From 8885f8177011f812139e6556fa9b177dceaad86b Mon Sep 17 00:00:00 2001 From: mipel Date: Fri, 23 Jul 2021 18:27:53 +0200 Subject: [PATCH] Documents removing * adds generic modal rendering using package django-bootstrap-modal-forms * adds document file removing from hard drive * adds translations --- .../templates/intervention/detail-view.html | 17 ++- konova/contexts.py | 1 + konova/forms.py | 17 +++ konova/models.py | 14 +++ konova/sub_settings/django_settings.py | 1 + konova/urls.py | 2 +- konova/views.py | 39 ++++++- locale/de/LC_MESSAGES/django.mo | Bin 8057 -> 8437 bytes locale/de/LC_MESSAGES/django.po | 108 ++++++++++-------- requirements.txt | 1 + templates/base.html | 13 +++ templates/modal/modal_form.html | 32 ++++++ templates/modal/modal_form_script.html | 18 +++ 13 files changed, 202 insertions(+), 61 deletions(-) create mode 100644 templates/modal/modal_form.html create mode 100644 templates/modal/modal_form_script.html diff --git a/intervention/templates/intervention/detail-view.html b/intervention/templates/intervention/detail-view.html index 9351f8b..25d99bd 100644 --- a/intervention/templates/intervention/detail-view.html +++ b/intervention/templates/intervention/detail-view.html @@ -1,7 +1,12 @@ {% extends 'base.html' %} {% load i18n static fontawesome_5 %} +{% block head %} + +{% endblock %} + {% block body %} +

{% trans 'Intervention' %} {{intervention.identifier}}

@@ -293,11 +298,9 @@ {{ doc.comment }} - - - + {% endfor %} @@ -308,4 +311,8 @@
+{% with 'del-btn' as btn_class %} + {% include 'modal/modal_form_script.html' %} +{% endwith %} + {% endblock %} \ No newline at end of file diff --git a/konova/contexts.py b/konova/contexts.py index 0b25086..e514dd1 100644 --- a/konova/contexts.py +++ b/konova/contexts.py @@ -23,6 +23,7 @@ class BaseContext: "user": None, "current_role": None, "help_link": HELP_LINK, + "modal_reload_page": "true", # must be string and lower case true, since it's used in JS code } def __init__(self, request: HttpRequest, additional_context: dict = {}): diff --git a/konova/forms.py b/konova/forms.py index 31bafa0..15966cd 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -8,10 +8,12 @@ Created on: 16.11.20 from abc import abstractmethod +from bootstrap_modal_forms.forms import BSModalModelForm, BSModalForm from django import forms from django.contrib.auth.models import User from django.contrib.gis.forms import GeometryField, OSMWidget from django.contrib.gis.geos import Polygon +from django.urls import reverse from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -127,3 +129,18 @@ class SimpleGeomForm(BaseForm): self.fields["geom"].widget.attrs["default_zoom"] = 1 self.initialize_form_field("geom", geom) self.area = geom.area + + +class RemoveDocumentForm(BaseForm, BSModalForm): + confirm = forms.BooleanField( + label=_("Confirm"), + label_suffix=_(""), + widget=forms.CheckboxInput(), + required=True, + ) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.instance = kwargs.get("instance", None) + self.form_title = _("Remove document") + self.form_caption = _("This will remove '{}'. Are you sure?").format(self.instance.title) diff --git a/konova/models.py b/konova/models.py index 25a63a6..0d4d79a 100644 --- a/konova/models.py +++ b/konova/models.py @@ -5,6 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de Created on: 17.11.20 """ +import os import uuid from django.contrib.auth.models import User @@ -65,6 +66,19 @@ class Document(BaseResource): document = models.FileField() comment = models.TextField() + def delete(self, using=None, keep_parents=False): + """ Custom delete function to remove the real file from the hard drive + + Args: + using (): + keep_parents (): + + Returns: + + """ + os.remove(self.document.file.name) + super().delete(using=using, keep_parents=keep_parents) + class Geometry(BaseResource): """ diff --git a/konova/sub_settings/django_settings.py b/konova/sub_settings/django_settings.py index e06c138..0f54ef8 100644 --- a/konova/sub_settings/django_settings.py +++ b/konova/sub_settings/django_settings.py @@ -55,6 +55,7 @@ INSTALLED_APPS = [ 'django.contrib.gis', 'simple_sso.sso_server', 'django_tables2', + 'bootstrap_modal_forms', 'fontawesome_5', 'bootstrap4', 'konova', diff --git a/konova/urls.py b/konova/urls.py index 74ad3f1..dcb4942 100644 --- a/konova/urls.py +++ b/konova/urls.py @@ -38,7 +38,7 @@ urlpatterns = [ # Documents path('document/', get_document_view, name="doc-open"), path('document/new', new_document_view, name="doc-new"), - path('document//remove>', remove_document_view, name="doc-remove"), + path('document//remove', remove_document_view, name="doc-remove"), # Autocomplete paths path("atcmplt/orgs", OrganisationAutocomplete.as_view(), name="orgs-autocomplete"), diff --git a/konova/views.py b/konova/views.py index 76ca956..68c8fdd 100644 --- a/konova/views.py +++ b/konova/views.py @@ -14,6 +14,7 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from konova.contexts import BaseContext +from konova.forms import RemoveDocumentForm from konova.models import Document from news.models import ServerMessage from konova.settings import SSO_SERVER_BASE @@ -104,17 +105,43 @@ def new_document_view(request: HttpRequest): def remove_document_view(request: HttpRequest, id: str): """ Renders a form for uploading new documents + This function works using a modal. We are not using the regular way, the django bootstrap modal forms are + intended to be used. Instead of View classes we work using the classic way of dealing with forms (see below). + It is important to mention, that modal forms, which should reload the page afterwards, must provide a + 'reload_page' bool in the context. This way, the modal may reload the page or not. + + For further details see the comments in templates/modal or + https://github.com/trco/django-bootstrap-modal-forms + Args: request (HttpRequest): The incoming request Returns: """ + template = "modal/modal_form.html" doc = get_object_or_404(Document, id=id) title = doc.title - #doc.delete() - messages.success( - request, - _("Document '{}' deleted").format(title) - ) - return redirect(request.META.get("HTTP_REFERER", "home")) + form = RemoveDocumentForm(request.POST or None, instance=doc) + if request.method == "POST": + if form.is_valid(): + doc.delete() + messages.success( + request, + _("Document '{}' deleted").format(title) + ) + return redirect(request.META.get("HTTP_REFERER", "home")) + else: + messages.info( + request, + _("There was an error on this form.") + ) + return redirect(request.META.get("HTTP_REFERER", "home")) + elif request.method == "GET": + context = { + "form": form, + } + context = BaseContext(request, context).context + return render(request, template, context) + else: + raise NotImplementedError \ No newline at end of file diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index b460f6443c80c0b307c8f14c5789a1c43150b6a9..70111a9e75a26bdf02533b9768a0930c42a85f66 100644 GIT binary patch delta 3157 zcmZA1drZ}39LMno6-)sE0}Yk@c?rP;Z=_i&VrVFe;k6P&gr9Kaa8CX>M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qr@85v_jY%}J zVdhQ9YabR8cM|s!*AO-nur0_C>Z3B0m`T(TPY~A=w)=?(h#QFtVm4uO)>8>5&5((3 z7aJs*&VCA(6E3zDglofDvar)_CEu>x3B-ehkH~gAF`sBA1`{sM|F>!E@NMuh+#L_P z{{GYE#-0_iY?rrN=&T_u>*Itg*|)_uj;JPXC1wz|M>3?pNAo>C_NSvi*>~7?d>5R* z#Xh$d;wEA-;eSK6rVQ!d^R;X*A^1%RV~MATc?54-Xe3q<4a7RawupF`aP7FhY?CvD zN%-&l2hph|?u!RqWVR=X$B5N-Xk~;8sWY*hm_rOFW)YXShv@ibxX5hFGNc#ZqjCFb z{?vr3*pa@3KaIX3wtI-H(_10jh7$>Y2P%oBL=7<}IXHJ;>UeH>Rp3U+l!ZRtHeD{EQu>%!9Hg~Iiz=lZPgm@MsgF}0xowyb{u+`;IV diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 886893b..e2b4ab4 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -4,14 +4,14 @@ # FIRST AUTHOR , YEAR. # #: intervention/filters.py:25 intervention/filters.py:31 -#: intervention/filters.py:38 intervention/filters.py:39 konova/forms.py:71 -#: user/forms.py:38 +#: intervention/filters.py:38 intervention/filters.py:39 konova/forms.py:73 +#: konova/forms.py:137 user/forms.py:38 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-07-23 16:00+0200\n" +"POT-Creation-Date: 2021-07-23 18:26+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,15 +23,15 @@ msgstr "" #: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26 #: intervention/tables.py:23 -#: intervention/templates/intervention/detail-view.html:174 +#: intervention/templates/intervention/detail-view.html:179 msgid "Identifier" msgstr "Kennung" #: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33 #: intervention/tables.py:28 -#: intervention/templates/intervention/detail-view.html:57 -#: intervention/templates/intervention/detail-view.html:177 -#: intervention/templates/intervention/detail-view.html:276 +#: intervention/templates/intervention/detail-view.html:62 +#: intervention/templates/intervention/detail-view.html:182 +#: intervention/templates/intervention/detail-view.html:281 msgid "Title" msgstr "Bezeichnung" @@ -44,7 +44,7 @@ msgid "Actions" msgstr "Aktionen" #: compensation/tables.py:44 -#: intervention/templates/intervention/detail-view.html:154 +#: intervention/templates/intervention/detail-view.html:159 msgid "Compensations" msgstr "Kompensationen" @@ -101,7 +101,7 @@ msgid "Which intervention type is this" msgstr "Welcher Eingriffstyp" #: intervention/forms.py:44 -#: intervention/templates/intervention/detail-view.html:65 +#: intervention/templates/intervention/detail-view.html:70 msgid "Law" msgstr "Gesetz" @@ -110,7 +110,7 @@ msgid "Based on which law" msgstr "Basiert auf welchem Recht" #: intervention/forms.py:50 -#: intervention/templates/intervention/detail-view.html:85 +#: intervention/templates/intervention/detail-view.html:90 msgid "Intervention handler" msgstr "Eingriffsverursacher" @@ -159,12 +159,12 @@ msgid "Edit intervention" msgstr "Eingriff bearbeiten" #: intervention/tables.py:33 -#: intervention/templates/intervention/detail-view.html:89 +#: intervention/templates/intervention/detail-view.html:94 msgid "Checked" msgstr "Geprüft" #: intervention/tables.py:39 -#: intervention/templates/intervention/detail-view.html:103 +#: intervention/templates/intervention/detail-view.html:108 msgid "Recorded" msgstr "Verzeichnet" @@ -181,7 +181,7 @@ msgid "Interventions" msgstr "Eingriffe" #: intervention/tables.py:92 intervention/tables.py:170 -#: intervention/templates/intervention/detail-view.html:7 +#: intervention/templates/intervention/detail-view.html:12 #: konova/templates/konova/home.html:11 templates/navbar.html:22 msgid "Intervention" msgstr "Eingriff" @@ -210,112 +210,112 @@ msgstr "Für Sie freigegeben - Datensatz kann bearbeitet werden" msgid "Access not granted" msgstr "Nicht freigegeben - Datensatz nur lesbar" -#: intervention/templates/intervention/detail-view.html:12 +#: intervention/templates/intervention/detail-view.html:17 msgid "Open in LANIS" msgstr "In LANIS öffnen" -#: intervention/templates/intervention/detail-view.html:17 +#: intervention/templates/intervention/detail-view.html:22 msgid "Public report" msgstr "Öffentlicher Bericht" -#: intervention/templates/intervention/detail-view.html:23 +#: intervention/templates/intervention/detail-view.html:28 msgid "Share" msgstr "Freigabe" -#: intervention/templates/intervention/detail-view.html:28 +#: intervention/templates/intervention/detail-view.html:33 msgid "Run check" msgstr "Prüfung vornehmen" -#: intervention/templates/intervention/detail-view.html:33 +#: intervention/templates/intervention/detail-view.html:38 msgid "Record" msgstr "Verzeichnen" -#: intervention/templates/intervention/detail-view.html:38 +#: intervention/templates/intervention/detail-view.html:43 msgid "Edit" msgstr "Bearbeiten" -#: intervention/templates/intervention/detail-view.html:43 +#: intervention/templates/intervention/detail-view.html:48 #: venv/lib/python3.7/site-packages/django/forms/formsets.py:391 msgid "Delete" msgstr "Löschen" -#: intervention/templates/intervention/detail-view.html:61 +#: intervention/templates/intervention/detail-view.html:66 msgid "Process type" msgstr "Verfahrenstyp" -#: intervention/templates/intervention/detail-view.html:69 +#: intervention/templates/intervention/detail-view.html:74 msgid "Registration office" msgstr "Zulassungsbehörde" -#: intervention/templates/intervention/detail-view.html:73 +#: intervention/templates/intervention/detail-view.html:78 msgid "Registration office file number" msgstr "Aktenzeichen Zulassungsbehörde" -#: intervention/templates/intervention/detail-view.html:77 +#: intervention/templates/intervention/detail-view.html:82 msgid "Conservation office" msgstr "Naturschutzbehörde" -#: intervention/templates/intervention/detail-view.html:81 +#: intervention/templates/intervention/detail-view.html:86 msgid "Conversation office file number" msgstr "Aktenzeichen Naturschutzbehörde" -#: intervention/templates/intervention/detail-view.html:117 +#: intervention/templates/intervention/detail-view.html:122 msgid "Registration date" msgstr "Datum Zulassung bzw. Satzungsbeschluss" -#: intervention/templates/intervention/detail-view.html:121 +#: intervention/templates/intervention/detail-view.html:126 msgid "Binding on" msgstr "Datum Bestandskraft" -#: intervention/templates/intervention/detail-view.html:125 +#: intervention/templates/intervention/detail-view.html:130 msgid "Last modified" msgstr "Zuletzt bearbeitet" -#: intervention/templates/intervention/detail-view.html:129 +#: intervention/templates/intervention/detail-view.html:134 msgid "by" msgstr "von" -#: intervention/templates/intervention/detail-view.html:138 +#: intervention/templates/intervention/detail-view.html:143 msgid "No geometry added, yet." msgstr "Keine Geometrie vorhanden" -#: intervention/templates/intervention/detail-view.html:159 +#: intervention/templates/intervention/detail-view.html:164 msgid "Add new compensation" msgstr "Neue Kompensation hinzufügen" -#: intervention/templates/intervention/detail-view.html:204 +#: intervention/templates/intervention/detail-view.html:209 msgid "Payments" msgstr "Ersatzzahlungen" -#: intervention/templates/intervention/detail-view.html:209 +#: intervention/templates/intervention/detail-view.html:214 msgid "Add new payment" msgstr "Neue Zahlung hinzufügen" -#: intervention/templates/intervention/detail-view.html:224 +#: intervention/templates/intervention/detail-view.html:229 msgid "Amount" msgstr "Betrag" -#: intervention/templates/intervention/detail-view.html:227 +#: intervention/templates/intervention/detail-view.html:232 msgid "Transfer comment" msgstr "Verwendungszweck" -#: intervention/templates/intervention/detail-view.html:256 +#: intervention/templates/intervention/detail-view.html:261 msgid "Documents" msgstr "Dokumente" -#: intervention/templates/intervention/detail-view.html:261 +#: intervention/templates/intervention/detail-view.html:266 msgid "Add new document" msgstr "Neues Dokument hinzufügen" -#: intervention/templates/intervention/detail-view.html:279 +#: intervention/templates/intervention/detail-view.html:284 msgid "Comment" msgstr "Kommentar" -#: intervention/templates/intervention/detail-view.html:282 +#: intervention/templates/intervention/detail-view.html:287 msgid "Action" msgstr "Aktionen" -#: intervention/templates/intervention/detail-view.html:297 +#: intervention/templates/intervention/detail-view.html:301 konova/forms.py:145 msgid "Remove document" msgstr "Dokument löschen" @@ -353,22 +353,26 @@ msgstr "Hierfür müssen Sie Administrator sein!" msgid "You need to be part of another user group." msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!" -#: konova/forms.py:44 +#: konova/forms.py:46 msgid "Not editable" msgstr "Nicht editierbar" -#: konova/forms.py:70 +#: konova/forms.py:72 konova/forms.py:136 msgid "Confirm" -msgstr "Bestätigen" +msgstr "Bestätige" -#: konova/forms.py:82 +#: konova/forms.py:84 msgid "Remove" msgstr "Entferne" -#: konova/forms.py:84 +#: konova/forms.py:86 msgid "You are about to remove {} {}" msgstr "Sie sind dabei {} {} zu löschen" +#: konova/forms.py:146 +msgid "This will remove '{}'. Are you sure?" +msgstr "Hiermit wird '{}' gelöscht. Sind Sie sicher?" + #: konova/management/commands/setup_data.py:42 msgid "On new related data" msgstr "Wenn neue Daten für mich angelegt werden" @@ -421,11 +425,13 @@ msgstr "Ökokonto" msgid "Withdraw" msgstr "Abbuchen" -#: konova/views.py:118 -#, fuzzy -#| msgid "Document identifier" +#: konova/views.py:133 msgid "Document '{}' deleted" -msgstr "Aktenzeichen" +msgstr "Dokument '{}' gelöscht" + +#: konova/views.py:139 +msgid "There was an error on this form." +msgstr "Es gab einen Fehler im Formular." #: news/templates/news/dashboard-news.html:12 news/templates/news/index.html:19 msgid "Published on" @@ -467,6 +473,10 @@ msgstr "Abbrechen" msgid "Save" msgstr "Speichern" +#: templates/modal/modal_form.html:30 +msgid "Continue" +msgstr "Weiter" + #: templates/navbar.html:4 msgid "Kompensationsverzeichnis Service Portal" msgstr "" diff --git a/requirements.txt b/requirements.txt index e3f3ce4..c0e6822 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ certifi==2020.11.8 chardet==3.0.4 Django==3.1.3 django-autocomplete-light==3.8.1 +django-bootstrap-modal-forms==2.2.0 django-bootstrap4==3.0.1 django-debug-toolbar==3.1.1 django-filter==2.4.0 diff --git a/templates/base.html b/templates/base.html index 16aff7c..f1a713c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,6 +8,10 @@ {% bootstrap_javascript jquery='full' %} {% fontawesome_5_static %} + {% comment %} + Adds script for modal rendering + {% endcomment %} + {% block head %} {% endblock %} @@ -27,6 +31,15 @@ {% endfor %} + {% comment %} + The modal wrapper, which can be used on every view can stay on the base.html template + {% endcomment %} + + {% block body %} {% endblock %} diff --git a/templates/modal/modal_form.html b/templates/modal/modal_form.html new file mode 100644 index 0000000..82e65c3 --- /dev/null +++ b/templates/modal/modal_form.html @@ -0,0 +1,32 @@ +{% load i18n %} +{% comment %} + A generic modal form template which is based on django-bootstrap-modal-forms package + https://pypi.org/project/django-bootstrap-modal-forms/ +{% endcomment %} + + +
+ {% csrf_token %} + + + + +
\ No newline at end of file diff --git a/templates/modal/modal_form_script.html b/templates/modal/modal_form_script.html new file mode 100644 index 0000000..1dda207 --- /dev/null +++ b/templates/modal/modal_form_script.html @@ -0,0 +1,18 @@ +{% comment %} + Taken from https://github.com/trco/django-bootstrap-modal-forms + + isDeleteForm refers to reloading the whole page after submitting the form in our case. + +{% endcomment %} + + \ No newline at end of file