Skip to content

Commit

Permalink
Further improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Feb 11, 2024
1 parent 67dc4ec commit c92337f
Show file tree
Hide file tree
Showing 18 changed files with 363 additions and 172 deletions.
26 changes: 13 additions & 13 deletions backend/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -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"
11 changes: 10 additions & 1 deletion category/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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):
Expand Down
66 changes: 43 additions & 23 deletions category/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -19,36 +18,36 @@ 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"

#: category/admin.py:27
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"
Expand All @@ -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"
Expand All @@ -93,53 +100,66 @@ msgstr "Jazyk"

#: category/templates/category/list.html:15
msgid "Actions"
msgstr ""
msgstr "Akce"

#: category/templates/category/list.html:27
msgid "Edit"
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"
6 changes: 3 additions & 3 deletions category/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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"):
Expand Down
19 changes: 19 additions & 0 deletions category/templates/category/add.html
Original file line number Diff line number Diff line change
@@ -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 %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% bootstrap_form form layout='horizontal' %}
<hr>
<h2 class="mb-4">{% trans "PDF Options" %}</h2>
{% bootstrap_form request_form layout='horizontal' %}
{% bootstrap_button _("Submit") button_type="submit" %}
</form>
{{ form.media }}
<script type="module">
const select = document.getElementById("id_category-locale");
if (select.value === "") {
select.value = "{{ request.LANGUAGE_CODE }}"
}
</script>
{% endblock %}
10 changes: 6 additions & 4 deletions category/templates/category/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<td>{{ category.name }}</td>
<td><a href="{% url "category:index" slug=category.slug %}">{% url "category:index" slug=category.slug %}</a></td>
<td>{% if category.generate_pdf %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</td>
<td>{{ category.locale }}</td>
<td>{{ category.request.locale }}</td>
<td>
<div class="btn-group me-1">
<a href="{% url "category:edit" pk=category.id %}" class="btn btn-primary">{% trans "Edit" %}</a>
Expand All @@ -30,10 +30,12 @@
</button>
<ul class="dropdown-menu dropdown-menu-end">
<li>
{% if category.id in already_staged %}
<a href="{% url "category:regenerate" pk=category.id %}" class="dropdown-item text-secondary pe-none">{% trans "Already in queue" %}</a>
{% if category.request.status == "SC" %}
<a href="{% url "pdf:wait" pk=category.request.id %}" class="dropdown-item text-secondary pe-none">{% trans "Already in queue" %} ({{ category.request.scheduled_at|time }})</a>
{% elif category.request.status == "QU" %}
<a href="{% url "pdf:wait" pk=category.request.id %}" class="dropdown-item text-secondary pe-none">{% trans "Already in queue" %}</a>
{% else %}
<span class="dropdown-item text-primary">{% trans "Regenerate" %}</span>
<a href="{% url "category:generate" pk=category.id %}" class="dropdown-item text-primary">{% trans "Generate PDF" %}</a>
{% endif %}
</li>
<li><a href="{% url "category:delete" pk=category.id %}" class="dropdown-item text-danger">{% trans "Delete" %}</a></li>
Expand Down
2 changes: 2 additions & 0 deletions category/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
CategoryDeleteView,
CategoryRegeneratePDFView,
CategoryMoveView,
CategoryGenerateView,
)

urlpatterns = [
Expand All @@ -20,4 +21,5 @@
path("regenerate/<int:pk>", CategoryRegeneratePDFView.as_view(), name="regenerate"),
path("move", CategoryMoveView.as_view(), name="move"),
path("<str:slug>", CategorySongsListView.as_view(), name="index"),
path("generate/<int:pk>", CategoryGenerateView.as_view, name="generate"),
]
Loading

0 comments on commit c92337f

Please sign in to comment.