From d1db559f3363116f4b7b0ffd961e5e20980de195 Mon Sep 17 00:00:00 2001 From: mipel Date: Mon, 26 Jul 2021 14:35:19 +0200 Subject: [PATCH] Template restructuring * splits large templates into smaller includes * removes localized form input for payments * refactors Document removing using the generic remove form --- compensation/forms.py | 1 - .../templates/intervention/detail-view.html | 328 ------------------ .../detail/related-documents.html | 61 ++++ .../intervention/detail/related-objects.html | 113 ++++++ .../templates/intervention/detail/view.html | 159 +++++++++ intervention/views.py | 2 +- konova/views.py | 4 +- 7 files changed, 336 insertions(+), 332 deletions(-) delete mode 100644 intervention/templates/intervention/detail-view.html create mode 100644 intervention/templates/intervention/detail/related-documents.html create mode 100644 intervention/templates/intervention/detail/related-objects.html create mode 100644 intervention/templates/intervention/detail/view.html diff --git a/compensation/forms.py b/compensation/forms.py index 9c435644..a86fbb6b 100644 --- a/compensation/forms.py +++ b/compensation/forms.py @@ -26,7 +26,6 @@ class NewPaymentForm(BaseModalForm): label=_("Amount"), label_suffix=_(""), help_text=_("Amount in Euro"), - localize=True, ) due = forms.DateField( label=_("Due on"), diff --git a/intervention/templates/intervention/detail-view.html b/intervention/templates/intervention/detail-view.html deleted file mode 100644 index 444a0f2d..00000000 --- a/intervention/templates/intervention/detail-view.html +++ /dev/null @@ -1,328 +0,0 @@ -{% extends 'base.html' %} -{% load i18n l10n static fontawesome_5 humanize %} - -{% block head %} - -{% endblock %} - -{% block body %} - -
-
-

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

-
- -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% trans 'Title' %}{{intervention.title}}
{% trans 'Process type' %}{{intervention.process_type|default_if_none:""}}
{% trans 'Law' %}{{intervention.law|default_if_none:""}}
{% trans 'Registration office' %}{{intervention.registration_office|default_if_none:""}}
{% trans 'Registration office file number' %}{{intervention.registration_file_number|default_if_none:""}}
{% trans 'Conservation office' %}{{intervention.conservation_office|default_if_none:""}}
{% trans 'Conversation office file number' %}{{intervention.conservation_file_number|default_if_none:""}}
{% trans 'Intervention handler' %}{{intervention.handler|default_if_none:""}}
{% trans 'Checked' %} - {% if intervention.checked_on is None %} - - {% fa5_icon 'star' 'far' %} - - {% else %} - - {% fa5_icon 'star' %} - - {% endif %} -
{% trans 'Recorded' %} - {% if intervention.recorded_on is None %} - - {% fa5_icon 'bookmark' 'far' %} - - {% else %} - - {% fa5_icon 'bookmark' %} - - {% endif %} -
{% trans 'Registration date' %}{{intervention.registration_date|default_if_none:""}}
{% trans 'Binding on' %}{{intervention.binding_on|default_if_none:""}}
{% trans 'Last modified' %} - {{intervention.created_on|default_if_none:""|naturalday}} -
- {% trans 'by' %} - {{intervention.created_by|default_if_none:""}} -
-
-
-
- {% if geom_form.area == 0 %} -
{% trans 'No geometry added, yet.' %}
- {% endif %} - {{geom_form.media}} - {{geom_form.geom}} -
-
-
- - - - -{% with 'btn-modal' as btn_class %} - {% include 'modal/modal_form_script.html' %} -{% endwith %} - -{% endblock %} \ No newline at end of file diff --git a/intervention/templates/intervention/detail/related-documents.html b/intervention/templates/intervention/detail/related-documents.html new file mode 100644 index 00000000..20ab0633 --- /dev/null +++ b/intervention/templates/intervention/detail/related-documents.html @@ -0,0 +1,61 @@ +{% load i18n l10n fontawesome_5 %} + \ No newline at end of file diff --git a/intervention/templates/intervention/detail/related-objects.html b/intervention/templates/intervention/detail/related-objects.html new file mode 100644 index 00000000..bca9f45e --- /dev/null +++ b/intervention/templates/intervention/detail/related-objects.html @@ -0,0 +1,113 @@ +{% load i18n l10n fontawesome_5 %} + diff --git a/intervention/templates/intervention/detail/view.html b/intervention/templates/intervention/detail/view.html new file mode 100644 index 00000000..9cddd4a5 --- /dev/null +++ b/intervention/templates/intervention/detail/view.html @@ -0,0 +1,159 @@ +{% extends 'base.html' %} +{% load i18n l10n static fontawesome_5 humanize %} + +{% block head %} + +{% endblock %} + +{% block body %} + +
+
+

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

+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{% trans 'Title' %}{{intervention.title}}
{% trans 'Process type' %}{{intervention.process_type|default_if_none:""}}
{% trans 'Law' %}{{intervention.law|default_if_none:""}}
{% trans 'Registration office' %}{{intervention.registration_office|default_if_none:""}}
{% trans 'Registration office file number' %}{{intervention.registration_file_number|default_if_none:""}}
{% trans 'Conservation office' %}{{intervention.conservation_office|default_if_none:""}}
{% trans 'Conversation office file number' %}{{intervention.conservation_file_number|default_if_none:""}}
{% trans 'Intervention handler' %}{{intervention.handler|default_if_none:""}}
{% trans 'Checked' %} + {% if intervention.checked_on is None %} + + {% fa5_icon 'star' 'far' %} + + {% else %} + + {% fa5_icon 'star' %} + + {% endif %} +
{% trans 'Recorded' %} + {% if intervention.recorded_on is None %} + + {% fa5_icon 'bookmark' 'far' %} + + {% else %} + + {% fa5_icon 'bookmark' %} + + {% endif %} +
{% trans 'Registration date' %}{{intervention.registration_date|default_if_none:""}}
{% trans 'Binding on' %}{{intervention.binding_on|default_if_none:""}}
{% trans 'Last modified' %} + {{intervention.created_on|default_if_none:""|naturalday}} +
+ {% trans 'by' %} + {{intervention.created_by|default_if_none:""}} +
+
+
+
+ {% if geom_form.area == 0 %} +
{% trans 'No geometry added, yet.' %}
+ {% endif %} + {{geom_form.media}} + {{geom_form.geom}} +
+
+
+ + {% include 'intervention/detail/related-objects.html' %} + {% include 'intervention/detail/related-documents.html' %} + + +{% with 'btn-modal' as btn_class %} + {% include 'modal/modal_form_script.html' %} +{% endwith %} + +{% endblock %} \ No newline at end of file diff --git a/intervention/views.py b/intervention/views.py index 131acbde..a7c8481c 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -84,7 +84,7 @@ def open_view(request: HttpRequest, id: str): Returns: """ - template = "intervention/detail-view.html" + template = "intervention/detail/view.html" intervention = get_object_or_404(Intervention, id=id) has_access = intervention.has_access(user=request.user) diff --git a/konova/views.py b/konova/views.py index 68c8fdd7..b7f2087e 100644 --- a/konova/views.py +++ b/konova/views.py @@ -14,7 +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.forms import RemoveModalForm from konova.models import Document from news.models import ServerMessage from konova.settings import SSO_SERVER_BASE @@ -122,7 +122,7 @@ def remove_document_view(request: HttpRequest, id: str): template = "modal/modal_form.html" doc = get_object_or_404(Document, id=id) title = doc.title - form = RemoveDocumentForm(request.POST or None, instance=doc) + form = RemoveModalForm(request.POST or None, instance=doc, user=request.user) if request.method == "POST": if form.is_valid(): doc.delete()