From: Radek Czajka Date: Tue, 1 Jul 2014 07:32:57 +0000 (+0200) Subject: Move source names to a model. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/d454277a61e2f34e34ee87777b0d35724edf877e Move source names to a model. --- 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 5605ea8e9..9044964e3 100644 Binary files a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo and b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo differ 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