diff --git a/compensation/forms.py b/compensation/forms.py index c0709975..9d2df376 100644 --- a/compensation/forms.py +++ b/compensation/forms.py @@ -60,12 +60,18 @@ class NewPaymentForm(BaseModalForm): format="%d.%m.%Y" ) ) - transfer_note = forms.CharField( + comment = forms.CharField( max_length=200, required=False, + label=_("Comment"), label_suffix=_(""), - label=_("Transfer note"), - help_text=_("Note for money transfer") + help_text=_("Additional comment, maximum {} letters").format(200), + widget=forms.Textarea( + attrs={ + "rows": 5, + "class": "w-100" + } + ) ) def __init__(self, *args, **kwargs): @@ -75,6 +81,29 @@ class NewPaymentForm(BaseModalForm): self.form_caption = _("Add a payment for intervention '{}'").format(self.intervention.title) self.add_placeholder_for_field("amount", "0,00") + def is_valid(self): + """ + Checks on form validity. + + For this form we need to make sure that a date or a comment is set. + If both are missing, the user needs to enter at least an explanation why + there is no date to be entered. + + Returns: + is_valid (bool): True if valid, False otherwise + """ + super_valid = super().is_valid() + date = self.cleaned_data["due"] + comment = self.cleaned_data["comment"] or None + if not date and not comment: + # At least one needs to be set! + self.add_error( + "comment", + _("If there is no date you can enter, please explain why.") + ) + return False + return super_valid + def save(self): with transaction.atomic(): created_action = UserActionLogEntry.objects.create( @@ -90,7 +119,7 @@ class NewPaymentForm(BaseModalForm): created=created_action, amount=self.cleaned_data.get("amount", -1), due_on=self.cleaned_data.get("due", None), - comment=self.cleaned_data.get("transfer_note", None), + comment=self.cleaned_data.get("comment", None), intervention=self.intervention, ) self.intervention.log.add(edited_action) diff --git a/compensation/templates/compensation/detail/compensation/includes/deadlines.html b/compensation/templates/compensation/detail/compensation/includes/deadlines.html index f1385a59..206bd7d3 100644 --- a/compensation/templates/compensation/detail/compensation/includes/deadlines.html +++ b/compensation/templates/compensation/detail/compensation/includes/deadlines.html @@ -44,7 +44,7 @@ {% trans deadline.type_humanized %} - {{ deadline.date }} + {{ deadline.date|default_if_none:"---" }} {{ deadline.comment }} {% if is_default_member and has_access %} diff --git a/compensation/templates/compensation/detail/eco_account/includes/deadlines.html b/compensation/templates/compensation/detail/eco_account/includes/deadlines.html index 2bd7d2c8..4bf26df6 100644 --- a/compensation/templates/compensation/detail/eco_account/includes/deadlines.html +++ b/compensation/templates/compensation/detail/eco_account/includes/deadlines.html @@ -44,7 +44,7 @@ {% trans deadline.type_humanized %} - {{ deadline.date }} + {{ deadline.date|default_if_none:"---" }} {{ deadline.comment }} {% if is_default_member and has_access %} diff --git a/ema/templates/ema/detail/includes/deadlines.html b/ema/templates/ema/detail/includes/deadlines.html index 63ed3b67..36bda6fd 100644 --- a/ema/templates/ema/detail/includes/deadlines.html +++ b/ema/templates/ema/detail/includes/deadlines.html @@ -44,7 +44,7 @@ {% trans deadline.type_humanized %} - {{ deadline.date }} + {{ deadline.date|default_if_none:"---" }} {{ deadline.comment }} {% if is_default_member and has_access %} diff --git a/intervention/templates/intervention/detail/includes/payments.html b/intervention/templates/intervention/detail/includes/payments.html index 767d0e4a..8177371a 100644 --- a/intervention/templates/intervention/detail/includes/payments.html +++ b/intervention/templates/intervention/detail/includes/payments.html @@ -31,7 +31,7 @@ {% trans 'Due on' %} - {% trans 'Transfer comment' %} + {% trans 'Comment' %} {% trans 'Action' %} @@ -44,7 +44,7 @@ {{ pay.amount|floatformat:2 }} € - {{ pay.due_on }} + {{ pay.due_on|default_if_none:"---" }} {{ pay.comment }} {% if is_default_member and has_access %} diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 1e8f0b2d..4c4736e3 100644 Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index f854d82e..eb53cb11 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -3,20 +3,20 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#: compensation/filters.py:71 compensation/forms.py:46 compensation/forms.py:51 -#: compensation/forms.py:65 compensation/forms.py:234 compensation/forms.py:314 +#: compensation/filters.py:71 compensation/forms.py:48 compensation/forms.py:53 +#: compensation/forms.py:67 compensation/forms.py:236 compensation/forms.py:331 #: intervention/filters.py:26 intervention/filters.py:40 #: intervention/filters.py:47 intervention/filters.py:48 #: intervention/forms.py:322 intervention/forms.py:334 -#: intervention/forms.py:346 konova/forms.py:108 konova/forms.py:242 -#: konova/forms.py:275 konova/forms.py:280 konova/forms.py:292 -#: konova/forms.py:304 konova/forms.py:317 user/forms.py:38 +#: intervention/forms.py:346 konova/forms.py:108 konova/forms.py:252 +#: konova/forms.py:287 konova/forms.py:292 konova/forms.py:304 +#: konova/forms.py:316 konova/forms.py:329 user/forms.py:38 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-08-24 14:26+0200\n" +"POT-Creation-Date: 2021-08-26 13:45+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -30,54 +30,48 @@ msgstr "" msgid "Show only unrecorded" msgstr "Nur unverzeichnete anzeigen" -#: compensation/forms.py:45 compensation/forms.py:303 -#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31 -#: intervention/templates/intervention/detail/includes/withdraws.html:31 -msgid "Amount" -msgstr "Menge" - -#: compensation/forms.py:47 +#: compensation/forms.py:49 msgid "in Euro" msgstr "in Euro" -#: compensation/forms.py:50 +#: compensation/forms.py:52 #: intervention/templates/intervention/detail/includes/payments.html:31 msgid "Due on" msgstr "Fällig am" -#: compensation/forms.py:53 +#: compensation/forms.py:55 msgid "Due on which date" msgstr "Zahlung wird an diesem Datum erwartet" -#: compensation/forms.py:66 +#: compensation/forms.py:68 msgid "Transfer note" msgstr "Verwendungszweck" -#: compensation/forms.py:67 +#: compensation/forms.py:69 msgid "Note for money transfer" msgstr "Verwendungszweck für Überweisung" -#: compensation/forms.py:73 +#: compensation/forms.py:75 msgid "Payment" msgstr "Zahlung" -#: compensation/forms.py:74 +#: compensation/forms.py:76 msgid "Add a payment for intervention '{}'" msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen" -#: compensation/forms.py:86 +#: compensation/forms.py:88 msgid "Added payment" msgstr "Zahlung hinzufügen" -#: compensation/forms.py:103 compensation/forms.py:115 +#: compensation/forms.py:105 compensation/forms.py:117 msgid "Biotope Type" msgstr "Biotoptyp" -#: compensation/forms.py:106 +#: compensation/forms.py:108 msgid "Select the biotope type" msgstr "Biotoptyp wählen" -#: compensation/forms.py:122 +#: compensation/forms.py:124 #: compensation/templates/compensation/detail/compensation/includes/states-after.html:36 #: compensation/templates/compensation/detail/compensation/includes/states-before.html:36 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36 @@ -88,35 +82,35 @@ msgstr "Biotoptyp wählen" msgid "Surface" msgstr "Fläche" -#: compensation/forms.py:125 intervention/forms.py:476 +#: compensation/forms.py:127 intervention/forms.py:476 msgid "in m²" msgstr "" -#: compensation/forms.py:130 +#: compensation/forms.py:132 msgid "New state" msgstr "Neuer Zustand" -#: compensation/forms.py:131 +#: compensation/forms.py:133 msgid "Insert data for the new state" msgstr "Geben Sie die Daten des neuen Zustandes ein" -#: compensation/forms.py:139 +#: compensation/forms.py:141 msgid "Added state" msgstr "Zustand hinzugefügt" -#: compensation/forms.py:155 konova/forms.py:158 +#: compensation/forms.py:157 konova/forms.py:168 msgid "Object removed" msgstr "Objekt entfernt" -#: compensation/forms.py:206 +#: compensation/forms.py:208 msgid "Deadline Type" msgstr "Fristart" -#: compensation/forms.py:209 +#: compensation/forms.py:211 msgid "Select the deadline type" msgstr "Fristart wählen" -#: compensation/forms.py:218 +#: compensation/forms.py:220 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31 #: ema/templates/ema/detail/includes/deadlines.html:31 @@ -124,11 +118,11 @@ msgstr "Fristart wählen" msgid "Date" msgstr "Datum" -#: compensation/forms.py:221 +#: compensation/forms.py:223 msgid "Select date" msgstr "Datum wählen" -#: compensation/forms.py:233 compensation/forms.py:313 +#: compensation/forms.py:235 compensation/forms.py:330 #: compensation/templates/compensation/detail/compensation/includes/actions.html:34 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:34 #: compensation/templates/compensation/detail/compensation/includes/documents.html:31 @@ -141,36 +135,40 @@ msgstr "Datum wählen" #: intervention/forms.py:345 #: intervention/templates/intervention/detail/includes/documents.html:31 #: intervention/templates/intervention/detail/includes/revocation.html:35 -#: konova/forms.py:303 +#: konova/forms.py:315 msgid "Comment" msgstr "Kommentar" -#: compensation/forms.py:235 compensation/forms.py:315 -#: intervention/forms.py:347 konova/forms.py:305 +#: compensation/forms.py:237 compensation/forms.py:332 +#: intervention/forms.py:347 konova/forms.py:317 msgid "Additional comment, maximum {} letters" msgstr "Zusätzlicher Kommentar, maximal {} Zeichen" -#: compensation/forms.py:246 +#: compensation/forms.py:248 msgid "New deadline" msgstr "Neue Frist" -#: compensation/forms.py:247 +#: compensation/forms.py:249 msgid "Insert data for the new deadline" msgstr "Geben Sie die Daten der neuen Frist ein" -#: compensation/forms.py:264 +#: compensation/forms.py:259 +msgid "If there is no date you can enter, please explain why." +msgstr "Falls Sie kein Datum angeben können, erklären Sie bitte weshalb." + +#: compensation/forms.py:280 msgid "Added deadline" msgstr "Frist/Termin hinzugefügt" -#: compensation/forms.py:275 +#: compensation/forms.py:291 msgid "Action Type" msgstr "Maßnahmentyp" -#: compensation/forms.py:278 +#: compensation/forms.py:294 msgid "Select the action type" msgstr "Maßnahmentyp wählen" -#: compensation/forms.py:285 +#: compensation/forms.py:303 #: compensation/templates/compensation/detail/compensation/includes/actions.html:37 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:37 #: compensation/templates/compensation/detail/compensation/includes/documents.html:34 @@ -196,51 +194,57 @@ msgstr "Maßnahmentyp wählen" msgid "Action" msgstr "Aktionen" -#: compensation/forms.py:291 +#: compensation/forms.py:308 msgid "Unit" msgstr "Einheit" -#: compensation/forms.py:294 +#: compensation/forms.py:311 msgid "Select the unit" msgstr "Einheit wählen" -#: compensation/forms.py:306 +#: compensation/forms.py:320 +#: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31 +#: intervention/templates/intervention/detail/includes/withdraws.html:31 +msgid "Amount" +msgstr "Menge" + +#: compensation/forms.py:323 msgid "Insert the amount" msgstr "Menge eingeben" -#: compensation/forms.py:326 +#: compensation/forms.py:343 msgid "New action" msgstr "Neue Maßnahme" -#: compensation/forms.py:327 +#: compensation/forms.py:344 msgid "Insert data for the new action" msgstr "Geben Sie die Daten der neuen Maßnahme ein" -#: compensation/forms.py:346 +#: compensation/forms.py:363 msgid "Added action" msgstr "Maßnahme hinzugefügt" -#: compensation/models.py:56 +#: compensation/models.py:67 msgid "cm" msgstr "" -#: compensation/models.py:57 +#: compensation/models.py:68 msgid "m" msgstr "" -#: compensation/models.py:58 +#: compensation/models.py:69 msgid "km" msgstr "" -#: compensation/models.py:59 +#: compensation/models.py:70 msgid "m²" msgstr "" -#: compensation/models.py:60 +#: compensation/models.py:71 msgid "ha" msgstr "" -#: compensation/models.py:61 +#: compensation/models.py:72 msgid "Pieces" msgstr "Stück" @@ -260,7 +264,7 @@ msgstr "Kennung" #: intervention/tables.py:28 #: intervention/templates/intervention/detail/includes/compensations.html:33 #: intervention/templates/intervention/detail/includes/documents.html:28 -#: intervention/templates/intervention/detail/view.html:31 konova/forms.py:274 +#: intervention/templates/intervention/detail/view.html:31 konova/forms.py:286 msgid "Title" msgstr "Bezeichnung" @@ -463,7 +467,7 @@ msgstr "Dokumente" #: compensation/templates/compensation/detail/eco_account/includes/documents.html:14 #: ema/templates/ema/detail/includes/documents.html:14 #: intervention/templates/intervention/detail/includes/documents.html:14 -#: konova/forms.py:316 +#: konova/forms.py:328 msgid "Add new document" msgstr "Neues Dokument hinzufügen" @@ -846,7 +850,7 @@ msgstr "Datum des Widerspruchs" msgid "Document" msgstr "Dokument" -#: intervention/forms.py:335 konova/forms.py:293 +#: intervention/forms.py:335 konova/forms.py:305 msgid "Must be smaller than 15 Mb" msgstr "Muss kleiner als 15 Mb sein" @@ -868,7 +872,7 @@ msgstr "Kompensationen und Zahlungen geprüft" msgid "Run check" msgstr "Prüfung vornehmen" -#: intervention/forms.py:411 konova/forms.py:364 +#: intervention/forms.py:411 konova/forms.py:376 msgid "" "I, {} {}, confirm that all necessary control steps have been performed by " "myself." @@ -1105,11 +1109,11 @@ msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!" msgid "Not editable" msgstr "Nicht editierbar" -#: konova/forms.py:107 konova/forms.py:241 +#: konova/forms.py:107 konova/forms.py:251 msgid "Confirm" msgstr "Bestätige" -#: konova/forms.py:119 konova/forms.py:250 +#: konova/forms.py:119 konova/forms.py:260 msgid "Remove" msgstr "Löschen" @@ -1117,44 +1121,44 @@ msgstr "Löschen" msgid "You are about to remove {} {}" msgstr "Sie sind dabei {} {} zu löschen" -#: konova/forms.py:251 +#: konova/forms.py:261 msgid "Are you sure?" msgstr "Sind Sie sicher?" -#: konova/forms.py:279 +#: konova/forms.py:291 msgid "Created on" msgstr "Erstellt" -#: konova/forms.py:281 +#: konova/forms.py:293 msgid "When has this file been created? Important for photos." msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?" -#: konova/forms.py:291 +#: konova/forms.py:303 #: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231 msgid "File" msgstr "Datei" -#: konova/forms.py:341 +#: konova/forms.py:353 msgid "Added document" msgstr "Dokument hinzugefügt" -#: konova/forms.py:355 +#: konova/forms.py:367 msgid "Confirm record" msgstr "Verzeichnen bestätigen" -#: konova/forms.py:363 +#: konova/forms.py:375 msgid "Record data" msgstr "Daten verzeichnen" -#: konova/forms.py:368 +#: konova/forms.py:380 msgid "Confirm unrecord" msgstr "Entzeichnen bestätigen" -#: konova/forms.py:369 +#: konova/forms.py:381 msgid "Unrecord data" msgstr "Daten entzeichnen" -#: konova/forms.py:370 +#: konova/forms.py:382 msgid "I, {} {}, confirm that this data must be unrecorded." msgstr "" "Ich, {} {}, bestätige, dass diese Daten wieder entzeichnet werden müssen." @@ -1307,7 +1311,7 @@ msgstr "Abbrechen" msgid "Save" msgstr "Speichern" -#: templates/form/generic_table_form_body.html:22 +#: templates/form/generic_table_form_body.html:23 msgid "Fields with * are required." msgstr "* sind Pflichtfelder."