From d454277a61e2f34e34ee87777b0d35724edf877e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 1 Jul 2014 09:32:57 +0200 Subject: [PATCH] Move source names to a model. --- apps/catalogue/admin.py | 7 +- apps/catalogue/constants.py | 6 - .../catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 11537 -> 11676 bytes .../catalogue/locale/pl/LC_MESSAGES/django.po | 69 ++++--- .../migrations/0018_auto__add_source.py | 192 ++++++++++++++++++ apps/catalogue/models/__init__.py | 1 + apps/catalogue/models/source.py | 21 ++ apps/catalogue/templatetags/catalogue_tags.py | 7 +- 8 files changed, 264 insertions(+), 39 deletions(-) create mode 100644 apps/catalogue/migrations/0018_auto__add_source.py create mode 100644 apps/catalogue/models/source.py diff --git a/apps/catalogue/admin.py b/apps/catalogue/admin.py index 87ab727e1..28cf53c37 100644 --- a/apps/catalogue/admin.py +++ b/apps/catalogue/admin.py @@ -6,7 +6,7 @@ from django.contrib import admin from django import forms from newtagging.admin import TaggableModelAdmin, TaggableModelForm -from catalogue.models import Tag, Book, Fragment, BookMedia, Collection +from catalogue.models import Tag, Book, Fragment, BookMedia, Collection, Source class TagAdmin(admin.ModelAdmin): @@ -58,7 +58,12 @@ class CollectionAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('title',)} +class SourceAdmin(admin.ModelAdmin): + list_display = ('netloc', 'name') + + admin.site.register(Tag, TagAdmin) admin.site.register(Book, BookAdmin) admin.site.register(Fragment, FragmentAdmin) admin.site.register(Collection, CollectionAdmin) +admin.site.register(Source, SourceAdmin) diff --git a/apps/catalogue/constants.py b/apps/catalogue/constants.py index 56fe93936..36f4f5dd3 100644 --- a/apps/catalogue/constants.py +++ b/apps/catalogue/constants.py @@ -36,9 +36,3 @@ LANGUAGES_3TO2 = { 'rus': 'ru', 'ukr': 'uk', } - -SOURCE_NAMES = { - u'pl.wikisource.org': _(u'Wikisource'), - u'de.wikisource.org': _(u'Wikisource'), - u'www.polona.pl': u'CBN Polona', -} diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index 5605ea8e99f980be8ba39b4f988ade75339aee89..9044964e3f2cd30baef8caf820089218c6ed4066 100644 GIT binary patch delta 3916 zcmYk;3s6->9LMn$MN~i$u~cq!1s`Bw5T+tXsg#BymL?^c-teX%-K#tm%PVH(12rVm zk`yf|(w8Vdu* zqdRRhlwE|2s0cNt4L|M14`p_DWBQ;6!>|Us;&M#HI_!+Eqi)%Qxws!QFuI2^={O11 zZW*edN3e@A0kfV;M^0?UzSxLY;2Ss)Kf|l=ckG8fqnr+sv4G=Y7>;$Qfo(<&cn2~U z^A28#@1xp%jdW$&a2U@w=c%aSke*J*sn(Gg!TB4Jk(xZ@pP9~249-I)X&%5{SZB{S zp(gUWy?zjN|8eY%r%@BTjNv@rBt$zMT#LFe4wcGc)J!Unwq`AApxaQX+-a}xM$Kp+ zYKBKpnfMkpfuB(+zlgeDqt*SLF%U^5l1d!Lq8g6EPB<2I!*~p40F}z=sG0asdu9dd zzU`=vTTn~&GAa`XP#J4OP3#h?eP|5%4-SB|n{~!*+?@^hFq%lb_eNoR#?oIv~jLGIiEZ$}t_>gU3YEd0+Kn0XFc>F zH)=O0p$3qSA((-BKo+WfE^4>WLfu!2nouRGU5!0niOTd^4A=X=)i!wE`X*{kKSFiz z397?`s7!r@+Px=G?M|cG{frvm8S4e>U#R;-STD5;M`bJuKMt^VE-LYyXk!7@aTnf2 zjW7xmu|KNgTvVo};3O=>G<*(|@f%dTu&bSZB2gLXjXEEXthPx+l5ECez)fW)6@6%y zqBhAURLWn%3VaKd!l7=b<1Ext<=Eo_WdE93sF_xw`cdZ^=qA(vPN6376RQ97Zt|~= z{^5jD65Zcf%Q#er>8R_usF}<}?cNg90~Vv!z8;miX4FJpL}hM2>b^6mx9l=97t@n; zYXE8S0VnmDoX`XBMvb)6x&#MuT#H(gXHf%v6E%P@0B7cIRJ#mo4)TpM`KZ^@ zi^^yv2A621J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D3&pvk&#dQb)GfW5w1F zk&nTQw)+RsWw&#%H`z(Xlg>nK9GRZWAN|)FMcP`D-FO4_+g)b&yJJ66MQZIaF~M%X zRzE*DEzoOeL48fHC+%DZ`XsvU_DSzFGkMaqgN{tpVWU3CBe diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.po b/apps/catalogue/locale/pl/LC_MESSAGES/django.po index ecd213e90..5b2a80b80 100644 --- a/apps/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/apps/catalogue/locale/pl/LC_MESSAGES/django.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: WolneLektury\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-06-30 10:37+0200\n" -"PO-Revision-Date: 2014-06-30 10:34+0100\n" +"POT-Creation-Date: 2014-07-01 09:28+0200\n" +"PO-Revision-Date: 2014-07-01 09:28+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: Fundacja Nowoczesna Polska \n" @@ -22,10 +22,6 @@ msgid "Creative Commons Attribution-ShareAlike 3.0 Unported" msgstr "" "Creative Commons Uznanie autorstwa – Na tych samych warunkach 3.0 Unported" -#: constants.py:41 constants.py:42 -msgid "Wikisource" -msgstr "Wikiźródła" - #: forms.py:27 msgid "Please supply an XML." msgstr "Proszę podać XML." @@ -107,77 +103,77 @@ msgstr "Stwórz własny PDF" msgid "Download" msgstr "Pobierz" -#: models/book.py:30 models/collection.py:11 +#: models/book.py:31 models/collection.py:11 msgid "title" msgstr "tytuł" -#: models/book.py:31 models/tag.py:34 +#: models/book.py:32 models/tag.py:34 msgid "sort key" msgstr "klucz sortowania" -#: models/book.py:32 +#: models/book.py:33 #, fuzzy msgid "sort key by author" msgstr "Znalezieni autorzy" -#: models/book.py:33 models/book.py:35 models/collection.py:12 +#: models/book.py:34 models/book.py:36 models/collection.py:12 #: models/collection.py:15 models/tag.py:33 msgid "slug" msgstr "slug" -#: models/book.py:36 +#: models/book.py:37 msgid "language code" msgstr "Kod języka" -#: models/book.py:38 models/book.py:170 models/collection.py:13 +#: models/book.py:39 models/book.py:171 models/collection.py:13 #: models/tag.py:37 models/tag.py:94 msgid "description" msgstr "opis" -#: models/book.py:39 models/book.py:40 models/bookmedia.py:31 models/tag.py:46 +#: models/book.py:40 models/book.py:41 models/bookmedia.py:31 models/tag.py:46 #: models/tag.py:47 msgid "creation date" msgstr "data utworzenia" -#: models/book.py:41 +#: models/book.py:42 msgid "parent number" msgstr "numer rodzica" -#: models/book.py:42 models/bookmedia.py:32 +#: models/book.py:43 models/bookmedia.py:32 msgid "extra information" msgstr "dodatkowe informacje" -#: models/book.py:47 +#: models/book.py:48 msgid "cover" msgstr "okładka" -#: models/book.py:52 +#: models/book.py:53 msgid "cover thumbnail" msgstr "podgląd okładki" -#: models/book.py:76 models/collection.py:18 models/tag.py:22 +#: models/book.py:77 models/collection.py:18 models/tag.py:22 msgid "book" msgstr "książka" -#: models/book.py:77 +#: models/book.py:78 msgid "books" msgstr "książki" -#: models/book.py:268 +#: models/book.py:269 #, python-format msgid "Book \"%s\" does not exist." msgstr "Utwór \"%s\" nie istnieje." -#: models/book.py:282 +#: models/book.py:283 #, python-format msgid "Book %s already exists" msgstr "Książka %s już istnieje" -#: models/book.py:618 +#: models/book.py:619 msgid "This work needs modernisation" msgstr "Ten utwór wymaga uwspółcześnienia" -#: models/book.py:637 models/bookmedia.py:23 +#: models/book.py:641 models/bookmedia.py:23 #, python-format msgid "%s file" msgstr "plik %s" @@ -186,7 +182,7 @@ msgstr "plik %s" msgid "type" msgstr "typ" -#: models/bookmedia.py:27 models/tag.py:32 +#: models/bookmedia.py:27 models/source.py:12 models/tag.py:32 msgid "name" msgstr "nazwa" @@ -222,6 +218,18 @@ msgstr "fragment" msgid "fragments" msgstr "fragmenty" +#: models/source.py:11 +msgid "network location" +msgstr "położenie sieciowe" + +#: models/source.py:16 +msgid "source" +msgstr "źródło" + +#: models/source.py:17 +msgid "sources" +msgstr "źródła" + #: models/tag.py:16 msgid "author" msgstr "autor" @@ -411,7 +419,7 @@ msgstr "Słuchaj" msgid "Table of contents" msgstr "Spis treści" -#: templates/catalogue/book_text.html:30 templatetags/catalogue_tags.py:421 +#: templates/catalogue/book_text.html:30 templatetags/catalogue_tags.py:426 msgid "Themes" msgstr "Motywy" @@ -517,28 +525,28 @@ msgstr "Pobierz katalog w formacie PDF." #: templates/catalogue/catalogue.html:19 #: templates/catalogue/search_multiple_hits.html:17 #: templates/catalogue/tagged_object_list.html:26 -#: templatetags/catalogue_tags.py:417 +#: templatetags/catalogue_tags.py:422 msgid "Authors" msgstr "Autorzy" #: templates/catalogue/catalogue.html:22 #: templates/catalogue/search_multiple_hits.html:25 #: templates/catalogue/tagged_object_list.html:34 -#: templatetags/catalogue_tags.py:419 +#: templatetags/catalogue_tags.py:424 msgid "Kinds" msgstr "Rodzaje" #: templates/catalogue/catalogue.html:25 #: templates/catalogue/search_multiple_hits.html:33 #: templates/catalogue/tagged_object_list.html:42 -#: templatetags/catalogue_tags.py:418 +#: templatetags/catalogue_tags.py:423 msgid "Genres" msgstr "Gatunki" #: templates/catalogue/catalogue.html:28 #: templates/catalogue/search_multiple_hits.html:41 #: templates/catalogue/tagged_object_list.html:50 -#: templatetags/catalogue_tags.py:420 +#: templatetags/catalogue_tags.py:425 msgid "Epochs" msgstr "Epoki" @@ -787,6 +795,9 @@ msgstr "Stwórz własny plik PDF" msgid "Free license" msgstr "Wolna licencja" +#~ msgid "Wikisource" +#~ msgstr "Wikiźródła" + #~ msgid "" #~ "Audioteka lektur szkolnych fundacji Nowoczesna Polska.\n" #~ "Możecie z niej korzystać bezpłatnie i bez ograniczeń.\n" diff --git a/apps/catalogue/migrations/0018_auto__add_source.py b/apps/catalogue/migrations/0018_auto__add_source.py new file mode 100644 index 000000000..1bad35956 --- /dev/null +++ b/apps/catalogue/migrations/0018_auto__add_source.py @@ -0,0 +1,192 @@ +# -*- 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 model 'Source' + db.create_table(u'catalogue_source', ( + ('netloc', self.gf('django.db.models.fields.CharField')(max_length=120, primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=120)), + )) + db.send_create_signal('catalogue', ['Source']) + + + def backwards(self, orm): + # Deleting model 'Source' + db.delete_table(u'catalogue_source') + + + 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'}), + '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/__init__.py b/apps/catalogue/models/__init__.py index 541ab5c8c..7651a9f87 100644 --- a/apps/catalogue/models/__init__.py +++ b/apps/catalogue/models/__init__.py @@ -7,4 +7,5 @@ from catalogue.models.bookmedia import BookMedia from catalogue.models.fragment import Fragment from catalogue.models.book import Book from catalogue.models.collection import Collection +from catalogue.models.source import Source from catalogue.models.listeners import * diff --git a/apps/catalogue/models/source.py b/apps/catalogue/models/source.py new file mode 100644 index 000000000..f530e07f4 --- /dev/null +++ b/apps/catalogue/models/source.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.db import models +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) + + class Meta: + ordering = ('netloc',) + verbose_name = _('source') + verbose_name_plural = _('sources') + app_label = 'catalogue' + + def __unicode__(self): + return self.netloc diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 5555711ef..2d19493eb 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -16,8 +16,8 @@ from django.contrib.auth.forms import UserCreationForm, AuthenticationForm from django.utils.translation import ugettext as _ from catalogue.utils import related_tag_name as _related_tag_name -from catalogue.models import Book, BookMedia, Fragment, Tag -from catalogue.constants import LICENSES, SOURCE_NAMES +from catalogue.models import Book, BookMedia, Fragment, Tag, Source +from catalogue.constants import LICENSES register = template.Library() @@ -485,4 +485,5 @@ def class_name(obj): @register.simple_tag def source_name(url): netloc = urlparse(url).netloc - return SOURCE_NAMES.get(netloc, netloc) + source, created = Source.objects.get_or_create(netloc=netloc) + return source.name or netloc -- 2.20.1