from api.models import Deleted
from catalogue.forms import BookImportForm
from catalogue.models import Book, Tag, BookMedia, Fragment, Collection
+from catalogue.utils import related_tag_name
from picture.models import Picture
from picture.forms import PictureImportForm
def _tag_getter(category):
@classmethod
def get_tag(cls, book):
- return ", ".join(t[0] for t in book.related_info()['tags'].get(category, []))
+ return ", ".join(related_tag_name(t) for t in book.related_info()['tags'].get(category, []))
return get_tag
for plural, singular in category_singular.items():
setattr(BookDetails, plural, _tags_getter(singular))
EBOOK_FORMATS_WITH_COVERS = ['pdf', 'epub', 'mobi']
EBOOK_FORMATS = EBOOK_FORMATS_WITHOUT_CHILDREN + EBOOK_FORMATS_WITH_CHILDREN
+
+LANGUAGES_3TO2 = {
+ 'deu': 'de',
+ 'ger': 'de',
+ 'eng': 'en',
+ 'spa': 'es',
+ 'fra': 'fr',
+ 'fre': 'fr',
+ 'ita': 'it',
+ 'jpn': 'jp',
+ 'lit': 'lt',
+ 'pol': 'pl',
+ 'rus': 'ru',
+ 'ukr': 'uk',
+}
from django.db import models
from django.db.models.fields.files import FieldFile
from catalogue import app_settings
+from catalogue.constants import LANGUAGES_3TO2
from catalogue.utils import remove_zip, truncate_html_words
from celery.task import Task, task
from waiter.utils import clear_cache
html_output = self.transform(
book.wldocument(parse_dublincore=False),
fieldfile)
+ lang = book.language
+ lang = LANGUAGES_3TO2.get(lang, lang)
+ if lang not in [ln[0] for ln in settings.LANGUAGES]:
+ lang = None
+
if html_output:
fieldfile.save(None, ContentFile(html_output.get_string()),
save=False)
for theme_name in theme_names:
if not theme_name:
continue
- tag, created = Tag.objects.get_or_create(
- slug=slughifi(theme_name),
- category='theme')
- if created:
- tag.name = theme_name
- tag.sort_key = sortify(theme_name.lower())
- tag.save()
- themes.append(tag)
+ if lang == settings.LANGUAGE_CODE:
+ # Allow creating themes if book in default language.
+ tag, created = Tag.objects.get_or_create(
+ slug=slughifi(theme_name),
+ category='theme')
+ if created:
+ tag.name = theme_name
+ setattr(tag, "name_%s" % lang, theme_name)
+ tag.sort_key = sortify(theme_name.lower())
+ tag.save()
+ themes.append(tag)
+ elif lang is not None:
+ # Don't create unknown themes in non-default languages.
+ try:
+ tag = Tag.objects.get(category='theme',
+ **{"name_%s" % lang: theme_name})
+ except Tag.DoesNotExist:
+ pass
+ else:
+ themes.append(tag)
if not themes:
continue
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding field 'Tag.name_de'
+ db.add_column(u'catalogue_tag', 'name_de',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_en'
+ db.add_column(u'catalogue_tag', 'name_en',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_es'
+ db.add_column(u'catalogue_tag', 'name_es',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_fr'
+ db.add_column(u'catalogue_tag', 'name_fr',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_it'
+ db.add_column(u'catalogue_tag', 'name_it',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_lt'
+ db.add_column(u'catalogue_tag', 'name_lt',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_pl'
+ db.add_column(u'catalogue_tag', 'name_pl',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_ru'
+ db.add_column(u'catalogue_tag', 'name_ru',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.name_uk'
+ db.add_column(u'catalogue_tag', 'name_uk',
+ self.gf('django.db.models.fields.CharField')(blank=True, max_length=50, null=True, db_index=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_de'
+ db.add_column(u'catalogue_tag', 'description_de',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_en'
+ db.add_column(u'catalogue_tag', 'description_en',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_es'
+ db.add_column(u'catalogue_tag', 'description_es',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_fr'
+ db.add_column(u'catalogue_tag', 'description_fr',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_it'
+ db.add_column(u'catalogue_tag', 'description_it',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_lt'
+ db.add_column(u'catalogue_tag', 'description_lt',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_pl'
+ db.add_column(u'catalogue_tag', 'description_pl',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_ru'
+ db.add_column(u'catalogue_tag', 'description_ru',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+ # Adding field 'Tag.description_uk'
+ db.add_column(u'catalogue_tag', 'description_uk',
+ self.gf('django.db.models.fields.TextField')(null=True, blank=True),
+ keep_default=False)
+
+
+ def backwards(self, orm):
+ # Deleting field 'Tag.name_de'
+ db.delete_column(u'catalogue_tag', 'name_de')
+
+ # Deleting field 'Tag.name_en'
+ db.delete_column(u'catalogue_tag', 'name_en')
+
+ # Deleting field 'Tag.name_es'
+ db.delete_column(u'catalogue_tag', 'name_es')
+
+ # Deleting field 'Tag.name_fr'
+ db.delete_column(u'catalogue_tag', 'name_fr')
+
+ # Deleting field 'Tag.name_it'
+ db.delete_column(u'catalogue_tag', 'name_it')
+
+ # Deleting field 'Tag.name_lt'
+ db.delete_column(u'catalogue_tag', 'name_lt')
+
+ # Deleting field 'Tag.name_pl'
+ db.delete_column(u'catalogue_tag', 'name_pl')
+
+ # Deleting field 'Tag.name_ru'
+ db.delete_column(u'catalogue_tag', 'name_ru')
+
+ # Deleting field 'Tag.name_uk'
+ db.delete_column(u'catalogue_tag', 'name_uk')
+
+ # Deleting field 'Tag.description_de'
+ db.delete_column(u'catalogue_tag', 'description_de')
+
+ # Deleting field 'Tag.description_en'
+ db.delete_column(u'catalogue_tag', 'description_en')
+
+ # Deleting field 'Tag.description_es'
+ db.delete_column(u'catalogue_tag', 'description_es')
+
+ # Deleting field 'Tag.description_fr'
+ db.delete_column(u'catalogue_tag', 'description_fr')
+
+ # Deleting field 'Tag.description_it'
+ db.delete_column(u'catalogue_tag', 'description_it')
+
+ # Deleting field 'Tag.description_lt'
+ db.delete_column(u'catalogue_tag', 'description_lt')
+
+ # Deleting field 'Tag.description_pl'
+ db.delete_column(u'catalogue_tag', 'description_pl')
+
+ # Deleting field 'Tag.description_ru'
+ db.delete_column(u'catalogue_tag', 'description_ru')
+
+ # Deleting field 'Tag.description_uk'
+ db.delete_column(u'catalogue_tag', 'description_uk')
+
+
+ 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'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'catalogue.book': {
+ 'Meta': {'ordering': "('sort_key',)", 'object_name': 'Book'},
+ '_related_info': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'common_slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'cover': ('catalogue.fields.EbookField', [], {'max_length': '100', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'epub_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'epub'", 'blank': 'True'}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': '{}'}),
+ 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'fb2'", 'blank': 'True'}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'html_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'html'", 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'pol'", 'max_length': '3', 'db_index': 'True'}),
+ 'mobi_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'mobi'", 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}),
+ 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'pdf_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'pdf'", 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'txt'", 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'xml_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'xml'", 'blank': 'True'})
+ },
+ 'catalogue.bookmedia': {
+ 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'},
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': '{}'}),
+ 'file': ('catalogue.fields.OverwritingFileField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
+ 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'", 'db_index': 'True'}),
+ 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'})
+ },
+ 'catalogue.collection': {
+ 'Meta': {'ordering': "('title',)", 'object_name': 'Collection'},
+ 'book_slugs': ('django.db.models.fields.TextField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'})
+ },
+ 'catalogue.fragment': {
+ 'Meta': {'ordering': "('book', 'anchor')", 'object_name': 'Fragment'},
+ 'anchor': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'fragments'", 'to': "orm['catalogue.Book']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_text': ('django.db.models.fields.TextField', [], {}),
+ 'text': ('django.db.models.fields.TextField', [], {})
+ },
+ 'catalogue.tag': {
+ 'Meta': {'ordering': "('sort_key',)", 'unique_together': "(('slug', 'category'),)", 'object_name': 'Tag'},
+ 'book_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'category': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'description_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_it': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'name_de': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_en': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_es': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_fr': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_it': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_lt': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_pl': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_ru': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_uk': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'})
+ },
+ 'catalogue.tagrelation': {
+ 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TagRelation', 'db_table': "u'catalogue_tag_relation'"},
+ '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': "orm['catalogue.Tag']"})
+ },
+ 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'})
+ }
+ }
+
+ complete_apps = ['catalogue']
\ No newline at end of file
--- /dev/null
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+from django.conf import settings
+
+class Migration(DataMigration):
+
+ def forwards(self, orm):
+ "Write your forwards methods here."
+ # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
+ for t in orm.Tag.objects.filter(category__in=('author', 'epoch', 'genre', 'kind', 'theme')):
+ setattr(t, "name_%s" % settings.LANGUAGE_CODE, t.name)
+ t.save()
+ orm.Book.objects.all().update(_related_info=None)
+
+ def backwards(self, orm):
+ "Write your backwards methods here."
+ orm.Book.objects.all().update(_related_info=None)
+
+
+ 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'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': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ u'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': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'catalogue.book': {
+ 'Meta': {'ordering': "('sort_key',)", 'object_name': 'Book'},
+ '_related_info': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'common_slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'cover': ('catalogue.fields.EbookField', [], {'max_length': '100', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'epub_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'epub'", 'blank': 'True'}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': '{}'}),
+ 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'fb2'", 'blank': 'True'}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'html_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'html'", 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'default': "'pol'", 'max_length': '3', 'db_index': 'True'}),
+ 'mobi_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'mobi'", 'blank': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}),
+ 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
+ 'pdf_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'pdf'", 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'txt'", 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ 'xml_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'xml'", 'blank': 'True'})
+ },
+ 'catalogue.bookmedia': {
+ 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'},
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}),
+ 'extra_info': ('jsonfield.fields.JSONField', [], {'default': '{}'}),
+ 'file': ('catalogue.fields.OverwritingFileField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}),
+ 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'", 'db_index': 'True'}),
+ 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'})
+ },
+ 'catalogue.collection': {
+ 'Meta': {'ordering': "('title',)", 'object_name': 'Collection'},
+ 'book_slugs': ('django.db.models.fields.TextField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120', 'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'})
+ },
+ 'catalogue.fragment': {
+ 'Meta': {'ordering': "('book', 'anchor')", 'object_name': 'Fragment'},
+ 'anchor': ('django.db.models.fields.CharField', [], {'max_length': '120'}),
+ 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'fragments'", 'to': "orm['catalogue.Book']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_text': ('django.db.models.fields.TextField', [], {}),
+ 'text': ('django.db.models.fields.TextField', [], {})
+ },
+ 'catalogue.tag': {
+ 'Meta': {'ordering': "('sort_key',)", 'unique_together': "(('slug', 'category'),)", 'object_name': 'Tag'},
+ 'book_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'category': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+ 'description_de': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_en': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_es': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_fr': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_it': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_lt': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'description_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}),
+ 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'name_de': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_en': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_es': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_fr': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_it': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_lt': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_pl': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_ru': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'name_uk': ('django.db.models.fields.CharField', [], {'blank': True, 'max_length': '50', 'null': True, 'db_index': 'True'}),
+ 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}),
+ 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'})
+ },
+ 'catalogue.tagrelation': {
+ 'Meta': {'unique_together': "(('tag', 'content_type', 'object_id'),)", 'object_name': 'TagRelation', 'db_table': "u'catalogue_tag_relation'"},
+ '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': "orm['catalogue.Tag']"})
+ },
+ 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'})
+ }
+ }
+
+ complete_apps = ['catalogue']
+ symmetrical = True
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
import re
-from django.conf import settings as settings
+from django.conf import settings
from django.core.cache import get_cache
from django.db import models
from django.db.models import permalink
from catalogue import constants
from catalogue.fields import EbookField
from catalogue.models import Tag, Fragment, BookMedia
-from catalogue.utils import create_zip, split_tags, book_upload_path
+from catalogue.utils import create_zip, split_tags, book_upload_path, related_tag_name
from catalogue import app_settings
from catalogue import tasks
from newtagging import managers
created_at = models.DateTimeField(_('creation date'), auto_now_add=True, db_index=True)
changed_at = models.DateTimeField(_('creation date'), auto_now=True, db_index=True)
parent_number = models.IntegerField(_('parent number'), default=0)
- extra_info = jsonfield.JSONField(_('extra information'), default='{}')
+ extra_info = jsonfield.JSONField(_('extra information'), default={})
gazeta_link = models.CharField(blank=True, max_length=240)
wiki_link = models.CharField(blank=True, max_length=240)
# files generated during publication
'author', 'kind', 'genre', 'epoch'))
tags = split_tags(tags)
for category in tags:
- rel['tags'][category] = [
- (t.name, t.slug) for t in tags[category]]
+ cat = []
+ for tag in tags[category]:
+ tag_info = {'slug': tag.slug}
+ for lc, ln in settings.LANGUAGES:
+ tag_name = getattr(tag, "name_%s" % lc)
+ if tag_name:
+ tag_info["name_%s" % lc] = tag_name
+ cat.append(tag_info)
+ rel['tags'][category] = cat
for media_format in BookMedia.formats:
rel['media'][media_format] = self.has_media(media_format)
def pretty_title(self, html_links=False):
book = self
rel_info = book.related_info()
- names = [(name, Tag.create_url('author', slug))
- for name, slug in rel_info['tags']['author']]
+ names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
+ for tag in rel_info['tags'].get('author', ())]
if 'parents' in rel_info:
books = [(name, Book.create_url(slug))
for name, slug in rel_info['parents']]
name = models.CharField(_('name'), max_length="100")
file = OverwritingFileField(_('file'), upload_to=book_upload_path())
uploaded_at = models.DateTimeField(_('creation date'), auto_now_add=True, editable=False, db_index=True)
- extra_info = jsonfield.JSONField(_('extra information'), default='{}', editable=False)
+ extra_info = jsonfield.JSONField(_('extra information'), default={}, editable=False)
book = models.ForeignKey('Book', related_name='media')
source_sha1 = models.CharField(null=True, blank=True, max_length=40, editable=False)
import django.dispatch
from catalogue.models import Tag, BookMedia, Book, Fragment, Collection
from catalogue import tasks
+from catalogue.utils import delete_from_cache_by_language
from newtagging.models import tags_updated
def _post_delete_handler(sender, instance, **kwargs):
""" refresh Book on BookMedia delete """
if sender == Collection:
- permanent_cache.delete('catalogue.collection:%s' % instance.slug)
- permanent_cache.delete('catalogue.catalogue')
+ delete_from_cache_by_language(permanent_cache, 'catalogue.collection:%s/%%s' % instance.slug)
+ delete_from_cache_by_language(permanent_cache, 'catalogue.catalogue/%s')
post_delete.connect(_post_delete_handler)
""" refresh all the short_html stuff on BookMedia update """
if sender == BookMedia:
instance.book.save()
- permanent_cache.delete_many([
- 'catalogue.audiobook_list', 'catalogue.daisy_list'])
+ delete_from_cache_by_language(permanent_cache, 'catalogue.audiobook_list/%s')
+ delete_from_cache_by_language(permanent_cache, 'catalogue.daisy_list/%s')
elif sender == Collection:
- permanent_cache.delete('catalogue.collection:%s' % instance.slug)
- permanent_cache.delete('catalogue.catalogue')
+ delete_from_cache_by_language(permanent_cache, 'catalogue.collection:%s/%%s' % instance.slug)
+ delete_from_cache_by_language(permanent_cache, 'catalogue.catalogue/%s')
post_save.connect(_post_save_handler)
def post_publish(sender, **kwargs):
- permanent_cache.delete('catalogue.book_list')
- permanent_cache.delete('catalogue.catalogue')
+ delete_from_cache_by_language(permanent_cache, 'catalogue.book_list/%s')
+ delete_from_cache_by_language(permanent_cache, 'catalogue.catalogue/%s')
Book.published.connect(post_publish)
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
# For instance, Pictures do not have 'genre' field.
continue
for tag_name in tag_names:
+ lang = getattr(tag_name, 'lang', settings.LANGUAGE_CODE)
tag_sort_key = tag_name
if category == 'author':
tag_sort_key = tag_name.last_name
tag_name = tag_name.readable()
- tag, created = Tag.objects.get_or_create(slug=slughifi(tag_name), category=category)
- if created:
- tag.name = tag_name
- tag.sort_key = sortify(tag_sort_key.lower())
- tag.save()
- meta_tags.append(tag)
+ if lang == settings.LANGUAGE_CODE:
+ # Allow creating new tag, if it's in default language.
+ tag, created = Tag.objects.get_or_create(slug=slughifi(tag_name), category=category)
+ if created:
+ tag.name = tag_name
+ setattr(tag, "name_%s" % lang, tag_name)
+ tag.sort_key = sortify(tag_sort_key.lower())
+ tag.save()
+ meta_tags.append(tag)
+ else:
+ # Ignore unknown tags in non-default languages.
+ try:
+ tag = Tag.objects.get(category=category, **{"name_%s" % lang: tag_name})
+ except Tag.DoesNotExist:
+ pass
+ else:
+ meta_tags.append(tag)
return meta_tags
{% extends "base.html" %}
-{% load cache i18n %}
+{% load i18n %}
{% load thumbnail %}
-{% load common_tags catalogue_tags pagination_tags %}
+{% load common_tags catalogue_tags %}
{% block titleextra %}{{ book.pretty_title }}{% endblock %}
{% block ogimage %}{% if book.cover %}{{ book.cover.url|build_absolute_uri:request }}{% endif %}{% endblock %}
<div class="book-box-head">
<div class="author">
- {% for name, slug in related.tags.author %}
- <a href="{% tag_url 'author' slug %}">{{ name }}</a>{% if not forloop.last %},
+ {% for tag in related.tags.author %}
+ <a href="{% tag_url 'author' tag.slug %}">{% related_tag_name tag %}</a>{% if not forloop.last %},
{% endif %}{% endfor %}{% for title, slug in related.parents %},
<a href="{% url 'book_detail' slug %}">{{ title }}</a>{% endfor %}
</div>
<span class="category">
<span class="mono"> {% trans "Epoch" %}:</span> <span class="book-box-tag">
- {% for name, slug in related.tags.epoch %}
- <a href="{% tag_url 'epoch' slug %}">{{ name }}</a>
+ {% for tag in related.tags.epoch %}
+ <a href="{% tag_url 'epoch' tag.slug %}">{% related_tag_name tag %}</a>
{% if not forloop.last %}<span>, </span>{% endif %}
{% endfor %}
</span></span>
<span class="category">
<span class="mono"> {% trans "Kind" %}:</span> <span class="book-box-tag">
- {% for name, slug in related.tags.kind %}
- <a href="{% tag_url 'kind' slug %}">{{ name }}</a>
+ {% for tag in related.tags.kind %}
+ <a href="{% tag_url 'kind' tag.slug %}">{% related_tag_name tag %}</a>
{% if not forloop.last %}<span>, </span>{% endif %}
{% endfor %}
</span></span>
<span class="category">
<span class="mono"> {% trans "Genre" %}:</span> <span class="book-box-tag">
- {% for name, slug in related.tags.genre %}
- <a href="{% tag_url 'genre' slug %}">{{ name }}</a>
+ {% for tag in related.tags.genre %}
+ <a href="{% tag_url 'genre' tag.slug %}">{% related_tag_name tag %}</a>
{% if not forloop.last %}<span>, </span>{% endif %}
{% endfor %}
</span></span>
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.utils.translation import ugettext as _
-from catalogue.utils import split_tags
+from catalogue.utils import split_tags, related_tag_name as _related_tag_name
from catalogue.models import Book, BookMedia, Fragment, Tag
from catalogue.constants import LICENSES
@register.inclusion_tag('catalogue/book_mini_box.html')
def book_mini(book):
- author_str = ", ".join(name
- for name, url in book.related_info()['tags']['author'])
+ author_str = ", ".join(related_tag_name(tag)
+ for tag in book.related_info()['tags'].get('author', ()))
return {
'book': book,
'author_str': author_str,
"icon": "img/licenses/%s.png" % known['icon'],
"license_description": known['description'],
}
+
+
+@register.simple_tag
+def related_tag_name(tag, lang=None):
+ return _related_tag_name(tag, lang)
related_info = book.related_info()
related_themes = book.related_themes()
for category in 'author', 'kind', 'genre', 'epoch':
- self.assertTrue('tag' in [tag[1] for tag in related_info['tags'][category]],
+ self.assertTrue('tag' in [tag['slug'] for tag in related_info['tags'][category]],
'missing related tag for %s' % category)
self.assertTrue('tag' in [tag.slug for tag in related_themes])
related_themes = book.related_themes()
self.assertEqual(related_info['tags']['author'],
- [('Common Man', 'common-man')])
+ [{'name_pl': 'Common Man', 'slug': 'common-man'}])
self.assertEqual(related_info['tags']['kind'],
- [('Kind', 'kind')])
+ [{'name_pl': 'Kind', 'slug': 'kind'}])
self.assertEqual([(tag.name, tag.count) for tag in related_themes],
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
from django.core.files.uploadedfile import UploadedFile
from django.core.files.storage import DefaultStorage
from django.utils.encoding import force_unicode
+from django.utils.translation import get_language
from django.conf import settings
from os import mkdir, path, unlink
from errno import EEXIST, ENOENT
connection.queries = trim_to > 0 \
and connection.queries[-trim_to:] \
or []
-
+
+
+def related_tag_name(tag_info, language=None):
+ return tag_info.get("name_%s" % (language or get_language()),
+ tag_info.get("name_%s" % settings.LANGUAGE_CODE, ""))
+
+
+def delete_from_cache_by_language(cache, key_template):
+ cache.delete_many([key_template % lc for lc, ln in settings.LANGUAGES])
from django.utils.datastructures import SortedDict
from django.utils.http import urlquote_plus
from django.utils import translation
-from django.utils.translation import ugettext as _, ugettext_lazy
+from django.utils.translation import get_language, ugettext as _, ugettext_lazy
from django.views.decorators.vary import vary_on_headers
from ajaxable.utils import JSONResponse, AjaxableFormView
@vary_on_headers('X-Requested-With')
def catalogue(request):
- cache_key='catalogue.catalogue'
+ cache_key='catalogue.catalogue/' + get_language()
output = permanent_cache.get(cache_key)
if output is None:
tags = models.Tag.objects.exclude(
context=None,
):
""" generates a listing of all books, optionally filtered with a test function """
+ cache_key = "%s/%s" % (cache_key, get_language())
cached = permanent_cache.get(cache_key)
if cached is not None:
rendered_nav, rendered_book_list = cached
from django.utils.translation import ugettext_lazy as _, ugettext, override
import getpaid
from catalogue.models import Book
-from catalogue.utils import get_random_hash
+from catalogue.utils import get_random_hash, related_tag_name
from polls.models import Poll
from django.contrib.sites.models import Site
from . import app_settings
'funding/email/published.txt', {
'offer': self,
'book': self.book,
- 'author': ", ".join(a[0] for a in self.book.related_info()['tags']['author']),
+ 'author': ", ".join(related_tag_name(a) for a in self.book.related_info()['tags']['author']),
'current': self.current(),
})
class SponsorPage(models.Model):
name = models.CharField(_('name'), max_length=120)
- sponsors = JSONField(_('sponsors'), default='{}')
+ sponsors = JSONField(_('sponsors'), default={})
_html = models.TextField(blank=True, editable=False)
sprite = models.ImageField(upload_to='sponsorzy/sprite', blank=True)
<section id="main-last">
<h1><a href="{% url 'recent_list' %}">{% trans "Recent publications" %}</a></h1>
- {% cache 60 last-published-on-main %}
+ {% cache 60 last-published-on-main LANGUAGE_CODE %}
{% for book in last_published %}
{% book_mini book %}
{% endfor %}
-Subproject commit a7d898e7b37b773ec111aa395f9591d61b7a1d46
+Subproject commit 6b327e1a303fa8512cd5c56684bab2869198c01e
# django
Django>=1.5,<1.6
-fnpdjango>=0.1.6,<0.2
+fnpdjango>=0.1.8,<0.2
South>=0.7 # migrations for django
django-pipeline>=1.2.24,<1.3
django-pagination>=1.0
django-maintenancemode>=0.10
django-piston>=0.2.2.1,<0.2.3
--e git+git://github.com/bradjasper/django-jsonfield.git@e67ec8c3652e61d8b47cc8db012a63f5ad39323d#egg=django-jsonfield
+jsonfield>=0.9.20
django-picklefield
#django-allauth<0.10 with migration fix
#
from modeltranslation.translator import translator, TranslationOptions
+from catalogue.models import Tag
from infopages.models import InfoPage
class InfoPageTranslationOptions(TranslationOptions):
fields = ('title', 'left_column', 'right_column')
+class TagTranslationOptions(TranslationOptions):
+ fields = ('name', 'description')
+
translator.register(InfoPage, InfoPageTranslationOptions)
+translator.register(Tag, TagTranslationOptions)