From c92337fb4dd9d9732d472313ff8f0f0d08cef6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20H=C3=A1la?= Date: Wed, 24 Jan 2024 19:52:37 +0100 Subject: [PATCH] Further improvements --- backend/locale/cs/LC_MESSAGES/django.po | 26 +- category/forms.py | 11 +- category/locale/cs/LC_MESSAGES/django.po | 66 ++++-- category/models.py | 6 +- category/templates/category/add.html | 19 ++ category/templates/category/list.html | 10 +- category/urls.py | 2 + category/views.py | 50 +++- pdf/generate.py | 3 +- pdf/locale/cs/LC_MESSAGES/django.po | 224 ++++++++++-------- ...er_pdffile_options_alter_pdffile_locale.py | 27 +++ pdf/models/__init__.py | 4 + pdf/models/file.py | 1 + pdf/templates/pdf/requests/list.html | 24 +- pdf/templates/pdf/requests/wait.html | 32 ++- pdf/views.py | 11 +- tenants/menus.py | 4 - tenants/migrations/0004_alter_tenant_icon.py | 15 +- 18 files changed, 363 insertions(+), 172 deletions(-) create mode 100644 pdf/migrations/0028_alter_pdffile_options_alter_pdffile_locale.py diff --git a/backend/locale/cs/LC_MESSAGES/django.po b/backend/locale/cs/LC_MESSAGES/django.po index 3e786b4..da54e2d 100644 --- a/backend/locale/cs/LC_MESSAGES/django.po +++ b/backend/locale/cs/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-26 14:31+0000\n" +"POT-Creation-Date: 2024-02-11 18:00+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -104,53 +104,53 @@ msgstr "Jste si jisti že chcete smazat písničku" msgid "Confirm" msgstr "Potvrdit" -#: backend/templates/songs/index.html:25 +#: backend/templates/songs/index.html:27 msgid "Hide chords" msgstr "Skrýt akordy" -#: backend/templates/songs/index.html:31 +#: backend/templates/songs/index.html:33 msgid "Prevent sleep" msgstr "Zabránit uspání" -#: backend/templates/songs/index.html:37 +#: backend/templates/songs/index.html:39 msgid "Single page" msgstr "Bez stránek" -#: backend/templates/songs/index.html:62 +#: backend/templates/songs/index.html:64 msgid "Actions" msgstr "Akce" -#: backend/templates/songs/index.html:67 +#: backend/templates/songs/index.html:69 msgid "Edit" msgstr "Editor" -#: backend/templates/songs/index.html:70 +#: backend/templates/songs/index.html:72 msgid "Delete" msgstr "Smazat" -#: backend/templates/songs/index.html:84 +#: backend/templates/songs/index.html:86 msgid "Transpose" msgstr "Transponovat" -#: backend/templates/songs/index.html:103 +#: backend/templates/songs/index.html:105 msgid "Search" msgstr "Vyhledávání" -#: backend/templates/songs/index.html:105 +#: backend/templates/songs/index.html:107 msgid "Number, text or author" msgstr "Číslo, text nebo autor" -#: backend/views.py:92 +#: backend/views.py:101 #, python-format msgid "Song %(name)s was successfully created" msgstr "Písnička %(name)s byla úspěšně přidána" -#: backend/views.py:115 +#: backend/views.py:124 #, python-format msgid "Song %(name)s was successfully updated" msgstr "Písnička %(name)s byla úspěšně upravena" -#: backend/views.py:131 +#: backend/views.py:140 #, python-format msgid "Song %s was successfully deleted" msgstr "Písnička %s byla úspěšně odstraněna" diff --git a/category/forms.py b/category/forms.py index 88fc1a4..3fa2624 100644 --- a/category/forms.py +++ b/category/forms.py @@ -4,6 +4,7 @@ from django.utils.translation import gettext_lazy as _ from category.models import Category +from pdf.models import PDFRequest from tenants.models import Tenant @@ -14,7 +15,15 @@ class CategoryForm(ModelForm): class Meta: model = Category - fields = "__all__" + fields = ["name", "slug", "generate_pdf", "tenant"] + + +class CategoryRequestForm(ModelForm): + """Form used for modifying category PDF generation options""" + + class Meta: + model = PDFRequest + fields = ["public", "locale", "title", "show_date", "image", "margin", "link"] class NameForm(Form): diff --git a/category/locale/cs/LC_MESSAGES/django.po b/category/locale/cs/LC_MESSAGES/django.po index 751ca52..032c697 100644 --- a/category/locale/cs/LC_MESSAGES/django.po +++ b/category/locale/cs/LC_MESSAGES/django.po @@ -3,12 +3,11 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-26 14:31+0000\n" +"POT-Creation-Date: 2024-02-11 19:44+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -19,7 +18,7 @@ msgstr "" "Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n " "<= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n" -#: category/admin.py:21 category/forms.py:43 +#: category/admin.py:21 category/forms.py:39 msgid "Tenant" msgstr "Do Zpěvníku" @@ -27,28 +26,28 @@ msgstr "Do Zpěvníku" msgid "Move Category to a different Tenant" msgstr "Přesunout Kategorie do jiného Zpěvníku" -#: category/models.py:14 category/templates/category/list.html:11 +#: category/models.py:16 category/templates/category/list.html:11 msgid "Name" msgstr "Jméno" -#: category/models.py:15 category/templates/category/list.html:12 +#: category/models.py:17 category/templates/category/list.html:12 msgid "URL pattern" msgstr "URL vzor" -#: category/models.py:17 category/templates/category/list.html:13 +#: category/models.py:24 category/templates/category/list.html:13 msgid "PDF generation" -msgstr "Automatické Generování PDF" +msgstr "Automatické generování PDF souboru" -#: category/models.py:18 +#: category/models.py:25 msgid "Should the PDF file be automatically generated when a song changes?" msgstr "" "Má být vygenerován pdf soubor když se nějaká písnička z kategorie změní?" -#: category/models.py:25 +#: category/models.py:32 msgid "Category" msgstr "Kategorie" -#: category/models.py:26 category/templates/admin/category/migrate.html:6 +#: category/models.py:33 category/templates/admin/category/migrate.html:6 #: category/templates/category/list.html:4 #: category/templates/category/list.html:5 msgid "Categories" @@ -63,11 +62,19 @@ msgstr "Přesun kategorii do jiného Zpěvníku" msgid "To Tenant" msgstr "Do Tenanta" -#: category/templates/category/add.html:4 #: category/templates/category/add.html:5 +#: category/templates/category/add.html:6 msgid "Category Editor" msgstr "Editor Kategorie" +#: category/templates/category/add.html:13 +msgid "PDF Options" +msgstr "Nastavení PDF" + +#: category/templates/category/add.html:15 +msgid "Submit" +msgstr "Odeslat" + #: category/templates/category/confirm_delete.html:5 #: category/templates/category/confirm_delete.html:6 msgid "Please confirm removal" @@ -93,7 +100,7 @@ msgstr "Jazyk" #: category/templates/category/list.html:15 msgid "Actions" -msgstr "" +msgstr "Akce" #: category/templates/category/list.html:27 msgid "Edit" @@ -101,45 +108,58 @@ msgstr "Upravit" #: category/templates/category/list.html:29 msgid "Toggle Dropdown" -msgstr "" +msgstr "Rozbalovací menu" #: category/templates/category/list.html:34 +#: category/templates/category/list.html:36 msgid "Already in queue" msgstr "Již ve frontě" -#: category/templates/category/list.html:36 -msgid "Regenerate" -msgstr "Přegenerovat" +#: category/templates/category/list.html:38 +#| msgid "Regenerate" +msgid "Generate PDF" +msgstr "Vygenerovat PDF" -#: category/templates/category/list.html:39 +#: category/templates/category/list.html:41 msgid "Delete" msgstr "Smazat" -#: category/templates/category/list.html:48 +#: category/templates/category/list.html:50 msgid "Add Category" msgstr "Přidat Kategorii" -#: category/views.py:36 +#: category/views.py:42 #, python-format msgid "Category with url /%(slug)s does not exist" msgstr "Kategorie s url /%(slug)s neexistuje" -#: category/views.py:65 +#: category/views.py:75 #, python-format msgid "Category %(name)s was successfully created" msgstr "Kategorie %(name)s byla úspěšně vytvořena" -#: category/views.py:82 +#: category/views.py:105 #, python-format msgid "Category %(name)s was successfully updated" msgstr "Kategorie %(name)s byla úspěšně upravena" -#: category/views.py:103 +#: category/views.py:138 #, python-format msgid "Category %s was successfully staged for PDF generation" msgstr "PDF pro Kategorii %s bylo přidáno do fronty" -#: category/views.py:114 +#: category/views.py:149 #, python-format msgid "Category %(name)s was successfully deleted" msgstr "Kategorie %(name)s byla úspěšně smazána" + +#: category/views.py:240 +#, python-format +msgid "Category %(name)s PDF generation is already pending " +msgstr "PDF pro Kategorie %(name)s je už naplánované" + +#: category/views.py:246 +#, python-format +#| msgid "Category %s was successfully staged for PDF generation" +msgid "Category %(name)s was scheduled for generation" +msgstr "PDF pro %(name)s bylo přidána do fronty" diff --git a/category/models.py b/category/models.py index 6754d3e..3d10540 100644 --- a/category/models.py +++ b/category/models.py @@ -5,8 +5,7 @@ from django.dispatch import receiver from django.utils.translation import gettext_lazy as _ -from pdf.models import PDFRequest -from pdf.models.request import RequestType +from pdf.models import PDFRequest, RequestType from tenants.models import Tenant @@ -35,8 +34,9 @@ class Meta: unique_together = [["tenant", "slug"], ["tenant", "name"]] +# pylint: disable=unused-argument @receiver(post_save, sender=Category) -def create_pdf_request(_, instance, created, **kwargs): +def create_pdf_request(signal, instance, created, **kwargs): """Generates a new PDFRequest for new category if not present""" if created: if not hasattr(instance, "request"): diff --git a/category/templates/category/add.html b/category/templates/category/add.html index 3e24aff..2548bdd 100644 --- a/category/templates/category/add.html +++ b/category/templates/category/add.html @@ -1,5 +1,24 @@ {% extends "base/form.html" %} {% load i18n %} +{% load django_bootstrap5 %} {% block title %} {% trans "Category Editor" %} {% endblock %} {% block header %} {% trans "Category Editor" %} {% endblock %} + +{% block framed_body %} +
+ {% csrf_token %} + {% bootstrap_form form layout='horizontal' %} +
+

{% trans "PDF Options" %}

+ {% bootstrap_form request_form layout='horizontal' %} + {% bootstrap_button _("Submit") button_type="submit" %} +
+ {{ form.media }} + +{% endblock %} \ No newline at end of file diff --git a/category/templates/category/list.html b/category/templates/category/list.html index 72ff30e..041e543 100644 --- a/category/templates/category/list.html +++ b/category/templates/category/list.html @@ -21,7 +21,7 @@ {{ category.name }} {% url "category:index" slug=category.slug %} {% if category.generate_pdf %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %} - {{ category.locale }} + {{ category.request.locale }}
{% trans "Edit" %} @@ -30,10 +30,12 @@