From: Radek Czajka Date: Mon, 20 Apr 2020 15:05:10 +0000 (+0200) Subject: Link catalogue to documents. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/acf3c41fb0ffe8e451b1e465b00e9998f2b027ac?ds=sidebyside;hp=c4426f18fdb50c224e8a5211a1766dcf261eaff8 Link catalogue to documents. --- diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 91656f13..00617cb6 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -1,3 +1,6 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from django.contrib import admin from . import models from .wikidata import WikidataAdminMixin diff --git a/src/catalogue/constants.py b/src/catalogue/constants.py index f8180f76..88d0e338 100644 --- a/src/catalogue/constants.py +++ b/src/catalogue/constants.py @@ -1,3 +1,6 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# class WIKIDATA: AUTHOR = "P50" LANGUAGE = "P407" diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.mo b/src/catalogue/locale/pl/LC_MESSAGES/django.mo new file mode 100644 index 00000000..eb7cf859 Binary files /dev/null and b/src/catalogue/locale/pl/LC_MESSAGES/django.mo differ diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.po b/src/catalogue/locale/pl/LC_MESSAGES/django.po new file mode 100644 index 00000000..3b3d06bb --- /dev/null +++ b/src/catalogue/locale/pl/LC_MESSAGES/django.po @@ -0,0 +1,71 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-04-20 16:44+0200\n" +"PO-Revision-Date: 2020-04-20 16:52+0200\n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n" +"%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n" +"%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n" +"Last-Translator: \n" +"Language-Team: \n" +"X-Generator: Poedit 2.2.4\n" + +#: models.py:22 +msgid "Alive" +msgstr "Żyje" + +#: models.py:23 +msgid "Dead" +msgstr "Zmarły" + +#: models.py:24 +msgid "Long dead" +msgstr "Dawno zmarły" + +#: models.py:25 +msgid "Unknown" +msgstr "Nieznany" + +#: models.py:37 models.py:83 +msgid "Low" +msgstr "Niski" + +#: models.py:37 models.py:83 +msgid "Medium" +msgstr "Średni" + +#: models.py:37 models.py:83 +msgid "High" +msgstr "Wysoki" + +#: templates/catalogue/catalogue.html:7 templates/catalogue/catalogue.html:13 +msgid "Catalogue" +msgstr "Katalog" + +#: templates/catalogue/catalogue.html:67 +msgid "trans." +msgstr "tłum." + +#: templates/catalogue/catalogue.html:90 +#, python-format +msgid "%(c)s author" +msgid_plural "%(c)s authors" +msgstr[0] "%(c)s autor" +msgstr[1] "%(c)s autorów" +msgstr[2] "%(c)s autorów" +msgstr[3] "" + +#: wikidata.py:18 +msgid "If you have a Wikidata ID, like \"Q1337\", enter it and save." +msgstr "" +"Jeśli masz identyfikator Wikidanych , jak „Q1337”, wklej go i zapisz." diff --git a/src/catalogue/management/commands/import_catalogue_from_wl_dump.py b/src/catalogue/management/commands/import_catalogue_from_wl_dump.py index 29d32753..e137f5a6 100644 --- a/src/catalogue/management/commands/import_catalogue_from_wl_dump.py +++ b/src/catalogue/management/commands/import_catalogue_from_wl_dump.py @@ -1,3 +1,6 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# import json from urllib.request import urlopen import sys diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 6a27cd9d..0863c1e3 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -1,6 +1,9 @@ +from django.apps import apps from django.db import models +from django.urls import reverse from django.utils.translation import gettext_lazy as _ from .constants import WIKIDATA +from .utils import UnrelatedManager from .wikidata import WikidataMixin @@ -48,6 +51,17 @@ class Author(WikidataMixin, models.Model): def __str__(self): return f"{self.first_name} {self.last_name}" + def get_absolute_url(self): + return reverse("catalogue_author", args=[self.slug]) + + @property + def pd_year(self): + if self.year_of_death: + return self.year_of_death + 71 + elif self.year_of_death == 0: + return 0 + else: + return None class Book(WikidataMixin, models.Model): slug = models.SlugField(max_length=255, blank=True, null=True, unique=True) @@ -73,6 +87,8 @@ class Book(WikidataMixin, models.Model): gazeta_link = models.CharField(max_length=255, blank=True) collections = models.ManyToManyField("Collection", blank=True) + objects = UnrelatedManager() + class Meta: ordering = ("title",) @@ -94,12 +110,19 @@ class Book(WikidataMixin, models.Model): txt = f"{txt} (tłum. {tstr})" return txt + def get_absolute_url(self): + return reverse("catalogue_book", args=[self.slug]) + def authors_str(self): return ", ".join(str(author) for author in self.authors.all()) def translators_str(self): return ", ".join(str(author) for author in self.translators.all()) + def get_document_books(self): + DBook = apps.get_model("documents", "Book") + return DBook.objects.filter(dc_slug=self.slug) + class Collection(models.Model): name = models.CharField(max_length=255) diff --git a/src/catalogue/templates/catalogue/author_detail.html b/src/catalogue/templates/catalogue/author_detail.html new file mode 100644 index 00000000..177f3be9 --- /dev/null +++ b/src/catalogue/templates/catalogue/author_detail.html @@ -0,0 +1,89 @@ +{% extends "documents/base.html" %} + +{% load i18n %} +{% load pagination_tags %} + + +{% block titleextra %}{% trans "Catalogue" %}{% endblock %} + + +{% block content %} +
+
+

{% trans "Catalogue" %}

+
+
+ + + + + + + + + {% for book in author.book_set.all %} + + + + + + + + {% endfor %} + {% for book in author.translated_book_set.all %} + + + + + + + + {% endfor %} +
+ + {{ author }} + + + {{ author.pd_year|default_if_none:"-" }} + + {{ author.wikidata_link }} + + {{ author.get_priority_display }} +
+   + + {{ book.title }} + + + {{ book.pd_year|default_if_none:"-" }} + + {{ book.wikidata_link }} + + {{ book.get_priorty_display }} + + {% for b in book.document_books %} + + {{ b }} + + {% endfor %} +
+   + + {{ book.title }} + ({% trans "trans." %}) + + {{ book.pd_year|default_if_none:"-" }} + + {{ book.wikidata_link }} + + {{ book.get_priorty_display }} + + {% for b in book.document_books %} + + {{ b }} + + {% endfor %} +
+
+
+{% endblock content %} diff --git a/src/catalogue/templates/catalogue/book_detail.html b/src/catalogue/templates/catalogue/book_detail.html new file mode 100644 index 00000000..2c59c359 --- /dev/null +++ b/src/catalogue/templates/catalogue/book_detail.html @@ -0,0 +1,80 @@ +{% extends "documents/base.html" %} + +{% load i18n %} +{% load pagination_tags %} + + +{% block titleextra %}{% trans "Catalogue" %}{% endblock %} + + +{% block content %} +
+
+

{% trans "Catalogue" %}

+
+
+ + {% for author in book.authors.all %} + + + + + + + {% endfor %} + {% for author in book.translator_set.all %} + + + + + + + {% endfor %} + + + + + + + +
+ + {{ author }} + + + {{ author.pd_year|default_if_none:"-" }} + + {{ author.wikidata_link }} + + {{ author.get_priority_display }} +
+ + {{ author }} + + + {{ author.pd_year|default_if_none:"-" }} + + {{ author.wikidata_link }} + + {{ author.get_priority_display }} +
+   + + {{ book.title }} + + + {{ book.pd_year|default_if_none:"-" }} + + {{ book.wikidata_link }} + + {{ book.get_priorty_display }} + + {% for b in book.get_document_books %} + + {{ b }} + + {% endfor %} +
+
+
+{% endblock content %} diff --git a/src/catalogue/templates/catalogue/catalogue.html b/src/catalogue/templates/catalogue/catalogue.html new file mode 100644 index 00000000..715ba8f1 --- /dev/null +++ b/src/catalogue/templates/catalogue/catalogue.html @@ -0,0 +1,93 @@ +{% extends "documents/base.html" %} + +{% load i18n %} +{% load pagination_tags %} + + +{% block titleextra %}{% trans "Catalogue" %}{% endblock %} + + +{% block content %} +
+
+

{% trans "Catalogue" %}

+
+
+ + {% autopaginate authors 20 as authors_page %} + {% for author in authors_page %} + + + + + + + {% for book in author.book_set.all %} + + + + + + + + {% endfor %} + {% for book in author.translated_book_set.all %} + + + + + + + + {% endfor %} + {% endfor %} +
+ + {{ author }} + + + {{ author.pd_year|default_if_none:"-" }} + + {{ author.wikidata_link }} + + {{ author.get_priority_display }} +
+   + + {{ book.title }} + + + {{ book.pd_year|default_if_none:"-" }} + + {{ book.wikidata_link }} + + {{ book.get_priorty_display }} + + {% for b in book.document_books %} + + {{ b }} + + {% endfor %} +
+   + + {{ book.title }} + ({% trans "trans." %}) + + {{ book.pd_year|default_if_none:"-" }} + + {{ book.wikidata_link }} + + {{ book.get_priorty_display }} + + {% for b in book.document_books %} + + {{ b }} + + {% endfor %} +
+ {% paginate %} + {% blocktrans count c=authors|length %}{{c}} author{% plural %}{{c}} authors{% endblocktrans %} +
+
+{% endblock content %} diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py new file mode 100644 index 00000000..10ef6d00 --- /dev/null +++ b/src/catalogue/urls.py @@ -0,0 +1,12 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.urls import path +from . import views + + +urlpatterns = [ + path("", views.CatalogueView.as_view(), name="catalogue"), + path("author//", views.AuthorView.as_view(), name="catalogue_author"), + path("book//", views.BookView.as_view(), name="catalogue_book"), +] diff --git a/src/catalogue/utils.py b/src/catalogue/utils.py new file mode 100644 index 00000000..00f71878 --- /dev/null +++ b/src/catalogue/utils.py @@ -0,0 +1,49 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from collections import defaultdict +from django.db.models import QuerySet +from django.db.models.manager import BaseManager + + +class UnrelatedQuerySet(QuerySet): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self._prefetch_unrelated_lookups = {} + self._prefetch_unrelated_done = False + + def _clone(self): + c = super()._clone() + c._prefetch_unrelated_lookups = self._prefetch_unrelated_lookups.copy() + return c + + def prefetch_unrelated(self, attribute, field, other_model, other_field): + clone = self._clone() + clone._prefetch_unrelated_lookups[field] = (attribute, other_model, other_field) + return clone + + def _fetch_all(self): + prefetch_done = self._prefetch_done + super()._fetch_all() + if self._prefetch_unrelated_lookups and not prefetch_done: + self._prefetch_unrelated_objects() + + def _prefetch_unrelated_objects(self): + for ( + field, + (attribute, other_model, other_field), + ) in self._prefetch_unrelated_lookups.items(): + values = set([getattr(obj, field) for obj in self._result_cache]) + other_objects = other_model._default_manager.filter( + **{f"{other_field}__in": values} + ) + results = defaultdict(list) + for other_obj in other_objects: + results[getattr(other_obj, other_field)].append(other_obj) + for obj in self._result_cache: + setattr(obj, attribute, results.get(getattr(obj, field))) + self._prefetch_unrelated_done = True + + +class UnrelatedManager(BaseManager.from_queryset(UnrelatedQuerySet)): + pass diff --git a/src/catalogue/views.py b/src/catalogue/views.py new file mode 100644 index 00000000..0b29b6f4 --- /dev/null +++ b/src/catalogue/views.py @@ -0,0 +1,43 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.db.models import Prefetch +from django.views.generic import DetailView, TemplateView +from . import models +import documents.models + + +class CatalogueView(TemplateView): + template_name = "catalogue/catalogue.html" + + def get_context_data(self): + ctx = super().get_context_data() + documents_books_queryset = models.Book.objects.prefetch_unrelated( + "document_books", "slug", documents.models.Book, "dc_slug" + ) + ctx["authors"] = models.Author.objects.all().prefetch_related( + Prefetch("book_set", queryset=documents_books_queryset), + Prefetch("translated_book_set", queryset=documents_books_queryset), + ) + return ctx + + +class AuthorView(TemplateView): + model = models.Author + template_name = "catalogue/author_detail.html" + + def get_context_data(self, slug): + ctx = super().get_context_data() + documents_books_queryset = models.Book.objects.prefetch_unrelated( + "document_books", "slug", documents.models.Book, "dc_slug" + ) + authors = models.Author.objects.filter(slug=slug).prefetch_related( + Prefetch("book_set", queryset=documents_books_queryset), + Prefetch("translated_book_set", queryset=documents_books_queryset), + ) + ctx["author"] = authors.first() + return ctx + + +class BookView(DetailView): + model = models.Book diff --git a/src/catalogue/wikidata.py b/src/catalogue/wikidata.py index 88686b6e..d97d3af7 100644 --- a/src/catalogue/wikidata.py +++ b/src/catalogue/wikidata.py @@ -1,3 +1,6 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from datetime import date from django.db import models from django.db.models.signals import m2m_changed diff --git a/src/documents/locale/pl/LC_MESSAGES/django.mo b/src/documents/locale/pl/LC_MESSAGES/django.mo index 395b34ef..dde8ac15 100644 Binary files a/src/documents/locale/pl/LC_MESSAGES/django.mo and b/src/documents/locale/pl/LC_MESSAGES/django.mo differ diff --git a/src/documents/locale/pl/LC_MESSAGES/django.po b/src/documents/locale/pl/LC_MESSAGES/django.po index ac60fb22..3a6596df 100644 --- a/src/documents/locale/pl/LC_MESSAGES/django.po +++ b/src/documents/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Platforma Redakcyjna\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-10-07 13:05+0200\n" -"PO-Revision-Date: 2019-10-07 13:06+0200\n" +"POT-Creation-Date: 2020-04-20 16:53+0200\n" +"PO-Revision-Date: 2020-04-20 16:54+0200\n" "Last-Translator: Radek Czajka \n" "Language-Team: Fundacja Nowoczesna Polska \n" @@ -18,89 +18,97 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2);\n" -"X-Generator: Poedit 2.0.6\n" +"X-Generator: Poedit 2.2.4\n" -#: forms.py:38 +#: forms.py:41 msgid "Text file must be UTF-8 encoded." msgstr "Plik powinien mieć kodowanie UTF-8." -#: forms.py:41 +#: forms.py:57 +msgid "Title not set" +msgstr "Brak tytułu" + +#: forms.py:60 +msgid "Slug not set" +msgstr "Brak slugu" + +#: forms.py:63 msgid "You must either enter text or upload a file" msgstr "Proszę wpisać tekst albo wybrać plik do załadowania" -#: forms.py:50 +#: forms.py:72 msgid "ZIP file" msgstr "Plik ZIP" -#: forms.py:51 +#: forms.py:73 msgid "Directories are documents in chunks" msgstr "Katalogi zawierają dokumenty w częściach" -#: forms.py:75 forms.py:176 +#: forms.py:97 forms.py:198 msgid "Assigned to" msgstr "Przypisane do" -#: forms.py:96 forms.py:110 +#: forms.py:118 forms.py:132 msgid "Chunk with this slug already exists" msgstr "Część z tym slugiem już istnieje" -#: forms.py:119 +#: forms.py:141 msgid "Append to" msgstr "Dołącz do" -#: models/book.py:26 models/chunk.py:21 models/image.py:20 +#: models/book.py:27 models/chunk.py:21 models/image.py:20 msgid "title" msgstr "tytuł" -#: models/book.py:27 models/chunk.py:22 models/image.py:21 +#: models/book.py:28 models/chunk.py:22 models/image.py:21 msgid "slug" msgstr "slug" -#: models/book.py:28 models/image.py:22 +#: models/book.py:29 models/image.py:22 msgid "public" msgstr "publiczna" -#: models/book.py:29 +#: models/book.py:30 msgid "scan gallery name" msgstr "nazwa galerii skanów" -#: models/book.py:33 +#: models/book.py:34 msgid "parent" msgstr "rodzic" -#: models/book.py:34 +#: models/book.py:35 msgid "parent number" msgstr "numeracja rodzica" -#: models/book.py:52 models/chunk.py:19 models/publish_log.py:15 +#: models/book.py:53 models/chunk.py:19 models/publish_log.py:15 msgid "book" msgstr "książka" -#: models/book.py:53 views.py:619 +#: models/book.py:54 views.py:619 msgid "books" msgstr "książki" -#: models/book.py:257 +#: models/book.py:263 msgid "No chunks in the book." msgstr "Książka nie ma części." -#: models/book.py:261 +#: models/book.py:267 msgid "Not all chunks have publishable revisions." msgstr "Niektóre części nie są gotowe do publikacji." -#: models/book.py:268 models/image.py:83 +#: models/book.py:274 models/image.py:83 msgid "Invalid XML" msgstr "Nieprawidłowy XML" -#: models/book.py:270 models/image.py:85 +#: models/book.py:276 models/image.py:85 msgid "No Dublin Core found." msgstr "Brak sekcji Dublin Core." -#: models/book.py:272 models/image.py:87 +#: models/book.py:278 models/image.py:87 msgid "Invalid Dublin Core" msgstr "Nieprawidłowy Dublin Core" -#: models/book.py:275 models/image.py:91 +#: models/book.py:281 models/image.py:91 msgid "rdf:about is not" msgstr "rdf:about jest różny od" @@ -140,8 +148,8 @@ msgstr "nazwa" msgid "notes" msgstr "notatki" -#: models/project.py:17 templates/catalogue/book_list/book_list.html:66 -#: templates/catalogue/image_table.html:60 +#: models/project.py:17 templates/documents/book_list/book_list.html:66 +#: templates/documents/image_table.html:60 msgid "project" msgstr "projekt" @@ -154,7 +162,7 @@ msgid "time" msgstr "czas" #: models/publish_log.py:17 models/publish_log.py:45 -#: templates/catalogue/wall.html:20 +#: templates/documents/wall.html:20 msgid "user" msgstr "użytkownik" @@ -186,185 +194,178 @@ msgstr "zapis publikacji obrazu" msgid "image publish records" msgstr "zapisy publikacji obrazów" -#: templates/catalogue/active_users_list.html:5 +#: templates/documents/active_users_list.html:5 msgid "Active users" msgstr "Aktywni użytkownicy" -#: templates/catalogue/active_users_list.html:11 +#: templates/documents/active_users_list.html:11 msgid "Users active in the year" msgstr "Użytkownicy aktywni w roku" -#: templates/catalogue/activity.html:6 templates/catalogue/activity.html:15 -#: templatetags/catalogue.py:30 +#: templates/documents/activity.html:6 templates/documents/activity.html:15 +#: templatetags/documents.py:30 msgid "Activity" msgstr "Aktywność" -#: templates/catalogue/base.html:13 +#: templates/documents/base.html:13 msgid "Platforma Redakcyjna" msgstr "Platforma Redakcyjna" -#: templates/catalogue/book_append_to.html:5 -#: templates/catalogue/book_append_to.html:14 +#: templates/documents/book_append_to.html:5 +#: templates/documents/book_append_to.html:14 msgid "Append book" msgstr "Dołącz książkę" -#: templates/catalogue/book_detail.html:23 -#: templates/catalogue/book_edit.html:13 templates/catalogue/chunk_edit.html:22 -#: templates/catalogue/image_detail.html:22 +#: templates/documents/book_detail.html:24 +#: templates/documents/book_edit.html:13 templates/documents/chunk_edit.html:22 +#: templates/documents/image_detail.html:22 msgid "Save" msgstr "Zapisz" -#: templates/catalogue/book_detail.html:30 +#: templates/documents/book_detail.html:31 msgid "Edit gallery" msgstr "Edytuj galerię" -#: templates/catalogue/book_detail.html:33 +#: templates/documents/book_detail.html:34 msgid "Append to other book" msgstr "Dołącz do innej książki" -#: templates/catalogue/book_detail.html:40 +#: templates/documents/book_detail.html:49 msgid "Chunks" msgstr "Części" -#: templates/catalogue/book_detail.html:58 -#: templates/catalogue/image_detail.html:47 templatetags/wall.py:108 +#: templates/documents/book_detail.html:67 +#: templates/documents/image_detail.html:47 templatetags/wall.py:108 #: templatetags/wall.py:129 msgid "Publication" msgstr "Publikacja" -#: templates/catalogue/book_detail.html:69 -#: templates/catalogue/image_detail.html:51 +#: templates/documents/book_detail.html:85 +#: templates/documents/image_detail.html:51 msgid "Last published" msgstr "Ostatnio opublikowano" -#: templates/catalogue/book_detail.html:79 +#: templates/documents/book_detail.html:95 msgid "Full XML" msgstr "Pełny XML" -#: templates/catalogue/book_detail.html:80 +#: templates/documents/book_detail.html:96 msgid "HTML version" msgstr "Wersja HTML" -#: templates/catalogue/book_detail.html:81 +#: templates/documents/book_detail.html:97 msgid "TXT version" msgstr "Wersja TXT" -#: templates/catalogue/book_detail.html:82 +#: templates/documents/book_detail.html:98 msgid "PDF version" msgstr "Wersja PDF" -#: templates/catalogue/book_detail.html:83 +#: templates/documents/book_detail.html:99 msgid "PDF version for mobiles" msgstr "Wersja PDF na telefony" -#: templates/catalogue/book_detail.html:84 +#: templates/documents/book_detail.html:100 msgid "EPUB version" msgstr "Wersja EPUB" -#: templates/catalogue/book_detail.html:85 +#: templates/documents/book_detail.html:101 msgid "MOBI version" msgstr "Wersja MOBI" -#: templates/catalogue/book_detail.html:99 -#: templates/catalogue/image_detail.html:70 +#: templates/documents/book_detail.html:115 +#: templates/documents/image_detail.html:70 msgid "Publish" msgstr "Opublikuj" -#: templates/catalogue/book_detail.html:103 -#: templates/catalogue/image_detail.html:74 +#: templates/documents/book_detail.html:119 +#: templates/documents/image_detail.html:74 msgid "Log in to publish." msgstr "Zaloguj się, aby opublikować." -#: templates/catalogue/book_detail.html:106 -#: templates/catalogue/image_detail.html:77 +#: templates/documents/book_detail.html:122 +#: templates/documents/image_detail.html:77 msgid "This book can't be published yet, because:" msgstr "Ta książka nie może jeszcze zostać opublikowana. Powód:" -#: templates/catalogue/book_edit.html:5 +#: templates/documents/book_edit.html:5 msgid "Edit book" msgstr "Edytuj książkę" -#: templates/catalogue/book_html.html:12 templates/catalogue/book_text.html:15 +#: templates/documents/book_html.html:12 templates/documents/book_text.html:15 msgid "Table of contents" msgstr "Spis treści" -#: templates/catalogue/book_html.html:13 templates/catalogue/book_text.html:17 +#: templates/documents/book_html.html:13 templates/documents/book_text.html:17 msgid "Edit. note" msgstr "Nota red." -#: templates/catalogue/book_html.html:14 +#: templates/documents/book_html.html:14 msgid "Infobox" msgstr "Informacje" -#: templates/catalogue/book_list/book.html:8 -#: templates/catalogue/book_list/book.html:36 +#: templates/documents/book_list/book.html:8 +#: templates/documents/book_list/book.html:35 msgid "Book settings" msgstr "Ustawienia książki" -#: templates/catalogue/book_list/book.html:9 -#: templates/catalogue/book_list/chunk.html:7 -#: templates/catalogue/chunk_edit.html:6 templates/catalogue/chunk_edit.html:12 +#: templates/documents/book_list/book.html:9 +#: templates/documents/book_list/chunk.html:7 +#: templates/documents/chunk_edit.html:6 templates/documents/chunk_edit.html:12 msgid "Chunk settings" msgstr "Ustawienia części" -#: templates/catalogue/book_list/book.html:12 -#: templates/catalogue/book_list/chunk.html:9 -#: templates/catalogue/image_short.html:9 -msgid "Edit:" -msgstr "Edytuj:" - -#: templates/catalogue/book_list/book.html:21 -#: templates/catalogue/book_list/book.html:43 -#: templates/catalogue/image_short.html:18 templatetags/book_list.py:82 +#: templates/documents/book_list/book.html:20 +#: templates/documents/book_list/book.html:42 +#: templates/documents/image_short.html:17 templatetags/book_list.py:82 #: templatetags/book_list.py:150 msgid "published" msgstr "opublikowane" -#: templates/catalogue/book_list/book.html:24 -#: templates/catalogue/book_list/book.html:46 -#: templates/catalogue/book_list/chunk.html:28 -#: templates/catalogue/image_short.html:21 templatetags/book_list.py:80 +#: templates/documents/book_list/book.html:23 +#: templates/documents/book_list/book.html:45 +#: templates/documents/image_short.html:20 templatetags/book_list.py:80 #: templatetags/book_list.py:148 msgid "publishable" msgstr "do publikacji" -#: templates/catalogue/book_list/book.html:27 -#: templates/catalogue/book_list/chunk.html:33 -#: templates/catalogue/image_short.html:24 templatetags/book_list.py:81 +#: templates/documents/book_list/book.html:26 +#: templates/documents/book_list/chunk.html:26 +#: templates/documents/image_short.html:23 templatetags/book_list.py:81 #: templatetags/book_list.py:149 msgid "changed" msgstr "zmienione" -#: templates/catalogue/book_list/book_list.html:29 -#: templates/catalogue/image_table.html:25 +#: templates/documents/book_list/book_list.html:29 +#: templates/documents/image_table.html:25 msgid "Search in book titles" msgstr "Szukaj w tytułach książek" -#: templates/catalogue/book_list/book_list.html:34 -#: templates/catalogue/image_table.html:30 +#: templates/documents/book_list/book_list.html:34 +#: templates/documents/image_table.html:30 msgid "stage" msgstr "etap" -#: templates/catalogue/book_list/book_list.html:36 -#: templates/catalogue/book_list/book_list.html:47 -#: templates/catalogue/book_list/book_list.html:68 -#: templates/catalogue/image_table.html:32 -#: templates/catalogue/image_table.html:43 -#: templates/catalogue/image_table.html:62 +#: templates/documents/book_list/book_list.html:36 +#: templates/documents/book_list/book_list.html:47 +#: templates/documents/book_list/book_list.html:68 +#: templates/documents/image_table.html:32 +#: templates/documents/image_table.html:43 +#: templates/documents/image_table.html:62 msgid "none" msgstr "brak" -#: templates/catalogue/book_list/book_list.html:45 -#: templates/catalogue/image_table.html:41 +#: templates/documents/book_list/book_list.html:45 +#: templates/documents/image_table.html:41 msgid "editor" msgstr "redaktor" -#: templates/catalogue/book_list/book_list.html:58 -#: templates/catalogue/image_table.html:52 +#: templates/documents/book_list/book_list.html:58 +#: templates/documents/image_table.html:52 msgid "status" msgstr "status" -#: templates/catalogue/book_list/book_list.html:92 +#: templates/documents/book_list/book_list.html:92 #, python-format msgid "%(c)s book" msgid_plural "%(c)s books" @@ -372,73 +373,73 @@ msgstr[0] "%(c)s książka" msgstr[1] "%(c)s książki" msgstr[2] "%(c)s książek" -#: templates/catalogue/book_list/book_list.html:96 +#: templates/documents/book_list/book_list.html:96 msgid "No books found." msgstr "Nie znaleziono książek." -#: templates/catalogue/book_list/book_list.html:105 -#: templates/catalogue/image_table.html:87 +#: templates/documents/book_list/book_list.html:105 +#: templates/documents/image_table.html:87 msgid "Set stage" msgstr "Ustaw etap" -#: templates/catalogue/book_list/book_list.html:106 -#: templates/catalogue/image_table.html:88 +#: templates/documents/book_list/book_list.html:106 +#: templates/documents/image_table.html:88 msgid "Set user" msgstr "Przypisz redaktora" -#: templates/catalogue/book_list/book_list.html:108 -#: templates/catalogue/image_table.html:90 +#: templates/documents/book_list/book_list.html:108 +#: templates/documents/image_table.html:90 msgid "Project" msgstr "Projekt" -#: templates/catalogue/book_list/book_list.html:109 -#: templates/catalogue/image_table.html:91 +#: templates/documents/book_list/book_list.html:109 +#: templates/documents/image_table.html:91 msgid "More users" msgstr "Więcej użytkowników" -#: templates/catalogue/book_text.html:7 +#: templates/documents/book_text.html:7 msgid "Redakcja" msgstr "" -#: templates/catalogue/chunk_add.html:6 templates/catalogue/chunk_add.html:12 -#: templates/catalogue/chunk_edit.html:29 +#: templates/documents/chunk_add.html:6 templates/documents/chunk_add.html:12 +#: templates/documents/chunk_edit.html:29 msgid "Split chunk" msgstr "Podziel część" -#: templates/catalogue/chunk_add.html:19 +#: templates/documents/chunk_add.html:19 msgid "Insert empty chunk after" msgstr "Wstaw pustą część po" -#: templates/catalogue/chunk_add.html:23 +#: templates/documents/chunk_add.html:23 msgid "Add chunk" msgstr "Dodaj część" -#: templates/catalogue/chunk_edit.html:19 +#: templates/documents/chunk_edit.html:19 msgid "Book" msgstr "Książka" -#: templates/catalogue/document_create_missing.html:6 -#: templates/catalogue/document_create_missing.html:12 +#: templates/documents/document_create_missing.html:6 +#: templates/documents/document_create_missing.html:12 msgid "Create a new book" msgstr "Utwórz nową książkę" -#: templates/catalogue/document_create_missing.html:21 +#: templates/documents/document_create_missing.html:21 msgid "Create book" msgstr "Utwórz książkę" -#: templates/catalogue/document_list.html:7 +#: templates/documents/document_list.html:7 msgid "Book list" msgstr "Lista książek" -#: templates/catalogue/document_upload.html:6 +#: templates/documents/document_upload.html:6 msgid "Bulk document upload" msgstr "Hurtowe dodawanie dokumentów" -#: templates/catalogue/document_upload.html:14 +#: templates/documents/document_upload.html:14 msgid "Bulk documents upload" msgstr "Hurtowe dodawanie dokumentów" -#: templates/catalogue/document_upload.html:19 +#: templates/documents/document_upload.html:19 msgid "" "Please submit a ZIP with UTF-8 encoded XML files. Files not ending with " ".xml will be ignored." @@ -446,69 +447,57 @@ msgstr "" "Proszę wskazać archiwum ZIP z plikami XML w kodowaniu UTF-8. Pliki nie " "kończące się na .xml zostaną zignorowane." -#: templates/catalogue/document_upload.html:26 -#: templates/catalogue/upload_pdf.html:16 templatetags/catalogue.py:37 +#: templates/documents/document_upload.html:26 +#: templates/documents/upload_pdf.html:16 templatetags/documents.py:37 msgid "Upload" msgstr "Załaduj" -#: templates/catalogue/document_upload.html:34 +#: templates/documents/document_upload.html:34 msgid "" "There have been some errors. No files have been added to the repository." msgstr "Wystąpiły błędy. Żadne pliki nie zostały dodane do repozytorium." -#: templates/catalogue/document_upload.html:35 +#: templates/documents/document_upload.html:35 msgid "Offending files" msgstr "Błędne pliki" -#: templates/catalogue/document_upload.html:43 +#: templates/documents/document_upload.html:43 msgid "Correct files" msgstr "Poprawne pliki" -#: templates/catalogue/document_upload.html:54 +#: templates/documents/document_upload.html:54 msgid "Files have been successfully uploaded to the repository." msgstr "Pliki zostały dodane do repozytorium." -#: templates/catalogue/document_upload.html:55 +#: templates/documents/document_upload.html:55 msgid "Uploaded files" msgstr "Dodane pliki" -#: templates/catalogue/document_upload.html:65 +#: templates/documents/document_upload.html:65 msgid "Skipped files" msgstr "Pominięte pliki" -#: templates/catalogue/document_upload.html:66 +#: templates/documents/document_upload.html:66 msgid "Files skipped due to no .xml extension" msgstr "Pliki pominięte z powodu braku rozszerzenia .xml." -#: templates/catalogue/head_login.html:10 -msgid "Admin" -msgstr "Administracja" - -#: templates/catalogue/head_login.html:15 -msgid "Log Out" -msgstr "Wyloguj" - -#: templates/catalogue/head_login.html:21 -msgid "Log In" -msgstr "Zaloguj" - -#: templates/catalogue/image_detail.html:34 +#: templates/documents/image_detail.html:34 msgid "Editor" msgstr "Edytor" -#: templates/catalogue/image_detail.html:38 +#: templates/documents/image_detail.html:38 msgid "Proceed to the editor." msgstr "Przejdź do edytora." -#: templates/catalogue/image_list.html:8 +#: templates/documents/image_list.html:8 msgid "Image list" msgstr "Lista obrazów" -#: templates/catalogue/image_short.html:6 +#: templates/documents/image_short.html:6 msgid "Image settings" msgstr "Ustawienia obrazu" -#: templates/catalogue/image_table.html:79 +#: templates/documents/image_table.html:79 #, python-format msgid "%(c)s image" msgid_plural "%(c)s images" @@ -516,36 +505,36 @@ msgstr[0] "%(c)s obraz" msgstr[1] "%(c)s obrazy" msgstr[2] "%(c)s obrazów" -#: templates/catalogue/image_table.html:81 +#: templates/documents/image_table.html:81 msgid "No images found." msgstr "Nie znaleziono obrazów." -#: templates/catalogue/my_page.html:15 templatetags/catalogue.py:28 +#: templates/documents/my_page.html:17 templatetags/documents.py:28 msgid "My page" msgstr "Moja strona" -#: templates/catalogue/my_page.html:25 +#: templates/documents/my_page.html:27 msgid "Your last edited documents" msgstr "Twoje ostatnie edycje" -#: templates/catalogue/my_page.html:45 templates/catalogue/user_page.html:18 +#: templates/documents/my_page.html:47 templates/documents/user_page.html:18 msgid "Recent activity for" msgstr "Ostatnia aktywność dla:" -#: templates/catalogue/upload_pdf.html:5 templates/catalogue/upload_pdf.html:11 +#: templates/documents/upload_pdf.html:5 templates/documents/upload_pdf.html:11 msgid "PDF file upload" msgstr "Ładowanie pliku PDF" -#: templates/catalogue/user_list.html:7 templates/catalogue/user_list.html:14 -#: templatetags/catalogue.py:33 +#: templates/documents/user_list.html:7 templates/documents/user_list.html:14 +#: templatetags/documents.py:33 msgid "Users" msgstr "Użytkownicy" -#: templates/catalogue/wall.html:30 +#: templates/documents/wall.html:30 msgid "not logged in" msgstr "nie zalogowany" -#: templates/catalogue/wall.html:35 +#: templates/documents/wall.html:35 msgid "No activity recorded." msgstr "Nie zanotowano aktywności." @@ -557,19 +546,19 @@ msgstr "nie opublikowane" msgid "empty" msgstr "puste" -#: templatetags/catalogue.py:31 +#: templatetags/documents.py:31 msgid "All" msgstr "Wszystkie" -#: templatetags/catalogue.py:32 +#: templatetags/documents.py:32 msgid "Images" msgstr "Obrazy" -#: templatetags/catalogue.py:36 +#: templatetags/documents.py:36 msgid "Add" msgstr "Dodaj" -#: templatetags/catalogue.py:39 +#: templatetags/documents.py:39 msgid "Covers" msgstr "Okładki" @@ -598,6 +587,18 @@ msgstr "Plik powinien mieć kodowanie UTF-8." msgid "scan gallery" msgstr "galeria skanów" +#~ msgid "Edit:" +#~ msgstr "Edytuj:" + +#~ msgid "Admin" +#~ msgstr "Administracja" + +#~ msgid "Log Out" +#~ msgstr "Wyloguj" + +#~ msgid "Log In" +#~ msgstr "Zaloguj" + #~ msgid "Active users since" #~ msgstr "Użytkownicy aktywni od" diff --git a/src/documents/models/book.py b/src/documents/models/book.py index e7c34814..24d0cea0 100644 --- a/src/documents/models/book.py +++ b/src/documents/models/book.py @@ -1,6 +1,7 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # +from django.apps import apps from django.contrib.sites.models import Site from django.db import models, transaction from django.template.loader import render_to_string @@ -89,6 +90,11 @@ class Book(models.Model): def gallery_url(self): return '%s%s%s/' % (settings.MEDIA_URL, settings.IMAGE_DIR, self.gallery) + @property + def catalogue_book(self): + CBook = apps.get_model('catalogue', 'Book') + return CBook.objects.filter(slug=self.dc_slug).first() + # Creating & manipulating # ======================= diff --git a/src/documents/templates/documents/book_detail.html b/src/documents/templates/documents/book_detail.html index 3dbaf213..d9b06c7f 100644 --- a/src/documents/templates/documents/book_detail.html +++ b/src/documents/templates/documents/book_detail.html @@ -13,7 +13,8 @@

{{ book.title }}

- +
+
{% if editable %}
{% csrf_token %}{% endif %} @@ -32,8 +33,16 @@

{% trans "Append to other book" %}

{% endif %} + + +
+
+ W katalogu: + {{ book.catalogue_book }} +
+
- +
@@ -73,7 +82,7 @@ Okładka w rozmiarze
-

{% trans "Last published" %}: +

{% trans "Last published" %}: {% if book.last_published %} {{ book.last_published }} {% else %} diff --git a/src/redakcja/urls.py b/src/redakcja/urls.py index af8b4f26..fe2193e7 100644 --- a/src/redakcja/urls.py +++ b/src/redakcja/urls.py @@ -1,7 +1,8 @@ # This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -from django.conf.urls import include, url +from django.conf.urls import url +from django.urls import include, path from django.contrib import admin from django.conf import settings from django.conf.urls.static import static @@ -18,7 +19,7 @@ urlpatterns = [ # Admin panel url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', admin.site.urls), - + path('catalogue/', include('catalogue.urls')), url(r'^$', RedirectView.as_view(url='/documents/', permanent=False)), url(r'^documents/', include('documents.urls')), url(r'^apiclient/', include('apiclient.urls')),