From a9b4700e3cd649a6dddc3b72dc0bd632f7841c74 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 27 Jan 2023 16:55:56 +0100 Subject: [PATCH] Publishing tags. --- src/catalogue/admin.py | 18 +- src/catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 4137 -> 4450 bytes src/catalogue/locale/pl/LC_MESSAGES/django.po | 179 ++++++++++-------- ...entury_of_birth_author_century_of_death.py | 23 +++ src/catalogue/models.py | 37 ++++ .../admin/catalogue/epoch/change_form.html | 14 ++ .../admin/catalogue/genre/change_form.html | 14 ++ .../admin/catalogue/kind/change_form.html | 14 ++ .../catalogue/author_description.html | 8 +- src/catalogue/urls.py | 3 + src/catalogue/views.py | 43 ++++- 11 files changed, 269 insertions(+), 84 deletions(-) create mode 100644 src/catalogue/migrations/0045_author_century_of_birth_author_century_of_death.py create mode 100644 src/catalogue/templates/admin/catalogue/epoch/change_form.html create mode 100644 src/catalogue/templates/admin/catalogue/genre/change_form.html create mode 100644 src/catalogue/templates/admin/catalogue/kind/change_form.html diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 7acfa401..54350a67 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -62,8 +62,22 @@ class AuthorAdmin(WikidataAdminMixin, TabbedTranslationAdmin): "genitive", "gender", "nationality", - ("date_of_birth", "year_of_birth", "year_of_birth_inexact", "year_of_birth_range", "place_of_birth"), - ("date_of_death", "year_of_death", "year_of_death_inexact", "year_of_death_range", "place_of_death"), + ( + "date_of_birth", + "year_of_birth", + "year_of_birth_inexact", + "year_of_birth_range", + "century_of_birth", + "place_of_birth" + ), + ( + "date_of_death", + "year_of_death", + "year_of_death_inexact", + "year_of_death_range", + "century_of_death", + "place_of_death" + ), ("description", "description_preview"), "status", "collections", diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.mo b/src/catalogue/locale/pl/LC_MESSAGES/django.mo index 4502885fc608a6c17601f2c779a752b66b8159c5..84cf1244f8ceac6b80b225f20b33050d901814dd 100644 GIT binary patch delta 2124 zcmYL~U2IfE7=~xDbW2N1Eg-0^913kM&~29rZE5RIs}^WM3N}O~B&Y2uJ^eXbm$O}q zA$x&|iU~2r;0E^*aSOlMgtKe~KkHZq| zX=~5I3hb9*Cp-()|0=x4n2fnjMGk+0a(ENg!QY`KEXG?YTn%Y58=(4cvUWWrn;3=0 zw?U2Tvh6*v61(5>7?i(hxSsjVOH|g`$QjUxsA!jpcVx6W@UHdkfwV@4$>!5@ETDKnbMHR6}*FhdR3*mYq=j_d_jY5Ng5C zL+x-F%1;8S-x;Wh&qDco+qS=N+viJ(zb3p$1KE5@A$!r<*PxEzXSfmGv9`R*u7K-d z1N=NAX@@$?KB%3&0JVc*%L%A6 zPeM(Uf$H~)eg1~Evrrp&4{|zY9+J&P3g*q2uc>gXCTDpa%JEI83IBw8t^S6Zpp2LK zK3E0yywNfa^%itMvgx<&$Dod66lx&>RKGM_r}zJLDsub*B%6<|{e|Tfn7@?PzGis? zYN5Yc{sk4me_;(QVirBGh5E8KLtWMZ$X(5+X1)K|<_Ky)>(DN=2MwZjqzhI^3Uy1t zu#Ceks1fxe0+o-b7OkXDyV7A)pRX-PPSwoQ6we?AZ&8sG$E$YIw>YVSFN3c(r70Bs!DyXWh_Scz0Dzq_VZCCEm2N z&57^cv#WJ`OMKyKY1fLbp_8GTc23|v@I7b3I~h8s0ymg*l8MQfbJR_SiQM@S-$_k) z(}CxVPPtAx=FG%`m>0`N$_J~{zBlQll8Mn%Uf{bXZ|2TV`(ARy&kmMfDj!WOFKp5s XneZ2)6>X7{ndDsB4FfORy=Lh@ve((E delta 1812 zcmX|?TS(MF6o=26>8iPEW>+hp&mf2O2dNPWPB1(F(C=gqO9=bpw%SJ>G zT^=d|DYhaADXIr6kRE~_f0?Kg>oCoWnBGLxspbJicXQ9T$p!(l{8h^*_UWhAuD0kadZ2)l^Y$l-2hE0m-CP@z5Q?C|zZs10>PIXnxu!pm+C zP9gr9@H-Wn;3rgw|3D2)V3ZuBKt&`Qs(&t2{{n9>a+W)5osCfATHsXJ>OAK4-4O~i zXgCjb1UDg{Js{IUot%9!Z}bAEQ1PtxwqHCY1qwB6CQ->-|lvo^9;3mpm`lT3 zZy1L9B^-sigxPrE4o;-SUMhp7Ue?4*kbdDdA{~KJ9nw?OhE}2)q^M3Lz5gntohd1# zoBo%GfK%tB9V=Cj!L~z1jWyaTuPcDMOS&Ix(Q2eriMAnaY9Z2Q3z1Spw{iF z$rd4{6^LW9VpM`QBc(9fiFBR~s1fm7ZnbCu8c%r?mZB!4=c`{&MO4S*sm11aX+F$H z>rpe>fOOI7ks5j03mX)h6T9O=(CIuU!$AWL;TT-$D@wU|5KxVk4 ow5lXrkyln$UB0TgG#tN}R+A7-4mC%QhaSf(Gb#enlbPTC0UXbV2mk;8 diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.po b/src/catalogue/locale/pl/LC_MESSAGES/django.po index 86f4d12d..45e6c06e 100644 --- a/src/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/src/catalogue/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2022-09-26 11:45+0200\n" +"PO-Revision-Date: 2023-01-27 16:53+0100\n" "Last-Translator: \n" "Language-Team: \n" "Language: pl\n" @@ -19,306 +19,327 @@ msgstr "" "n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n" "X-Generator: Poedit 3.0.1\n" -#: catalogue/admin.py:53 catalogue/admin.py:203 +#: catalogue/admin.py:57 catalogue/admin.py:310 msgid "Identification" msgstr "Identyfikacja" -#: catalogue/admin.py:218 +#: catalogue/admin.py:325 msgid "Features" msgstr "Cechy" -#: catalogue/admin.py:228 +#: catalogue/admin.py:335 msgid "Plan" msgstr "Plan" -#: catalogue/admin.py:270 +#: catalogue/admin.py:379 msgid "Title" msgstr "tytuł" -#: catalogue/admin.py:276 +#: catalogue/admin.py:385 msgid "Book" msgstr "książka" -#: catalogue/admin.py:286 catalogue/models.py:160 +#: catalogue/admin.py:395 catalogue/models.py:247 msgid "scans source" msgstr "źródło skanów" -#: catalogue/models.py:15 +#: catalogue/models.py:21 msgid "first name" msgstr "imię" -#: catalogue/models.py:16 +#: catalogue/models.py:22 msgid "last name" msgstr "nazwisko" -#: catalogue/models.py:18 +#: catalogue/models.py:28 msgid "name (de)" msgstr "nazwa (de)" -#: catalogue/models.py:19 +#: catalogue/models.py:29 msgid "name (lt)" msgstr "nazwa (lt)" -#: catalogue/models.py:21 +#: catalogue/models.py:31 msgid "gender" msgstr "płeć" -#: catalogue/models.py:22 +#: catalogue/models.py:32 msgid "nationality" msgstr "narodowość" -#: catalogue/models.py:23 +#: catalogue/models.py:34 msgid "year of birth" msgstr "rok urodzenia" -#: catalogue/models.py:24 catalogue/models.py:33 +#: catalogue/models.py:35 catalogue/models.py:48 msgid "inexact" msgstr "niedokładny" -#: catalogue/models.py:25 +#: catalogue/models.py:36 msgid "year of birth, range end" msgstr "rok urodzenia, koniec zakresu" -#: catalogue/models.py:26 +#: catalogue/models.py:37 msgid "date_of_birth" msgstr "data urodzenia" -#: catalogue/models.py:29 +#: catalogue/models.py:39 +msgid "century of birth" +msgstr "wiek urodzenia" + +#: catalogue/models.py:40 catalogue/models.py:53 +msgid "Set if year unknown. Negative for BC." +msgstr "Ustaw gry nie jest znany rok. Wartości ujemne dla w. p.n.e." + +#: catalogue/models.py:44 msgid "place of birth" msgstr "miejsce urodzenia" -#: catalogue/models.py:32 +#: catalogue/models.py:47 msgid "year of death" msgstr "rok śmierci" -#: catalogue/models.py:34 +#: catalogue/models.py:49 msgid "year of death, range end" msgstr "rok śmierci, koniec zakresu" -#: catalogue/models.py:35 +#: catalogue/models.py:50 msgid "date_of_death" msgstr "data śmierci" -#: catalogue/models.py:38 +#: catalogue/models.py:52 +msgid "century of death" +msgstr "wiek śmierci" + +#: catalogue/models.py:57 msgid "place of death" msgstr "miejsce śmierci" -#: catalogue/models.py:42 +#: catalogue/models.py:61 msgid "status" msgstr "status" -#: catalogue/models.py:46 +#: catalogue/models.py:65 msgid "Alive" msgstr "Żyje" -#: catalogue/models.py:47 +#: catalogue/models.py:66 msgid "Dead" msgstr "Zmarły" -#: catalogue/models.py:48 +#: catalogue/models.py:67 msgid "Long dead" msgstr "Dawno zmarły" -#: catalogue/models.py:49 +#: catalogue/models.py:68 msgid "Unknown" msgstr "Nieznany" -#: catalogue/models.py:52 catalogue/models.py:162 catalogue/models.py:232 -#: catalogue/models.py:250 +#: catalogue/models.py:71 catalogue/models.py:249 catalogue/models.py:394 +#: catalogue/models.py:412 msgid "notes" msgstr "notatki" -#: catalogue/models.py:53 catalogue/models.py:169 +#: catalogue/models.py:71 catalogue/models.py:249 catalogue/models.py:394 +#: catalogue/models.py:412 +msgid "private" +msgstr "prywatne" + +#: catalogue/models.py:73 catalogue/models.py:256 msgid "gazeta link" msgstr "link do bazy gazety" -#: catalogue/models.py:54 +#: catalogue/models.py:74 msgid "culture.pl link" msgstr "link do bazy culture.pl" -#: catalogue/models.py:56 +#: catalogue/models.py:80 catalogue/models.py:178 catalogue/models.py:413 msgid "description" msgstr "opis" -#: catalogue/models.py:59 catalogue/models.py:164 catalogue/models.py:300 +#: catalogue/models.py:80 catalogue/models.py:178 +msgid "for publication" +msgstr "do publikacji" + +#: catalogue/models.py:83 catalogue/models.py:251 catalogue/models.py:463 msgid "priority" msgstr "priorytet" -#: catalogue/models.py:60 catalogue/models.py:165 +#: catalogue/models.py:84 catalogue/models.py:252 msgid "Low" msgstr "Niski" -#: catalogue/models.py:60 catalogue/models.py:165 +#: catalogue/models.py:84 catalogue/models.py:252 msgid "Medium" msgstr "Średni" -#: catalogue/models.py:60 catalogue/models.py:165 +#: catalogue/models.py:84 catalogue/models.py:252 msgid "High" msgstr "Wysoki" -#: catalogue/models.py:62 catalogue/models.py:170 catalogue/models.py:255 -#: catalogue/models.py:307 +#: catalogue/models.py:86 catalogue/models.py:257 catalogue/models.py:418 +#: catalogue/models.py:470 msgid "collections" msgstr "kolekcje" -#: catalogue/models.py:65 +#: catalogue/models.py:89 msgid "author" msgstr "autor" -#: catalogue/models.py:66 catalogue/models.py:143 +#: catalogue/models.py:90 catalogue/models.py:230 msgid "authors" msgstr "autorzy" -#: catalogue/models.py:114 catalogue/models.py:230 catalogue/models.py:247 -#: catalogue/models.py:280 catalogue/models.py:333 +#: catalogue/models.py:176 catalogue/models.py:392 catalogue/models.py:409 +#: catalogue/models.py:443 catalogue/models.py:496 msgid "name" msgstr "nazwa" -#: catalogue/models.py:125 +#: catalogue/models.py:198 msgid "epoch" msgstr "epoka" -#: catalogue/models.py:126 catalogue/models.py:151 catalogue/models.py:304 +#: catalogue/models.py:199 catalogue/models.py:238 catalogue/models.py:467 msgid "epochs" msgstr "epoki" -#: catalogue/models.py:131 +#: catalogue/models.py:213 msgid "genre" msgstr "gatunek" -#: catalogue/models.py:132 catalogue/models.py:153 catalogue/models.py:306 +#: catalogue/models.py:214 catalogue/models.py:240 catalogue/models.py:469 msgid "genres" msgstr "gatunki" -#: catalogue/models.py:137 +#: catalogue/models.py:224 msgid "kind" msgstr "rodzaj" -#: catalogue/models.py:138 catalogue/models.py:152 catalogue/models.py:305 +#: catalogue/models.py:225 catalogue/models.py:239 catalogue/models.py:468 msgid "kinds" msgstr "rodzaje" -#: catalogue/models.py:149 +#: catalogue/models.py:236 msgid "translators" msgstr "tłumacze" -#: catalogue/models.py:154 +#: catalogue/models.py:241 msgid "title" msgstr "tytuł" -#: catalogue/models.py:155 +#: catalogue/models.py:242 msgid "language" msgstr "język" -#: catalogue/models.py:158 +#: catalogue/models.py:245 msgid "based on" msgstr "oparte na" -#: catalogue/models.py:161 +#: catalogue/models.py:248 msgid "text source" msgstr "źródło tekstu" -#: catalogue/models.py:167 +#: catalogue/models.py:254 msgid "original publication year" msgstr "rok oryginalnej publikacji" -#: catalogue/models.py:168 +#: catalogue/models.py:255 msgid "year of entry into PD" msgstr "rok wstąpienia do DP" -#: catalogue/models.py:172 +#: catalogue/models.py:259 msgid "estimated number of characters" msgstr "szacowana liczba znaków" -#: catalogue/models.py:173 +#: catalogue/models.py:260 msgid "estimated number of verses" msgstr "szacowana liczba wersów" -#: catalogue/models.py:174 +#: catalogue/models.py:261 msgid "source of estimates" msgstr "źródło szacunków" -#: catalogue/models.py:176 +#: catalogue/models.py:263 msgid "free license" msgstr "wolna licencja" -#: catalogue/models.py:177 +#: catalogue/models.py:264 msgid "missing on Polona" msgstr "brak na Polonie" -#: catalogue/models.py:181 +#: catalogue/models.py:271 msgid "book" msgstr "książka" -#: catalogue/models.py:182 +#: catalogue/models.py:272 msgid "books" msgstr "książki" -#: catalogue/models.py:215 +#: catalogue/models.py:307 msgid "Author" msgstr "autor" -#: catalogue/models.py:220 +#: catalogue/models.py:314 msgid "Translator" msgstr "tłumacze" -#: catalogue/models.py:231 +#: catalogue/models.py:393 msgid "parent" msgstr "rodzic" -#: catalogue/models.py:236 +#: catalogue/models.py:398 msgid "collection category" msgstr "kategoria kolekcji" -#: catalogue/models.py:237 +#: catalogue/models.py:399 msgid "collection categories" msgstr "kategorie kolekcji" -#: catalogue/models.py:249 +#: catalogue/models.py:411 msgid "category" msgstr "kategoria" -#: catalogue/models.py:254 +#: catalogue/models.py:417 msgid "collection" msgstr "kolekcja" -#: catalogue/models.py:284 catalogue/models.py:303 +#: catalogue/models.py:447 catalogue/models.py:466 msgid "work type" msgstr "rodzaj pracy" -#: catalogue/models.py:285 +#: catalogue/models.py:448 msgid "work types" msgstr "rodzaje prac" -#: catalogue/models.py:301 +#: catalogue/models.py:464 msgid "per normalized page" msgstr "za stronę maszynopisu" -#: catalogue/models.py:302 +#: catalogue/models.py:465 msgid "per verse" msgstr "za wers" -#: catalogue/models.py:311 +#: catalogue/models.py:474 msgid "work rate" msgstr "stawka" -#: catalogue/models.py:312 +#: catalogue/models.py:475 msgid "work rates" msgstr "stawki" -#: catalogue/models.py:334 +#: catalogue/models.py:497 msgid "locative" msgstr "miejscownik" -#: catalogue/models.py:334 +#: catalogue/models.py:497 msgid "in…" msgstr "w…" -#: catalogue/models.py:337 +#: catalogue/models.py:500 msgid "place" msgstr "miejsce" -#: catalogue/models.py:338 +#: catalogue/models.py:501 msgid "places" msgstr "miejsca" diff --git a/src/catalogue/migrations/0045_author_century_of_birth_author_century_of_death.py b/src/catalogue/migrations/0045_author_century_of_birth_author_century_of_death.py new file mode 100644 index 00000000..c0bb413c --- /dev/null +++ b/src/catalogue/migrations/0045_author_century_of_birth_author_century_of_death.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.6 on 2023-01-27 16:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0044_epoch_description_genre_description_kind_description'), + ] + + operations = [ + migrations.AddField( + model_name='author', + name='century_of_birth', + field=models.SmallIntegerField(blank=True, help_text='Set if year unknown. Negative for BC.', null=True, verbose_name='century of birth'), + ), + migrations.AddField( + model_name='author', + name='century_of_death', + field=models.SmallIntegerField(blank=True, help_text='Set if year unknown. Negative for BC.', null=True, verbose_name='century of death'), + ), + ] diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 6f4fa1e9..8321b54e 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -30,10 +30,15 @@ class Author(WikidataModel): gender = models.CharField(_("gender"), max_length=255, blank=True) nationality = models.CharField(_("nationality"), max_length=255, blank=True) + year_of_birth = models.SmallIntegerField(_("year of birth"), null=True, blank=True) year_of_birth_inexact = models.BooleanField(_("inexact"), default=False) year_of_birth_range = models.SmallIntegerField(_("year of birth, range end"), null=True, blank=True) date_of_birth = models.DateField(_("date_of_birth"), null=True, blank=True) + century_of_birth = models.SmallIntegerField( + _("century of birth"), null=True, blank=True, + help_text=_('Set if year unknown. Negative for BC.') + ) place_of_birth = models.ForeignKey( 'Place', models.PROTECT, null=True, blank=True, verbose_name=_('place of birth'), @@ -43,6 +48,10 @@ class Author(WikidataModel): year_of_death_inexact = models.BooleanField(_("inexact"), default=False) year_of_death_range = models.SmallIntegerField(_("year of death, range end"), null=True, blank=True) date_of_death = models.DateField(_("date_of_death"), null=True, blank=True) + century_of_death = models.SmallIntegerField( + _("century of death"), null=True, blank=True, + help_text=_('Set if year unknown. Negative for BC.') + ) place_of_death = models.ForeignKey( 'Place', models.PROTECT, null=True, blank=True, verbose_name=_('place of death'), @@ -130,6 +139,34 @@ class Author(WikidataModel): ) return t + def century_description(self, number): + n = abs(number) + letters = '' + while n > 10: + letters += 'X' + n -= 10 + if n == 9: + letters += 'IX' + n = 0 + elif n >= 5: + letters += 'V' + n -= 5 + if n == 4: + letters += 'IV' + n = 0 + letters += 'I' * n + letters += ' w.' + if number < 0: + letters += ' p.n.e.' + return letters + + def birth_century_description(self): + return self.century_description(self.century_of_birth) + + def death_century_description(self): + return self.century_description(self.century_of_death) + + class NotableBook(OrderableModel): author = models.ForeignKey(Author, models.CASCADE) book = models.ForeignKey('Book', models.CASCADE) diff --git a/src/catalogue/templates/admin/catalogue/epoch/change_form.html b/src/catalogue/templates/admin/catalogue/epoch/change_form.html new file mode 100644 index 00000000..8e8d1ec7 --- /dev/null +++ b/src/catalogue/templates/admin/catalogue/epoch/change_form.html @@ -0,0 +1,14 @@ +{% extends "admin/change_form.html" %} + +{% block object-tools-items %} + {% if change and original.slug %} +
  • +
    + + {% csrf_token %} + +
    +
  • + {% endif %} + {{ block.super }} +{% endblock %} diff --git a/src/catalogue/templates/admin/catalogue/genre/change_form.html b/src/catalogue/templates/admin/catalogue/genre/change_form.html new file mode 100644 index 00000000..416b5a66 --- /dev/null +++ b/src/catalogue/templates/admin/catalogue/genre/change_form.html @@ -0,0 +1,14 @@ +{% extends "admin/change_form.html" %} + +{% block object-tools-items %} + {% if change and original.slug %} +
  • +
    + + {% csrf_token %} + +
    +
  • + {% endif %} + {{ block.super }} +{% endblock %} diff --git a/src/catalogue/templates/admin/catalogue/kind/change_form.html b/src/catalogue/templates/admin/catalogue/kind/change_form.html new file mode 100644 index 00000000..ea9692c5 --- /dev/null +++ b/src/catalogue/templates/admin/catalogue/kind/change_form.html @@ -0,0 +1,14 @@ +{% extends "admin/change_form.html" %} + +{% block object-tools-items %} + {% if change and original.slug %} +
  • +
    + + {% csrf_token %} + +
    +
  • + {% endif %} + {{ block.super }} +{% endblock %} diff --git a/src/catalogue/templates/catalogue/author_description.html b/src/catalogue/templates/catalogue/author_description.html index 26c35323..54e0caea 100644 --- a/src/catalogue/templates/catalogue/author_description.html +++ b/src/catalogue/templates/catalogue/author_description.html @@ -1,11 +1,13 @@
    - {% if obj.date_of_birth or obj.place_of_birth %} + {% if obj.date_of_birth or obj.year_of_birth or obj.century_of_birth or obj.place_of_birth %}
    Ur.
    {% if obj.date_of_birth %} {{ obj.date_of_birth }} {% elif obj.year_of_birth %} {{ obj.year_of_birth }} + {% elif obj.century_of_birth %} + {{ obj.birth_century_description }} {% endif %} {% if obj.place_of_birth %} w @@ -17,13 +19,15 @@ {% endif %}
    {% endif %} - {% if obj.date_of_death or obj.place_of_death %} + {% if obj.date_of_death or obj.year_of_death or obj.century_of_death or obj.place_of_death %}
    Zm.
    {% if obj.date_of_death %} {{ obj.date_of_death }} {% elif obj.year_of_death %} {{ obj.year_of_death }} + {% elif obj.century_of_death %} + {{ obj.death_century_description }} {% endif %} {% if obj.place_of_death %} w diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py index 065c4f92..d3e31dcf 100644 --- a/src/catalogue/urls.py +++ b/src/catalogue/urls.py @@ -23,5 +23,8 @@ urlpatterns = [ path('wikidata//', views.WikidataView.as_view()), path('publish/author//', views.publish_author, name='catalogue_publish_author'), + path('publish/genre//', views.publish_genre, name='catalogue_publish_genre'), + path('publish/kind//', views.publish_kind, name='catalogue_publish_kind'), + path('publish/epoch//', views.publish_epoch, name='catalogue_publish_epoch'), path('publish/collection//', views.publish_collection, name='catalogue_publish_collection'), ] diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 3e55d693..5be41462 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -22,12 +22,15 @@ from rest_framework.views import APIView from rest_framework import serializers + + + class CatalogueView(TemplateView): template_name = "catalogue/catalogue.html" def get_context_data(self): ctx = super().get_context_data() - ctx["authors"] = models.Author.objects.all().prefetch_related('book_set__book_set', 'translated_book_set__book_set') + ctx["authors"] = models.Author.objects.all().prefetch_related('book_set__document_books', 'translated_book_set__document_books') return ctx @@ -213,6 +216,44 @@ def publish_author(request, pk): return redirect(reverse('admin:catalogue_author_change', args=[author.pk])) +@require_POST +@login_required +def publish_genre(request, pk): + obj = get_object_or_404(models.Genre, pk=pk) + data = { + "description_pl": obj.description, + "plural": obj.plural, + "is_epoch_specific": obj.is_epoch_specific, + } + apiclient.api_call(request.user, f"genres/{obj.slug}/", data) + return redirect(reverse('admin:catalogue_genre_change', args=[obj.pk])) + + +@require_POST +@login_required +def publish_kind(request, pk): + obj = get_object_or_404(models.Kind, pk=pk) + data = { + "description_pl": obj.description, + "collective_noun": obj.collective_noun, + } + apiclient.api_call(request.user, f"kinds/{obj.slug}/", data) + return redirect(reverse('admin:catalogue_kind_change', args=[obj.pk])) + + +@require_POST +@login_required +def publish_epoch(request, pk): + obj = get_object_or_404(models.Epoch, pk=pk) + data = { + "description_pl": obj.description, + "adjective_feminine_singular": obj.adjective_feminine_singular, + "adjective_nonmasculine_plural": obj.adjective_feminine_singular, + } + apiclient.api_call(request.user, f"epochs/{obj.slug}/", data) + return redirect(reverse('admin:catalogue_epoch_change', args=[obj.pk])) + + @require_POST @login_required def publish_collection(request, pk): -- 2.20.1