# HG changeset patch # User cavaliet # Date 1397138147 -7200 # Node ID 1a24fb79eb11bed64ec8e6145284b5d7a7f302d7 # Parent 75b5e67ec752c9492ad7a156ef0c8f8eca79702f v1.53 : tagging to taggit migration diff -r 75b5e67ec752 -r 1a24fb79eb11 .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Thu Apr 03 15:58:25 2014 +0200 +++ b/.settings/org.eclipse.core.resources.prefs Thu Apr 10 15:55:47 2014 +0200 @@ -1,4 +1,3 @@ -#Thu Sep 19 17:16:28 CEST 2013 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 @@ -38,6 +37,7 @@ encoding//src/ldt/ldt/ldt_utils/migrations/0026_set_relative_ldtproject.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0027_auto__chg_field_project_owner__chg_field_media_creator.py=utf-8 encoding//src/ldt/ldt/ldt_utils/migrations/0028_all_users_in_everyone.py=utf-8 +encoding//src/ldt/ldt/ldt_utils/migrations/0029_tagging_to_taggit.py=utf-8 encoding//src/ldt/ldt/ldt_utils/views/json.py=utf-8 encoding//src/ldt/ldt/management/commands/synciri.py=utf-8 encoding//src/ldt/ldt/management/commands/updateiriurlinprojects.py=utf-8 @@ -45,6 +45,7 @@ encoding//src/ldt/ldt/test/test_runner.py=utf-8 encoding//src/ldt/ldt/text/migrations/0001_initial.py=utf-8 encoding//src/ldt/ldt/text/migrations/0002_auto__chg_field_annotation_external_id.py=utf-8 +encoding//src/ldt/ldt/text/migrations/0003_auto__del_field_annotation_tags_field.py=utf-8 encoding//src/ldt/ldt/user/migrations/0001_initial.py=utf-8 encoding//src/ldt/ldt/user/migrations/0005_add_permission_owner_group.py=utf-8 encoding//src/ldt/ldt/user/migrations/0008_auto__chg_field_groupprofile_image__chg_field_groupprofile_group__chg_.py=utf-8 diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/__init__.py --- a/src/ldt/ldt/__init__.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/__init__.py Thu Apr 10 15:55:47 2014 +0200 @@ -1,6 +1,6 @@ __all__ = ["VERSION", "get_version", "__version__"] -VERSION = (1, 52, 7, "final", 0) +VERSION = (1, 53, 0, "final", 0) def get_version(): diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/api/ldt/resources/segment.py --- a/src/ldt/ldt/api/ldt/resources/segment.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/api/ldt/resources/segment.py Thu Apr 10 15:55:47 2014 +0200 @@ -101,7 +101,7 @@ Q(start_ts__gte=begin, start_ts__lte=end) | # segment starts between begin and end Q(start_ts__gte=begin-F('duration'), start_ts__lte=end-F('duration')) |# segment ends between begin and end Q(start_ts__lte=begin, start_ts__gte=end-F('duration')) # period [begin:end] is included in the segment - ).select_related("project_obj") + ).select_related("project_obj").prefetch_related("tags") a = SegmentSerializer(content, segments) return self.create_response(request, a.serialize_to_cinelab()) diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/api/ldt/resources/tag.py --- a/src/ldt/ldt/api/ldt/resources/tag.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/api/ldt/resources/tag.py Thu Apr 10 15:55:47 2014 +0200 @@ -1,9 +1,9 @@ from django.conf import settings from django.conf.urls import url from django.core.paginator import Paginator, InvalidPage -from haystack.query import SearchQuerySet from ldt.ldt_utils.models import Segment -from tagging.models import Tag +from ldt.templatetags.taggit_extras_ldt import get_queryset +from taggit.models import Tag from tastypie.http import HttpNotFound from tastypie.resources import ModelResource, ALL from tastypie.utils import trailing_slash @@ -38,14 +38,17 @@ weight_steps = 10 tags_cloud = None if content_ids=="all" or segment_ids=="all": - tags_cloud = Tag.objects.cloud_for_model(Segment, steps=weight_steps) + #tags_cloud = Tag.objects.cloud_for_model(Segment, steps=weight_steps) + tags_cloud = get_queryset('ldt_utils.Segment') elif content_ids != "": # We get all the segments for these contents content_ids = content_ids.split(',') - tags_cloud = Tag.objects.cloud_for_model(Segment, filters={"iri_id__in":content_ids}, steps=weight_steps) + #tags_cloud = Tag.objects.cloud_for_model(Segment, filters={"iri_id__in":content_ids}, steps=weight_steps) + tags_cloud = get_queryset(Segment.objects.filter(iri_id__in=content_ids)) elif not all_segments and segment_ids != "": segment_ids = segment_ids.split(',') - tags_cloud = Tag.objects.cloud_for_model(Segment, filters={"element_id__in":segment_ids}, steps=weight_steps) + #tags_cloud = Tag.objects.cloud_for_model(Segment, filters={"element_id__in":segment_ids}, steps=weight_steps) + tags_cloud = get_queryset(Segment.objects.filter(element_id__in=segment_ids)) limit = request.GET.get('limit', getattr(settings, 'API_LIMIT_PER_PAGE', 20)) if limit == "0": @@ -75,4 +78,6 @@ # This function enable to add the weight of a tag in the bundle's datas, which is not in the tag model if bundle.obj and hasattr(bundle.obj,'font_size'): bundle.data['weight'] = bundle.obj.font_size + if bundle.obj and hasattr(bundle.obj,'num_times'): + bundle.data['weight'] = bundle.obj.num_times return bundle \ No newline at end of file diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/indexation/search_indexes.py --- a/src/ldt/ldt/indexation/search_indexes.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/indexation/search_indexes.py Thu Apr 10 15:55:47 2014 +0200 @@ -29,6 +29,9 @@ def get_model(self): return Segment + def prepare_tags(self, obj): + return ",".join([tag.name for tag in obj.tags.all()]) + class AnnotationIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) tags = indexes.CharField(model_attr='tags', indexed=True, stored=False) @@ -39,6 +42,9 @@ def get_model(self): return Annotation + + def prepare_tags(self, obj): + return ",".join([tag.name for tag in obj.tags.all()]) class ContentIndex(indexes.SearchIndex, indexes.Indexable): @@ -48,4 +54,7 @@ abstract = indexes.CharField(model_attr='description', indexed=True, stored=False, null=True) def get_model(self): - return Content \ No newline at end of file + return Content + + def prepare_tags(self, obj): + return ",".join([tag.name for tag in obj.tags.all()]) \ No newline at end of file diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/annotation_text.txt --- a/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/annotation_text.txt Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/annotation_text.txt Thu Apr 10 15:55:47 2014 +0200 @@ -1,4 +1,4 @@ -{{object.tags}} +{% for tag in object.tags.all %} {{ tag.name }} {% endfor %} {{object.title}} {{object.description}} {{object.text}} \ No newline at end of file diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/content_text.txt --- a/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/content_text.txt Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/content_text.txt Thu Apr 10 15:55:47 2014 +0200 @@ -1,3 +1,3 @@ -{{object.tags}} +{% for tag in object.tags.all %} {{ tag.name }} {% endfor %} {{object.title}} {{object.description}} \ No newline at end of file diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/segment_text.txt --- a/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/segment_text.txt Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/indexation/templates/search/indexes/ldt_utils/segment_text.txt Thu Apr 10 15:55:47 2014 +0200 @@ -1,3 +1,3 @@ -{{object.tags}} +{% for tag in object.tags.all %} {{ tag.name }} {% endfor %} {{object.title}} {{object.abstract}} \ No newline at end of file diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/contentindexer.py --- a/src/ldt/ldt/ldt_utils/contentindexer.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/contentindexer.py Thu Apr 10 15:55:47 2014 +0200 @@ -7,10 +7,9 @@ from ldt.ldt_utils.stat import update_stat_project, add_annotation_to_stat from ldt.ldt_utils.utils import reduce_text_node from ldt.utils.url import request_with_auth -from tagging import settings as tagging_settings import logging import lxml.etree #@UnresolvedImport -import tagging.utils +from taggit.utils import parse_tags logger = logging.getLogger(__name__) @@ -92,11 +91,6 @@ if tags is None: tags = u"" - tags_list = [tag[:tagging_settings.MAX_TAG_LENGTH] for tag in tagging.utils.parse_tag_input(tags)] - tags = u",".join(tags_list) - if u"," not in tags: - tags = u"," + tags - title = reduce_text_node(elementNode, "title/text()") abstract = reduce_text_node(elementNode, "abstract/text()") @@ -122,7 +116,6 @@ ensemble_id=ensembleId, cutting_id=decoupId, element_id=elementId, - tags=tags, title=title, abstract=abstract, duration=duration, @@ -133,14 +126,20 @@ project_id=ldt_id, audio_src=audio_src, audio_href=audio_href) + # Because of taggit managing (we HAVE to have primary key to ad tags), we save segment and then tags seg.polemics = seg.get_polemic(polemics) - if settings.LDT_INDEXATION_INSERT_BATCH_SIZE < 2: - seg.save() - else: - self.__segment_cache.append(seg) - if not (len(self.__segment_cache)%settings.LDT_INDEXATION_INSERT_BATCH_SIZE): - object_insert(Segment, self.__segment_cache) - self.__segment_cache = [] + seg.save() + for t in parse_tags(tags): + seg.tags.add(t) + seg.save() + +# if settings.LDT_INDEXATION_INSERT_BATCH_SIZE < 2: +# seg.save() +# else: +# self.__segment_cache.append(seg) +# if not (len(self.__segment_cache)%settings.LDT_INDEXATION_INSERT_BATCH_SIZE): +# object_insert(Segment, self.__segment_cache) +# self.__segment_cache = [] class ContentIndexer(LdtIndexer): @@ -221,7 +220,6 @@ ensemble_id=ensemble_id, cutting_id=cutting_id, element_id=element_id, - tags=tags_str, title=title, abstract=abstract, duration=duration, @@ -234,6 +232,9 @@ audio_href=audio_href) seg.polemics = seg.get_polemic(polemics) seg.save() + for t in parse_tags(tags_str): + seg.tags.add(t) + seg.save() add_annotation_to_stat(seg.content, seg.start_ts, seg.start_ts+seg.duration) diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/forms.py --- a/src/ldt/ldt/ldt_utils/forms.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/forms.py Thu Apr 10 15:55:47 2014 +0200 @@ -5,6 +5,7 @@ from ldt.security.forms import ShareForm from models import Project, Content, Media from utils import generate_uuid +from taggit.forms import TagField class LdtImportForm(forms.Form): importFile = forms.FileField() @@ -55,6 +56,7 @@ is_public = forms.BooleanField(required=False) front_project = forms.ModelChoiceField(queryset=Project.objects.none(), required=False, label=_("content.front_project")) duration = ldt_fields.LdtDurationField(required=True, label=_("content.duration")+" (Ms, M:S, H:M:S, HhM, Ss, Ssec)", formats=["%M:%S", "%H:%M:%S", "%Hh%M", "%Ss", "%Ssec"]) + tags = TagField(required=False) def clean_iri_id(self): data = self.cleaned_data.get('iri_id') @@ -70,9 +72,6 @@ if not iriurl_data: iriurl_data = "%s/%s.iri" % (iri_id_data, iri_id_data) cleaned_data['iriurl'] = iriurl_data - # if needed, we add a comma to the tag list, to force comma separated list and enable tags with spaces. - if ',' not in cleaned_data['tags'] and cleaned_data['tags']!="" : - cleaned_data['tags'] = cleaned_data['tags'] + ',' return cleaned_data class Meta: diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/migrations/0029_tagging_to_taggit.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/ldt_utils/migrations/0029_tagging_to_taggit.py Thu Apr 10 15:55:47 2014 +0200 @@ -0,0 +1,204 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models +from django.template.defaultfilters import slugify + +class Migration(DataMigration): + + def forwards(self, orm): + # Deleting field 'Content.tags' + db.delete_column(u'ldt_utils_content', 'tags') + # Deleting field 'Segment.tags_field' + db.delete_column(u'ldt_utils_segment', 'tags') + # Dirty version, but version who enables migration in one step : change table and column names + # instead of copying data from orm["tagging.*"] to orm["taggit.*"] + # Change columns name + db.rename_table('tagging_taggeditem', 'taggit_taggeditem') + db.rename_table('tagging_tag', 'taggit_tag') + db.add_column('taggit_tag', 'slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=255, null=True), keep_default=True) + """ + ALTER TABLE `tagging_tag` ADD COLUMN `slug` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' AFTER `name`; + ALTER TABLE `tagging_tag` CHANGE COLUMN `name` `name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '' AFTER `id`; + ALTER TABLE `tagging_taggeditem` CHANGE COLUMN `object_id` `object_id` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '' AFTER `content_type_id`; + ALTER TABLE `tagging_taggeditem` CHANGE COLUMN `object_id` `object_id` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '' AFTER `tag_id`; + """ + tags = orm['taggit.tag'].objects.all() + slugs = {} + for t in tags: + slug = slugify(t.name) + if slug in slugs: + slugs[slug] += 1 + s = slug + "-" + str(slugs[slug]) + else: + slugs[slug] = 1 + s = slug + t.slug = s + t.save() + print str(t.pk) + " : " + t.name + " : " + t.slug + + + def backwards(self, orm): + "Write your backwards methods here." + db.delete_column('taggit_tag', 'slug') + db.rename_table('taggit_tag', 'tagging_tag') + db.rename_table('taggit_taggeditem', 'tagging_taggeditem') + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'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'}), + u'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'}) + }, + u'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'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'lastname': ('django.db.models.fields.CharField', [], {'max_length': '512', 'null': 'True', 'blank': 'True'}) + }, + u'ldt_utils.content': { + 'Meta': {'ordering': "['title']", 'object_name': 'Content'}, + 'authors': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"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': u"orm['ldt_utils.Project']", 'null': 'True', 'blank': 'True'}), + u'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'9a8e899c-bb15-11e3-ba1e-c8bcc896c290'", 'unique': 'True', 'max_length': '255'}), + 'iriurl': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), + 'media_obj': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['ldt_utils.Media']", 'null': 'True', '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'}) + }, + u'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': u"orm['ldt_utils.Content']"}), + u'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'}) + }, + u'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': u"orm['user.LdtUser']", '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'}), + u'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'}) + }, + u'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': u"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'}), + u'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': u"orm['user.LdtUser']", 'null': 'True', 'blank': 'True'}), + 'state': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024'}) + }, + u'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': u"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'}), + u'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': u"orm['ldt_utils.Project']", 'null': 'True'}), + 'start_ts': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}) + }, + u'tagging.tag': { + 'Meta': {'ordering': "('name',)", 'object_name': 'Tag'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '50', 'db_index': 'True'}) + }, + u'tagging.taggeditem': { + 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TaggedItem'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), + 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': u"orm['tagging.Tag']"}) + }, + u'taggit.tag': { + 'Meta': {'object_name': 'Tag'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}) + }, + u'taggit.taggeditem': { + 'Meta': {'object_name': 'TaggedItem'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'taggit_taggeditem_tagged_items'", 'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "u'taggit_taggeditem_items'", 'to': u"orm['taggit.Tag']"}) + }, + u'user.ldtuser': { + 'Meta': {'object_name': 'LdtUser'}, + '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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('sorl.thumbnail.fields.ImageField', [], {'default': "'thumbnails/users/user_default_icon.png'", 'max_length': '200'}), + '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'}), + 'language': ('django.db.models.fields.CharField', [], {'default': "'fr'", 'max_length': '2'}), + '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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + } + } + + complete_apps = ['tagging', 'ldt_utils'] + symmetrical = True diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/models.py --- a/src/ldt/ldt/ldt_utils/models.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/models.py Thu Apr 10 15:55:47 2014 +0200 @@ -1,9 +1,7 @@ import datetime -import mimetypes +import lxml.etree #@UnresolvedImport import os.path import re -from shutil import move -import uuid from django.conf import settings from django.contrib.auth import get_user_model @@ -12,20 +10,21 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from guardian.shortcuts import assign, remove_perm, get_perms -import lxml.etree #@UnresolvedImport from sorl.thumbnail import ImageField -import tagging.fields -from tagging.models import Tag +from taggit.managers import TaggableManager from ldt.core.models import Document -from ldt.security import (get_current_user_or_admin, set_current_user, - get_current_user) +from ldt.security import get_current_user_or_admin, set_current_user, \ + get_current_user from ldt.security.manager import SafeManager from ldt.security.models import SafeModel from ldt.utils import generate_hash, url as url_utils from ldt.utils.web_url_management import get_web_url -from utils import (create_ldt, copy_ldt, create_empty_iri, update_iri, - generate_uuid) +import mimetypes +from shutil import move +from utils import create_ldt, copy_ldt, create_empty_iri, update_iri, \ + generate_uuid +import uuid from .events import post_project_save @@ -176,7 +175,7 @@ authors = models.ManyToManyField(Author, blank=True, verbose_name=_('content.authors')) duration = models.IntegerField(null=True, blank=True, verbose_name=_('content.duration')) content_creation_date = models.DateTimeField(null=True, blank=True, verbose_name=_('content.content_creation_date')) - tags = tagging.fields.TagField(max_length=2048, null=True, blank=True) + tags = TaggableManager() media_obj = models.ForeignKey('Media', blank=True, null=True) image = ImageField(upload_to="thumbnails/contents/", default=settings.DEFAULT_CONTENT_ICON, max_length=200) front_project = models.ForeignKey('Project', null=True, blank=True) @@ -801,7 +800,7 @@ ensemble_id = models.CharField(max_length=512, unique=False, db_index=True) cutting_id = models.CharField(max_length=512, unique=False, db_index=True) element_id = models.CharField(max_length=512, unique=False, db_index=True) - tags = tagging.fields.TagField(max_length=2048, null=True, blank=True, unique=False) + tags = TaggableManager() title = models.CharField(max_length=2048, unique=False, null=True, blank=True) duration = models.IntegerField(null=True) start_ts = models.IntegerField(null=True) diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/segmentserializer.py --- a/src/ldt/ldt/ldt_utils/segmentserializer.py Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/segmentserializer.py Thu Apr 10 15:55:47 2014 +0200 @@ -1,7 +1,6 @@ from django.conf import settings from ldt.ldt_utils.stat import get_string_from_buckets from ldt.security.utils import use_forbidden_url -from tagging.utils import parse_tag_input import logging import lxml.etree import uuid @@ -139,7 +138,7 @@ for seg in self.segments: segment_tags = [] - for tag in parse_tag_input(seg.tags): + for tag in [t.name for t in seg.tags.all()]: if not self.tags.has_key(tag): new_tag = { "meta": { diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Apr 10 15:55:47 2014 +0200 @@ -3,6 +3,7 @@ {% load thumbnail %} {% load front_tags %} {% load static %} +{% load taggit_extras_ldt %} {% block title %} {% if tag_label %} @@ -57,8 +58,9 @@
{% trans 'All categories of medias' %} : {% for t in tag_cloud %} - {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %}
+ {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}{% trans 'All categories of medias' %} : {% for t in tag_cloud %} - {{t.name}} - {% if not forloop.last %}, {% endif %}{% endfor %}
+ {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %} {% endblock %} diff -r 75b5e67ec752 -r 1a24fb79eb11 src/ldt/ldt/ldt_utils/templates/front/front_home.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Apr 03 15:58:25 2014 +0200 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Apr 10 15:55:47 2014 +0200 @@ -3,6 +3,7 @@ {% load thumbnail %} {% load front_tags %} {% load static %} +{% load taggit_extras_ldt %} {% block title %}{% trans "front.home" %}{% endblock %} @@ -47,8 +48,9 @@{% trans 'All categories of medias' %} : {% for t in tag_cloud %} - {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %}
+ {{t.name}}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}