From 4b4e3aa4d7f75f4bee66b3f3098cbeb756adb8d0 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 16 Oct 2014 13:48:02 +0200 Subject: [PATCH 1/1] Fixes #3509: support for long titles. --- .../migrations/0005_auto_20141016_1337.py | 19 +++++++++++++++++++ apps/catalogue/models/book.py | 4 ++-- .../migrations/0004_auto_20141016_1337.py | 19 +++++++++++++++++++ apps/picture/models.py | 4 ++-- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 apps/catalogue/migrations/0005_auto_20141016_1337.py create mode 100644 apps/picture/migrations/0004_auto_20141016_1337.py diff --git a/apps/catalogue/migrations/0005_auto_20141016_1337.py b/apps/catalogue/migrations/0005_auto_20141016_1337.py new file mode 100644 index 000000000..6de315722 --- /dev/null +++ b/apps/catalogue/migrations/0005_auto_20141016_1337.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0004_remove_booktags_count_related_info'), + ] + + operations = [ + migrations.AlterField( + model_name='book', + name='title', + field=models.CharField(max_length=32767, verbose_name='Title'), + ), + ] diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 3da9f0695..bfc9ec4f5 100644 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -40,7 +40,7 @@ def _ebook_upload_to(upload_path): class Book(models.Model): """Represents a book imported from WL-XML.""" - title = models.CharField(_('title'), max_length=120) + title = models.CharField(_('title'), max_length=32767) sort_key = models.CharField(_('sort key'), max_length=120, db_index=True, editable=False) sort_key_author = models.CharField(_('sort key by author'), max_length=120, db_index=True, editable=False, default=u'') slug = models.SlugField(_('slug'), max_length=120, db_index=True, @@ -99,7 +99,7 @@ class Book(models.Model): def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify - self.sort_key = sortify(self.title) + self.sort_key = sortify(self.title)[:120] self.title = unicode(self.title) # ??? try: diff --git a/apps/picture/migrations/0004_auto_20141016_1337.py b/apps/picture/migrations/0004_auto_20141016_1337.py new file mode 100644 index 000000000..88d124934 --- /dev/null +++ b/apps/picture/migrations/0004_auto_20141016_1337.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('picture', '0003_auto_20140924_1559'), + ] + + operations = [ + migrations.AlterField( + model_name='picture', + name='title', + field=models.CharField(max_length=32767, verbose_name='Title'), + ), + ] diff --git a/apps/picture/models.py b/apps/picture/models.py index 70efd781b..120750d7c 100644 --- a/apps/picture/models.py +++ b/apps/picture/models.py @@ -72,7 +72,7 @@ class Picture(models.Model): Picture resource. """ - title = models.CharField(_('title'), max_length=255) + title = models.CharField(_('title'), max_length=32767) slug = models.SlugField(_('slug'), max_length=120, db_index=True, unique=True) sort_key = models.CharField(_('sort key'), max_length=120, db_index=True, editable=False) sort_key_author = models.CharField(_('sort key by author'), max_length=120, db_index=True, editable=False, default=u'') @@ -161,7 +161,7 @@ class Picture(models.Model): raise Picture.AlreadyExists('Picture %s already exists' % picture_xml.slug) picture.areas.all().delete() - picture.title = unicode(picture_xml.picture_info.title)[:255] + picture.title = unicode(picture_xml.picture_info.title) picture.extra_info = picture_xml.picture_info.to_dict() picture_tags = set(catalogue.models.Tag.tags_from_info(picture_xml.picture_info)) -- 2.20.1