# HG changeset patch # User cavaliet # Date 1348827610 -7200 # Node ID e7546394653c0f048b5f22995d5d0afdd3f30fcc # Parent 37bad74c2520ada56aecd43fd561a9ca58b16582 add audio annotation to segment api and correct reindex command. diff -r 37bad74c2520 -r e7546394653c .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Wed Sep 26 19:52:15 2012 +0200 +++ b/.settings/org.eclipse.core.resources.prefs Fri Sep 28 12:20:10 2012 +0200 @@ -1,3 +1,4 @@ +#Fri Sep 28 10:36:06 CEST 2012 eclipse.preferences.version=1 encoding//src/ldt/ldt/core/migrations/0001_initial.py=utf-8 encoding//src/ldt/ldt/core/migrations/0002_auto__del_owner.py=utf-8 @@ -12,17 +13,24 @@ encoding//src/ldt/ldt/ldt_utils/migrations/0003_auto__chg_field_project_owner.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0004_auto__add_field_project_description.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0006_auto__add_field_media_image.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0008_auto__add_field_project_image.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0009_auto__chg_field_content_image__chg_field_project_image.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0010_auto__add_annotationstat.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0012_auto__add_field_content_last_annotated.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0013_auto__add_field_content_front_project__chg_field_content_last_annotate.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0014_auto__del_annotationstat__chg_field_content_last_annotated.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0015_auto__add_contentstat__del_field_content_last_annotated__del_field_con.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0016_one_to_one_stat_annotation.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0017_correct_image_path.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0018_auto__chg_field_content_iri_id__chg_field_project_ldt_id__chg_field_au.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0019_recalculate_media_hash_src.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0020_auto__add_field_segment_id_hash__chg_field_segment_iri_id__chg_field_s.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0021_recalculate_segment_id_hash_script.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0022_auto__add_unique_media_src_hash__chg_field_segment_cutting_id__chg_fie.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0023_auto__add_field_segment_audio_src__add_field_segment_audio_href.py=utf-8 encoding//src/ldt/ldt/ldt_utils/views/json.py=utf-8 encoding//src/ldt/ldt/management/utils.py=utf-8 encoding//src/ldt/ldt/test/test_runner.py=utf-8 diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/ldt_utils/contentindexer.py --- a/src/ldt/ldt/ldt_utils/contentindexer.py Wed Sep 26 19:52:15 2012 +0200 +++ b/src/ldt/ldt/ldt_utils/contentindexer.py Fri Sep 28 12:20:10 2012 +0200 @@ -83,6 +83,13 @@ ldt_id = u"" if project: ldt_id = project.ldt_id + # audio annotation management + audio_src = u"" + audio_href = u"" + audio_node = elementNode.xpath('audio') + if audio_node: + audio_src = audio_node[0].get(u"source", u"") + audio_href = audio_node[0].text seg = Segment(content=content, iri_id=content.iri_id, @@ -97,7 +104,9 @@ start_ts=start_ts, date=date_str, project_obj=project, - project_id=ldt_id) + project_id=ldt_id, + audio_src=audio_src, + audio_href=audio_href) seg.polemics = seg.get_polemic(polemics) seg.save() diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/ldt_utils/migrations/0023_auto__add_field_segment_audio_src__add_field_segment_audio_href.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/ldt_utils/migrations/0023_auto__add_field_segment_audio_src__add_field_segment_audio_href.py Fri Sep 28 12:20:10 2012 +0200 @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.core.management import call_command +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'Segment.audio_src' + db.add_column('ldt_utils_segment', 'audio_src', + self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), + keep_default=False) + + # Adding field 'Segment.audio_href' + db.add_column('ldt_utils_segment', 'audio_href', + self.gf('django.db.models.fields.CharField')(max_length=512, null=True, blank=True), + keep_default=False) + + # Reindex all contents and projects + call_command('reindex', projects=True) + + + def backwards(self, orm): + # Deleting field 'Segment.audio_src' + db.delete_column('ldt_utils_segment', 'audio_src') + + # Deleting field 'Segment.audio_href' + db.delete_column('ldt_utils_segment', 'audio_href') + + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'ldt_utils.author': { + 'Meta': {'object_name': 'Author'}, + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), + 'firstname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}), + 'handle': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lastname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}) + }, + 'ldt_utils.content': { + 'Meta': {'ordering': "['title']", 'object_name': 'Content'}, + 'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ldt_utils.Author']", 'symmetrical': 'False', 'blank': 'True'}), + 'content_creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'front_project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ldt_utils.Project']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/contents/content_default_icon.png'", 'max_length': '200'}), + 'iri_id': ('django.db.models.fields.CharField', [], {'default': "u'ac7c8438-08ba-11e2-a905-c8bcc896c290'", 'unique': 'True', 'max_length': '255'}), + 'iriurl': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), + 'media_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ldt_utils.Media']", 'null': 'True', 'blank': 'True'}), + 'tags': ('tagging.fields.TagField', [], {'max_length': '2048', 'null': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'update_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) + }, + 'ldt_utils.contentstat': { + 'Meta': {'object_name': 'ContentStat'}, + 'annotation_volume_str': ('django.db.models.fields.CommaSeparatedIntegerField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'content': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'stat_annotation'", 'unique': 'True', 'to': "orm['ldt_utils.Content']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_annotated': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'null': 'True', 'blank': 'True'}), + 'nb_annotations': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}), + 'polemics_volume_str': ('django.db.models.fields.CommaSeparatedIntegerField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}) + }, + 'ldt_utils.media': { + 'Meta': {'object_name': 'Media'}, + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'creator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'external_id': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'external_permalink': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'external_publication_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'external_src_url': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'media_creation_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'mimetype_field': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}), + 'src': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), + 'src_hash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'update_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'videopath': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}) + }, + 'ldt_utils.project': { + 'Meta': {'ordering': "['title']", 'object_name': 'Project'}, + 'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}), + 'contents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ldt_utils.Content']", 'symmetrical': 'False'}), + 'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/projects/project_default_icon.png'", 'max_length': '200'}), + 'ldt': ('django.db.models.fields.TextField', [], {'null': 'True'}), + 'ldt_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}), + 'state': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024'}) + }, + 'ldt_utils.segment': { + 'Meta': {'object_name': 'Segment'}, + 'abstract': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'audio_href': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}), + 'audio_src': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'author': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), + 'content': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ldt_utils.Content']"}), + 'cutting_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}), + 'date': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), + 'duration': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'element_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}), + 'ensemble_id': ('django.db.models.fields.CharField', [], {'max_length': '512', 'db_index': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'id_hash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), + 'iri_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), + 'polemics': ('django.db.models.fields.IntegerField', [], {'default': '0', 'null': 'True', 'blank': 'True'}), + 'project_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'project_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ldt_utils.Project']", 'null': 'True'}), + 'start_ts': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'tags': ('tagging.fields.TagField', [], {'max_length': '2048', 'null': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['ldt_utils'] \ No newline at end of file diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Wed Sep 26 19:52:15 2012 +0200 +++ b/src/ldt/ldt/ldt_utils/models.py Fri Sep 28 12:20:10 2012 +0200 @@ -700,6 +700,8 @@ abstract = models.TextField(null=True, blank=True) polemics = models.IntegerField(null=True, blank=True, default=0) id_hash = models.CharField(max_length=128, unique=True, blank=True) + audio_src = models.CharField(max_length=255, unique=False, null=True, blank=True) + audio_href = models.CharField(max_length=512, unique=False, null=True, blank=True) # All combinations of polemic hashtags can be represented by a combination of diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/ldt_utils/projectserializer.py --- a/src/ldt/ldt/ldt_utils/projectserializer.py Wed Sep 26 19:52:15 2012 +0200 +++ b/src/ldt/ldt/ldt_utils/projectserializer.py Fri Sep 28 12:20:10 2012 +0200 @@ -196,7 +196,7 @@ res = element_node.xpath("audio") if len(res) > 0: element_audio_src = res[0].get(u"source", u"") - element_audio_href = res[0].text + element_audio_href = res[0].text element_tags = [] diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/ldt_utils/segmentserializer.py --- a/src/ldt/ldt/ldt_utils/segmentserializer.py Wed Sep 26 19:52:15 2012 +0200 +++ b/src/ldt/ldt/ldt_utils/segmentserializer.py Fri Sep 28 12:20:10 2012 +0200 @@ -171,8 +171,8 @@ 'polemics': [ ], 'audio': { 'mimetype': 'audio/mp3', - 'src': '', - 'href': 'null' + 'src': seg.audio_src, + 'href': seg.audio_href } }, diff -r 37bad74c2520 -r e7546394653c src/ldt/ldt/management/commands/reindex.py --- a/src/ldt/ldt/management/commands/reindex.py Wed Sep 26 19:52:15 2012 +0200 +++ b/src/ldt/ldt/management/commands/reindex.py Fri Sep 28 12:20:10 2012 +0200 @@ -19,16 +19,15 @@ ) def handle(self, *args, **options): - parser = self.create_parser("reindex", "") - options, _ = parser.parse_args() - - if options.content_id: - self.stdout.write('Creating index for %s\n' % options.content_id) - contentList = Content.objects.filter(iri_id=options.content_id) + content_id = options.get("content_id") + projects = options.get("projects") + + if content_id: + self.stdout.write('Creating index for %s\n' % content_id) + contentList = Content.objects.filter(iri_id=content_id) else: self.stdout.write('Creating contents index...\n') contentList = Content.objects.all() - count = contentList.count() c = lambda i,o: show_progress(i+1, count, o.title, 50) @@ -36,7 +35,7 @@ indexer = ContentIndexer(contentList, callback=c) indexer.index_all() - if options.projects: + if projects: self.stdout.write('Creating projects index...\n') projectList = Project.objects.filter(contents__in=contentList, state=2).distinct() count = projectList.count()