From c3545c19bd62da303fe0f8c49f82d8c340d965ea Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jul 2014 09:40:59 +0200 Subject: [PATCH] Translated source names. --- ..._add_field_source_name_en__add_field_so.py | 263 ++++++++++++++++++ apps/catalogue/models/source.py | 2 +- wolnelektury/translation.py | 6 +- 3 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 apps/catalogue/migrations/0019_auto__add_field_source_name_de__add_field_source_name_en__add_field_so.py diff --git a/apps/catalogue/migrations/0019_auto__add_field_source_name_de__add_field_source_name_en__add_field_so.py b/apps/catalogue/migrations/0019_auto__add_field_source_name_de__add_field_source_name_en__add_field_so.py new file mode 100644 index 000000000..9a861fc70 --- /dev/null +++ b/apps/catalogue/migrations/0019_auto__add_field_source_name_de__add_field_source_name_en__add_field_so.py @@ -0,0 +1,263 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as 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 'Source.name_de' + db.add_column(u'catalogue_source', 'name_de', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_en' + db.add_column(u'catalogue_source', 'name_en', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_es' + db.add_column(u'catalogue_source', 'name_es', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_fr' + db.add_column(u'catalogue_source', 'name_fr', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_it' + db.add_column(u'catalogue_source', 'name_it', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_lt' + db.add_column(u'catalogue_source', 'name_lt', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_pl' + db.add_column(u'catalogue_source', 'name_pl', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_ru' + db.add_column(u'catalogue_source', 'name_ru', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + # Adding field 'Source.name_uk' + db.add_column(u'catalogue_source', 'name_uk', + self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Source.name_de' + db.delete_column(u'catalogue_source', 'name_de') + + # Deleting field 'Source.name_en' + db.delete_column(u'catalogue_source', 'name_en') + + # Deleting field 'Source.name_es' + db.delete_column(u'catalogue_source', 'name_es') + + # Deleting field 'Source.name_fr' + db.delete_column(u'catalogue_source', 'name_fr') + + # Deleting field 'Source.name_it' + db.delete_column(u'catalogue_source', 'name_it') + + # Deleting field 'Source.name_lt' + db.delete_column(u'catalogue_source', 'name_lt') + + # Deleting field 'Source.name_pl' + db.delete_column(u'catalogue_source', 'name_pl') + + # Deleting field 'Source.name_ru' + db.delete_column(u'catalogue_source', 'name_ru') + + # Deleting field 'Source.name_uk' + db.delete_column(u'catalogue_source', 'name_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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + 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', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + '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': '255', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}), + 'cover_thumb': ('catalogue.fields.EbookField', [], {'max_length': '255', 'null': 'True', 'format_name': "'cover_thumb'", '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': '255', 'format_name': "'epub'", 'blank': 'True'}), + 'extra_info': ('jsonfield.fields.JSONField', [], {'default': '{}'}), + 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '255', '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': '255', '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': '255', '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': '255', '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'}), + 'sort_key_author': ('django.db.models.fields.CharField', [], {'default': "u''", 'max_length': '120', 'db_index': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}), + 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '255', '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': '255', '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': '600'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '512'}), + 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), + 'type': ('django.db.models.fields.CharField', [], {'max_length': '20', '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'}), + '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'}), + 'kind': ('django.db.models.fields.CharField', [], {'default': "'book'", 'max_length': '10', 'db_index': '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'}), + 'title_de': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_en': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_es': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_fr': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_it': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_lt': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_pl': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_ru': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'title_uk': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '120', 'null': 'True', 'blank': '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.source': { + 'Meta': {'ordering': "('netloc',)", 'object_name': 'Source'}, + 'name': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}), + 'name_de': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_en': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_es': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_fr': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_it': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_lt': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_pl': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_ru': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'name_uk': ('django.db.models.fields.CharField', [], {'max_length': '120', 'null': 'True', 'blank': 'True'}), + 'netloc': ('django.db.models.fields.CharField', [], {'max_length': '120', 'primary_key': 'True'}) + }, + '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'}), + 'culturepl_link': ('django.db.models.fields.CharField', [], {'max_length': '240', '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', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_en': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_es': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_fr': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_it': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_lt': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_pl': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_ru': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'name_uk': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'picture_count': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': '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'}), + 'wiki_link_de': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_en': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_es': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_fr': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_it': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_lt': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_pl': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_ru': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', 'blank': 'True'}), + 'wiki_link_uk': ('django.db.models.fields.CharField', [], {'max_length': '240', 'null': 'True', '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 diff --git a/apps/catalogue/models/source.py b/apps/catalogue/models/source.py index f530e07f4..d13161378 100644 --- a/apps/catalogue/models/source.py +++ b/apps/catalogue/models/source.py @@ -9,7 +9,7 @@ from django.utils.translation import ugettext_lazy as _ class Source(models.Model): """A collection of books, which might be defined before publishing them.""" netloc = models.CharField(_('network location'), max_length=120, primary_key=True) - name = models.CharField(_('name'), max_length=120) + name = models.CharField(_('name'), max_length=120, blank=True) class Meta: ordering = ('netloc',) diff --git a/wolnelektury/translation.py b/wolnelektury/translation.py index 95b9dd74f..b9e7b9c7c 100644 --- a/wolnelektury/translation.py +++ b/wolnelektury/translation.py @@ -4,7 +4,7 @@ # from modeltranslation.translator import translator, TranslationOptions -from catalogue.models import Collection, Tag +from catalogue.models import Collection, Tag, Source from infopages.models import InfoPage from chunks.models import Chunk @@ -17,10 +17,14 @@ class TagTranslationOptions(TranslationOptions): class CollectionTranslationOptions(TranslationOptions): fields = ('title', 'description') +class SourceTranslationOptions(TranslationOptions): + fields = ('name',) + class ChunkTranslationOptions(TranslationOptions): fields = ('content',) translator.register(InfoPage, InfoPageTranslationOptions) translator.register(Tag, TagTranslationOptions) translator.register(Collection, CollectionTranslationOptions) +translator.register(Source, SourceTranslationOptions) translator.register(Chunk, ChunkTranslationOptions) -- 2.20.1