From 48c29c279aef18746d0d2f5d5f47f5b045814b32 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Wed, 15 Jun 2022 16:45:08 +0200 Subject: [PATCH] Add last scripts to notelemeta --- probarreau2-20211215.sql.gz | 0 .../commands/teleforma-export-marker.py | 25 +++++++++++++ ...ield_training_code__chg_field_training.py} | 37 ++++++++++++++++++- ...tion__chg_field_conference_city__chg_f.py} | 12 ++++++ ....py => 0139_auto__del_field_media_item.py} | 12 ++++++ teleforma/models/core.py | 25 +++++++++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 probarreau2-20211215.sql.gz create mode 100644 teleforma/management/commands/teleforma-export-marker.py rename teleforma/migrations/{0136_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py => 0137_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py} (97%) rename teleforma/migrations/{0137_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py => 0138_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py} (98%) rename teleforma/migrations/{0138_auto__del_field_media_item.py => 0139_auto__del_field_media_item.py} (97%) diff --git a/probarreau2-20211215.sql.gz b/probarreau2-20211215.sql.gz new file mode 100644 index 00000000..e69de29b diff --git a/teleforma/management/commands/teleforma-export-marker.py b/teleforma/management/commands/teleforma-export-marker.py new file mode 100644 index 00000000..3549a6cc --- /dev/null +++ b/teleforma/management/commands/teleforma-export-marker.py @@ -0,0 +1,25 @@ +from django.core.management.base import BaseCommand + + + +from teleforma.models.core import Media +import json + +class Command(BaseCommand): + help = "Send orders to avis-verifies ftp" + + + def handle(self, *args, **options): + data = {} + import pdb;pdb.set_trace() + for media_item in Media.objects.all(): + + for marker_item in media_item.item.markers2.all(): + import pdb;pdb.set_trace() + data.append({ + 'item_id':marker_item.item.id, + 'time':marker_item.time, + 'public_id':marker_item.public_id + }) + with open('export-mediamarkers.json', 'w') as file: + file.write(json.dumps(data)) \ No newline at end of file diff --git a/teleforma/migrations/0136_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py b/teleforma/migrations/0137_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py similarity index 97% rename from teleforma/migrations/0136_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py rename to teleforma/migrations/0137_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py index 5519f8f4..2cf31fe9 100644 --- a/teleforma/migrations/0136_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py +++ b/teleforma/migrations/0137_auto__add_mediatranscoded__chg_field_training_code__chg_field_training.py @@ -4,7 +4,7 @@ from south.db import db from south.v2 import SchemaMigration from django.db import models -from teleforma.models.core import MediaTranscoded +from teleforma.models.core import MediaMarker, MediaTranscoded class Migration(SchemaMigration): @@ -21,6 +21,18 @@ class Migration(SchemaMigration): )) db.send_create_signal('teleforma', ['MediaTranscoded']) + # Adding model 'MediaMarker' + db.create_table('teleforma_media_markers', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('item', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='markers', null=True, to=orm['teleforma.Media'])), + ('public_id', self.gf('django.db.models.fields.CharField')(max_length=255)), + ('time', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), + ('title', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), + ('date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, null=True, blank=True)), + ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), + ('author', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='markers', null=True, to=orm['auth.User'])), + )) + db.send_create_signal('teleforma', ['MediaMarker']) # Changing field 'Training.code' db.alter_column('teleforma_training', 'code', self.gf('django.db.models.fields.CharField')(max_length=255)) @@ -364,6 +376,17 @@ class Migration(SchemaMigration): ) transcoded.save() + for marker_item in media_item.item.markers2.all(): + marker = MediaMarker( + item=media_item, + public_id=marker_item.public_id, + title=marker_item.title, + date=marker_item.date, + description=marker_item.description, + author=marker_item.author + ) + marker.save() + # # add media transcoded : original CRFPA code # for item in Media.objects.filter(conference=media_item.conference, course=media_item.course, course_type=media_item.course_type, period=media_item.period): # if item.id == media_item.id: @@ -841,6 +864,7 @@ class Migration(SchemaMigration): }, 'teleforma.auditor': { 'Meta': {'ordering': "['user__last_name']", 'object_name': 'Auditor'}, + 'activity': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'address': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'block_fifpl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'block_testimonials': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), @@ -1027,6 +1051,17 @@ class Migration(SchemaMigration): 'mimetype': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}) }, + 'teleforma.mediamarker': { + 'Meta': {'ordering': "['time']", 'object_name': 'MediaMarker', 'db_table': "'teleforma_media_markers'"}, + 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['auth.User']"}), + 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'item': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['teleforma.Media']"}), + 'public_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) + }, 'teleforma.organization': { 'Meta': {'object_name': 'Organization'}, 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), diff --git a/teleforma/migrations/0137_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py b/teleforma/migrations/0138_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py similarity index 98% rename from teleforma/migrations/0137_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py rename to teleforma/migrations/0138_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py index 6a0a964d..6c83b5e2 100644 --- a/teleforma/migrations/0137_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py +++ b/teleforma/migrations/0138_auto__add_locationtype__add_location__chg_field_conference_city__chg_f.py @@ -196,6 +196,7 @@ class Migration(SchemaMigration): }, 'teleforma.auditor': { 'Meta': {'ordering': "['user__last_name']", 'object_name': 'Auditor'}, + 'activity': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'address': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'block_fifpl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'block_testimonials': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), @@ -398,6 +399,17 @@ class Migration(SchemaMigration): 'mimetype': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}) }, + 'teleforma.mediamarker': { + 'Meta': {'ordering': "['time']", 'object_name': 'MediaMarker', 'db_table': "'teleforma_media_markers'"}, + 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['auth.User']"}), + 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'item': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['teleforma.Media']"}), + 'public_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) + }, 'teleforma.organization': { 'Meta': {'object_name': 'Organization'}, 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), diff --git a/teleforma/migrations/0138_auto__del_field_media_item.py b/teleforma/migrations/0139_auto__del_field_media_item.py similarity index 97% rename from teleforma/migrations/0138_auto__del_field_media_item.py rename to teleforma/migrations/0139_auto__del_field_media_item.py index 78c23f5c..efcdec45 100644 --- a/teleforma/migrations/0138_auto__del_field_media_item.py +++ b/teleforma/migrations/0139_auto__del_field_media_item.py @@ -165,6 +165,7 @@ class Migration(SchemaMigration): }, 'teleforma.auditor': { 'Meta': {'ordering': "['user__last_name']", 'object_name': 'Auditor'}, + 'activity': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), 'address': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'block_fifpl': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'block_testimonials': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), @@ -366,6 +367,17 @@ class Migration(SchemaMigration): 'mimetype': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'status': ('django.db.models.fields.IntegerField', [], {'default': '1'}) }, + 'teleforma.mediamarker': { + 'Meta': {'ordering': "['time']", 'object_name': 'MediaMarker', 'db_table': "'teleforma_media_markers'"}, + 'author': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['auth.User']"}), + 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'null': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'item': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'markers'", 'null': 'True', 'to': "orm['teleforma.Media']"}), + 'public_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) + }, 'teleforma.organization': { 'Meta': {'object_name': 'Organization'}, 'description': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 4614c90b..4721020b 100755 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -558,6 +558,31 @@ class MediaTranscoded(Model): db_table = app_label + '_media_transcoded' +class MediaMarker(Model): + "2D marker object : text value vs. time (in seconds)" + + element_type = 'marker' + + item = ForeignKey('Media', related_name="markers", verbose_name=_('item'), blank=True, null=True) + public_id = CharField(_('public_id'), max_length=255) + time = FloatField(_('time (s)'), blank=True, null=True) + title = CharField(_('title'), blank=True, null=True, max_length=255) + date = DateTimeField(_('date'), blank=True, null=True) + description = TextField(_('description'), blank=True, null=True) + author = ForeignKey(User, related_name="markers", verbose_name=_('author'), + blank=True, null=True) + + class Meta(MetaCore): + db_table = app_label + '_media_markers' + ordering = ['time'] + + def __unicode__(self): + if self.title: + return self.title + else: + return self.public_id + + class Media(MediaBase): "Describe a media resource linked to a conference" -- 2.39.5