diff --git a/compensation/filters.py b/compensation/filters.py index f96cbb9..8bf0c23 100644 --- a/compensation/filters.py +++ b/compensation/filters.py @@ -5,6 +5,9 @@ Contact: michel.peltriaux@sgdnord.rlp.de Created on: 29.07.21 """ +import django_filters +from django.utils.translation import gettext_lazy as _ +from django import forms from django.db.models import QuerySet from intervention.filters import InterventionTableFilter @@ -62,6 +65,12 @@ class EcoAccountTableFilter(InterventionTableFilter): Just some minor changes for EcoAccount model. """ + sr = django_filters.BooleanFilter( + method='_filter_only_show_unrecorded', + label=_("Show only unrecorded"), + label_suffix=_(""), + widget=forms.CheckboxInput() + ) def _filter_show_all(self, queryset, name, value) -> QuerySet: """ Filters queryset depending on value of 'show_all' setting @@ -81,7 +90,7 @@ class EcoAccountTableFilter(InterventionTableFilter): else: return queryset - def _filter_show_recorded(self, queryset, name, value) -> QuerySet: + def _filter_only_show_unrecorded(self, queryset, name, value) -> QuerySet: """ Filters queryset depending on value of 'show_recorded' setting Args: @@ -92,7 +101,7 @@ class EcoAccountTableFilter(InterventionTableFilter): Returns: """ - if not value: + if value: return queryset.filter( recorded=None, ) diff --git a/compensation/forms.py b/compensation/forms.py index c2a225b..8a7737e 100644 --- a/compensation/forms.py +++ b/compensation/forms.py @@ -135,6 +135,10 @@ class NewStateModalForm(BaseModalForm): Wraps the request processing logic, so we don't need the same code everywhere a RemoveModalForm is being used + +++ + The generic method from super class can not be used, since we need to do some request parameter check in here. + +++ + Args: request (HttpRequest): The incoming request msg_success (str): The message in case of successful removing diff --git a/compensation/templates/compensation/detail/compensation/view.html b/compensation/templates/compensation/detail/compensation/view.html index 310e7eb..16084e2 100644 --- a/compensation/templates/compensation/detail/compensation/view.html +++ b/compensation/templates/compensation/detail/compensation/view.html @@ -80,11 +80,7 @@
- {% if geom_form.area == 0 %} -
{% trans 'No geometry added, yet.' %}
- {% endif %} - {{geom_form.media}} - {{geom_form.geom}} + {% include 'map/geom_form.html' %}

diff --git a/compensation/templates/compensation/detail/eco_account/view.html b/compensation/templates/compensation/detail/eco_account/view.html index 098d7a3..51d0645 100644 --- a/compensation/templates/compensation/detail/eco_account/view.html +++ b/compensation/templates/compensation/detail/eco_account/view.html @@ -2,7 +2,13 @@ {% load i18n l10n static fontawesome_5 humanize %} {% block head %} - + {% comment %} + dal documentation (django-autocomplete-light) states using form.media for adding needed scripts. + This does not work properly with modal forms, as the scripts are not loaded properly inside the modal. + Therefore the script linkages from form.media have been extracted and put inside dal/scripts.html to ensure + these scripts are loaded when needed. + {% endcomment %} + {% include 'dal/scripts.html' %} {% endblock %} {% block body %} @@ -66,11 +72,7 @@
- {% if geom_form.area == 0 %} -
{% trans 'No geometry added, yet.' %}
- {% endif %} - {{geom_form.media}} - {{geom_form.geom}} + {% include 'map/geom_form.html' %}

diff --git a/intervention/templates/intervention/detail/view.html b/intervention/templates/intervention/detail/view.html index 57edb2e..57bf6ba 100644 --- a/intervention/templates/intervention/detail/view.html +++ b/intervention/templates/intervention/detail/view.html @@ -2,7 +2,13 @@ {% load i18n l10n static fontawesome_5 humanize %} {% block head %} - + {% comment %} + dal documentation (django-autocomplete-light) states using form.media for adding needed scripts. + This does not work properly with modal forms, as the scripts are not loaded properly inside the modal. + Therefore the script linkages from form.media have been extracted and put inside dal/scripts.html to ensure + these scripts are loaded when needed. + {% endcomment %} + {% include 'dal/scripts.html' %} {% endblock %} {% block body %} @@ -44,7 +50,7 @@ {% trans 'Conservation office' %} {{intervention.responsible.conservation_office|default_if_none:""}} - + {% trans 'Conversation office file number' %} {{intervention.responsible.conservation_file_number|default_if_none:""}} @@ -112,11 +118,7 @@
- {% if geom_form.area == 0 %} -
{% trans 'No geometry added, yet.' %}
- {% endif %} - {{geom_form.media}} - {{geom_form.geom}} + {% include 'map/geom_form.html' %}

diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 0c06917..cc0dc4d 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 5c3ad1c..f61eefb 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -3,12 +3,12 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#: compensation/forms.py:42 compensation/forms.py:47 compensation/forms.py:60 -#: compensation/forms.py:203 compensation/forms.py:271 +#: compensation/filters.py:71 compensation/forms.py:42 compensation/forms.py:47 +#: compensation/forms.py:60 compensation/forms.py:203 compensation/forms.py:271 #: intervention/filters.py:26 intervention/filters.py:40 #: intervention/filters.py:47 intervention/filters.py:48 -#: intervention/forms.py:321 intervention/forms.py:333 -#: intervention/forms.py:345 konova/forms.py:91 konova/forms.py:227 +#: intervention/forms.py:319 intervention/forms.py:331 +#: intervention/forms.py:343 konova/forms.py:91 konova/forms.py:227 #: konova/forms.py:260 konova/forms.py:265 konova/forms.py:277 #: konova/forms.py:289 konova/forms.py:302 user/forms.py:38 #, fuzzy @@ -16,7 +16,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-08-10 10:30+0200\n" +"POT-Creation-Date: 2021-08-10 12:35+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,6 +26,10 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: compensation/filters.py:70 +msgid "Show only unrecorded" +msgstr "Nur unverzeichnete anzeigen" + #: compensation/forms.py:41 compensation/forms.py:260 #: compensation/templates/compensation/detail/eco_account/includes/withdraws.html:31 #: intervention/templates/intervention/detail/includes/withdraws.html:31 @@ -78,11 +82,11 @@ msgstr "Biotoptyp wählen" #: compensation/templates/compensation/detail/compensation/includes/states-before.html:36 #: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36 #: compensation/templates/compensation/detail/eco_account/includes/states-before.html:36 -#: intervention/forms.py:449 +#: intervention/forms.py:455 msgid "Surface" msgstr "Fläche" -#: compensation/forms.py:106 intervention/forms.py:451 +#: compensation/forms.py:106 intervention/forms.py:457 msgid "in m²" msgstr "" @@ -113,7 +117,7 @@ msgstr "Fristart wählen" #: compensation/forms.py:187 #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31 -#: intervention/forms.py:320 +#: intervention/forms.py:318 msgid "Date" msgstr "Datum" @@ -128,7 +132,7 @@ msgstr "Datum wählen" #: compensation/templates/compensation/detail/eco_account/includes/actions.html:34 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:34 #: compensation/templates/compensation/detail/eco_account/includes/documents.html:31 -#: intervention/forms.py:344 +#: intervention/forms.py:342 #: intervention/templates/intervention/detail/includes/documents.html:31 #: intervention/templates/intervention/detail/includes/revocation.html:35 #: konova/forms.py:288 @@ -136,7 +140,7 @@ msgid "Comment" msgstr "Kommentar" #: compensation/forms.py:204 compensation/forms.py:272 -#: intervention/forms.py:346 konova/forms.py:290 +#: intervention/forms.py:344 konova/forms.py:290 msgid "Additional comment, maximum {} letters" msgstr "Zusätzlicher Kommentar, maximal {} Zeichen" @@ -184,32 +188,32 @@ msgstr "Geben Sie die Daten der neuen Maßnahme ein" msgid "Added action" msgstr "Maßnahme hinzugefügt" -#: compensation/models.py:60 +#: compensation/models.py:58 msgid "cm" msgstr "" -#: compensation/models.py:61 +#: compensation/models.py:59 msgid "m" msgstr "" -#: compensation/models.py:62 +#: compensation/models.py:60 msgid "km" msgstr "" -#: compensation/models.py:63 +#: compensation/models.py:61 msgid "m²" msgstr "" -#: compensation/models.py:64 +#: compensation/models.py:62 msgid "ha" msgstr "" -#: compensation/models.py:65 +#: compensation/models.py:63 msgid "Pieces" msgstr "Stück" #: compensation/tables.py:26 compensation/tables.py:166 -#: intervention/forms.py:31 intervention/tables.py:23 +#: intervention/forms.py:29 intervention/tables.py:23 #: intervention/templates/intervention/detail/includes/compensations.html:30 msgid "Identifier" msgstr "Kennung" @@ -219,7 +223,7 @@ msgstr "Kennung" #: compensation/templates/compensation/detail/compensation/view.html:24 #: compensation/templates/compensation/detail/eco_account/includes/documents.html:28 #: compensation/templates/compensation/detail/eco_account/view.html:24 -#: intervention/forms.py:38 intervention/tables.py:28 +#: intervention/forms.py:36 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:24 konova/forms.py:259 @@ -310,7 +314,7 @@ msgstr "Ökokonten" #: compensation/tables.py:224 #: compensation/templates/compensation/detail/eco_account/view.html:12 -#: intervention/forms.py:433 intervention/forms.py:440 +#: intervention/forms.py:439 intervention/forms.py:446 #: konova/templates/konova/home.html:88 templates/navbar.html:34 msgid "Eco-account" msgstr "Ökokonto" @@ -410,7 +414,7 @@ msgstr "Neue Frist hinzufügen" #: compensation/templates/compensation/detail/compensation/includes/deadlines.html:28 #: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:28 -#: intervention/forms.py:43 +#: intervention/forms.py:41 msgid "Type" msgstr "Typ" @@ -513,7 +517,7 @@ msgstr "Zuletzt bearbeitet" #: compensation/templates/compensation/detail/compensation/view.html:72 #: compensation/templates/compensation/detail/eco_account/view.html:58 -#: intervention/forms.py:254 +#: intervention/forms.py:252 #: intervention/templates/intervention/detail/view.html:104 msgid "Shared with" msgstr "Freigegeben für" @@ -550,7 +554,7 @@ msgid "Remove Withdraw" msgstr "Abbuchung entfernen" #: compensation/views/compensation_views.py:121 -#: compensation/views/eco_account_views.py:185 intervention/views.py:391 +#: compensation/views/eco_account_views.py:184 intervention/views.py:391 msgid "Log" msgstr "Log" @@ -559,22 +563,22 @@ msgid "Compensation removed" msgstr "Kompensation entfernt" #: compensation/views/compensation_views.py:161 -#: compensation/views/eco_account_views.py:262 intervention/views.py:96 +#: compensation/views/eco_account_views.py:261 intervention/views.py:96 msgid "Document added" msgstr "Dokument hinzugefügt" #: compensation/views/compensation_views.py:180 -#: compensation/views/eco_account_views.py:206 +#: compensation/views/eco_account_views.py:205 msgid "State added" msgstr "Zustand hinzugefügt" #: compensation/views/compensation_views.py:199 -#: compensation/views/eco_account_views.py:225 +#: compensation/views/eco_account_views.py:224 msgid "Action added" msgstr "Maßnahme hinzugefügt" #: compensation/views/compensation_views.py:218 -#: compensation/views/eco_account_views.py:244 +#: compensation/views/eco_account_views.py:243 msgid "Deadline added" msgstr "Frist hinzugefügt" @@ -586,15 +590,15 @@ msgstr "Zustand gelöscht" msgid "Action removed" msgstr "Maßnahme entfernt" -#: compensation/views/eco_account_views.py:135 +#: compensation/views/eco_account_views.py:134 msgid "Eco-account removed" msgstr "Ökokonto entfernt" -#: compensation/views/eco_account_views.py:162 +#: compensation/views/eco_account_views.py:161 msgid "Withdraw removed" msgstr "Abbuchung entfernt" -#: compensation/views/eco_account_views.py:282 intervention/views.py:413 +#: compensation/views/eco_account_views.py:281 intervention/views.py:413 msgid "Withdraw added" msgstr "Abbuchung hinzugefügt" @@ -622,125 +626,125 @@ msgstr "Gemarkung" msgid "Search for district" msgstr "Nach Gemarkung suchen" -#: intervention/forms.py:34 +#: intervention/forms.py:32 msgid "Generated automatically if none was given" msgstr "Wird automatisch erzeugt, falls nicht angegeben" -#: intervention/forms.py:46 +#: intervention/forms.py:44 msgid "Which intervention type is this" msgstr "Welcher Eingriffstyp" -#: intervention/forms.py:49 +#: intervention/forms.py:47 #: intervention/templates/intervention/detail/view.html:32 msgid "Law" msgstr "Gesetz" -#: intervention/forms.py:52 +#: intervention/forms.py:50 msgid "Based on which law" msgstr "Basiert auf welchem Recht" -#: intervention/forms.py:55 +#: intervention/forms.py:53 #: intervention/templates/intervention/detail/view.html:52 msgid "Intervention handler" msgstr "Eingriffsverursacher" -#: intervention/forms.py:58 +#: intervention/forms.py:56 msgid "Who performs the intervention" msgstr "Wer führt den Eingriff durch" -#: intervention/forms.py:61 +#: intervention/forms.py:59 msgid "Data provider" msgstr "Datenbereitsteller" -#: intervention/forms.py:63 +#: intervention/forms.py:61 msgid "Who provides the data for the intervention" msgstr "Wer stellt die Daten für den Eingriff zur Verfügung" -#: intervention/forms.py:68 +#: intervention/forms.py:66 msgid "Organization" msgstr "Organisation" -#: intervention/forms.py:74 +#: intervention/forms.py:72 msgid "Data provider details" msgstr "Datenbereitsteller Details" -#: intervention/forms.py:77 +#: intervention/forms.py:75 msgid "Further details" msgstr "Weitere Details" -#: intervention/forms.py:90 +#: intervention/forms.py:88 msgid "Map" msgstr "Karte" -#: intervention/forms.py:92 +#: intervention/forms.py:90 msgid "Where does the intervention take place" msgstr "Wo findet der Eingriff statt" -#: intervention/forms.py:100 +#: intervention/forms.py:98 msgid "Files" msgstr "Dateien" -#: intervention/forms.py:107 +#: intervention/forms.py:105 msgid "New intervention" msgstr "Neuer Eingriff" -#: intervention/forms.py:149 +#: intervention/forms.py:147 msgid "Edit intervention" msgstr "Eingriff bearbeiten" -#: intervention/forms.py:243 +#: intervention/forms.py:241 msgid "Share link" msgstr "Freigabelink" -#: intervention/forms.py:245 +#: intervention/forms.py:243 msgid "Send this link to users who you want to have writing access on the data" msgstr "Andere Nutzer erhalten über diesen Link Zugriff auf die Daten" -#: intervention/forms.py:257 +#: intervention/forms.py:255 msgid "Remove check to remove access for this user" msgstr "Wählen Sie die Nutzer ab, die keinen Zugriff mehr haben sollen" -#: intervention/forms.py:268 +#: intervention/forms.py:266 #: intervention/templates/intervention/detail/includes/controls.html:15 msgid "Share" msgstr "Freigabe" -#: intervention/forms.py:269 +#: intervention/forms.py:267 msgid "Share settings for {}" msgstr "Freigabe Einstellungen für {}" -#: intervention/forms.py:322 +#: intervention/forms.py:320 msgid "Date of revocation" msgstr "Datum des Widerspruchs" -#: intervention/forms.py:332 +#: intervention/forms.py:330 #: intervention/templates/intervention/detail/includes/revocation.html:38 msgid "Document" msgstr "Dokument" -#: intervention/forms.py:334 konova/forms.py:278 +#: intervention/forms.py:332 konova/forms.py:278 msgid "Must be smaller than 15 Mb" msgstr "Muss kleiner als 15 Mb sein" -#: intervention/forms.py:357 +#: intervention/forms.py:355 #: intervention/templates/intervention/detail/includes/revocation.html:18 msgid "Add revocation" msgstr "Widerspruch hinzufügen" -#: intervention/forms.py:393 +#: intervention/forms.py:391 msgid "Checked intervention data" msgstr "Eingriffsdaten geprüft" -#: intervention/forms.py:399 +#: intervention/forms.py:397 msgid "Checked compensations data and payments" msgstr "Kompensationen und Zahlungen geprüft" -#: intervention/forms.py:407 +#: intervention/forms.py:405 #: intervention/templates/intervention/detail/includes/controls.html:19 msgid "Run check" msgstr "Prüfung vornehmen" -#: intervention/forms.py:408 +#: intervention/forms.py:406 msgid "" "I, {} {}, confirm that all necessary control steps have been performed by " "myself." @@ -748,36 +752,36 @@ msgstr "" "Ich, {} {}, bestätige, dass die notwendigen Kontrollschritte durchgeführt " "wurden:" -#: intervention/forms.py:435 +#: intervention/forms.py:441 msgid "Only recorded accounts can be selected for withdraws" -msgstr "" -"Nur verzeichnete Ökokonten können für Abbuchungen verwendet werden." +msgstr "Nur verzeichnete Ökokonten können für Abbuchungen verwendet werden." -#: intervention/forms.py:454 intervention/forms.py:461 +#: intervention/forms.py:460 intervention/forms.py:467 #: intervention/tables.py:92 intervention/tables.py:172 #: intervention/templates/intervention/detail/view.html:12 #: konova/templates/konova/home.html:11 templates/navbar.html:22 msgid "Intervention" msgstr "Eingriff" -#: intervention/forms.py:456 +#: intervention/forms.py:462 msgid "Only shared interventions can be selected" msgstr "Nur freigegebene Eingriffe können gewählt werden" -#: intervention/forms.py:469 +#: intervention/forms.py:475 msgid "New Withdraw" msgstr "Neue Abbuchung" -#: intervention/forms.py:470 +#: intervention/forms.py:476 msgid "Enter the information for a new withdraw from a chosen eco-account" msgstr "Geben Sie die Informationen für eine neue Abbuchung ein." -#: intervention/forms.py:511 +#: intervention/forms.py:517 msgid "" "The account {} has not enough surface for a withdraw of {} m². There are " "only {} m² left" msgstr "" -"Das Ökokonto {} hat für eine Abbuchung von {} m² nicht ausreichend Restfläche. Es stehen noch {} m² zur Verfügung." +"Das Ökokonto {} hat für eine Abbuchung von {} m² nicht ausreichend " +"Restfläche. Es stehen noch {} m² zur Verfügung." #: intervention/models.py:203 #: intervention/templates/intervention/detail/view.html:23 diff --git a/templates/dal/scripts.html b/templates/dal/scripts.html new file mode 100644 index 0000000..484820d --- /dev/null +++ b/templates/dal/scripts.html @@ -0,0 +1,15 @@ + +{% comment %} + These are the scripts, which are generally loaded by using form.meda, as stated in the + dal documentation (django-autocomplete-light). By including these scripts independent from any script + we can easily use dal in modal forms. + + https://django-autocomplete-light.readthedocs.io/en/master/tutorial.html#using-autocompletes-outside-the-admin +{% endcomment %} + + + + + + + \ No newline at end of file diff --git a/templates/map/geom_form.html b/templates/map/geom_form.html new file mode 100644 index 0000000..6d07903 --- /dev/null +++ b/templates/map/geom_form.html @@ -0,0 +1,12 @@ +{% load i18n %} + +{% comment %} + Encapsules the rendering and initializing of a geometry view component, e.g. used in the detail views. +{% endcomment %} + + +{% if geom_form.area == 0 %} +
{% trans 'No geometry added, yet.' %}
+{% endif %} +{{geom_form.media}} +{{geom_form.geom}} \ No newline at end of file