From 82be1511db7ec01a61bf1bcb3a4aeaf1d89bc194 Mon Sep 17 00:00:00 2001 From: mipel Date: Thu, 22 Jul 2021 16:06:13 +0200 Subject: [PATCH] Intervention Detail View * adds hint for empty map in case of missing geometry * adds empty geometry workaround, so openlayers is rendered without digitalization tools * adds translations --- .../templates/intervention/detail-view.html | 3 ++ intervention/views.py | 7 ++-- konova/forms.py | 27 ++++++++----- locale/de/LC_MESSAGES/django.mo | Bin 7777 -> 7843 bytes locale/de/LC_MESSAGES/django.po | 38 ++++++++++-------- 5 files changed, 44 insertions(+), 31 deletions(-) diff --git a/intervention/templates/intervention/detail-view.html b/intervention/templates/intervention/detail-view.html index 7700b516..8c0e6df2 100644 --- a/intervention/templates/intervention/detail-view.html +++ b/intervention/templates/intervention/detail-view.html @@ -122,6 +122,9 @@
+ {% if geom_form.area == 0 %} +
{% trans 'No geometry added, yet.' %}
+ {% endif %} {{geom_form.media}} {{geom_form.geom}}
diff --git a/intervention/views.py b/intervention/views.py index 70b04609..49ae0c3f 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -88,9 +88,6 @@ def open_view(request: HttpRequest, id: str): intervention = get_object_or_404(Intervention, id=id) has_access = intervention.has_access(user=request.user) - if not has_access: - messages.info(request, _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording.")) - geom_form = SimpleGeomForm( instance=intervention ) @@ -100,6 +97,10 @@ def open_view(request: HttpRequest, id: str): "has_access": has_access, "geom_form": geom_form, } + + if not has_access: + messages.info(request, _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording.")) + context = BaseContext(request, context).context return render(request, template, context) diff --git a/konova/forms.py b/konova/forms.py index b5198fa6..31bafa09 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -10,7 +10,8 @@ from abc import abstractmethod from django import forms from django.contrib.auth.models import User -from django.contrib.gis.forms import GeometryField, OSMWidget, MultiPolygonField +from django.contrib.gis.forms import GeometryField, OSMWidget +from django.contrib.gis.geos import Polygon from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -101,6 +102,8 @@ class SimpleGeomForm(BaseForm): """ geom = GeometryField( + required=False, + disabled=True, widget=OSMWidget( attrs={ "map_width": 600, @@ -110,15 +113,17 @@ class SimpleGeomForm(BaseForm): ) def __init__(self, *args, **kwargs): - """ - Constructor does not need to perform further initial setup, like other forms. - We simply use this here for easy rendering of a geometry view component - - Args: - *args (): - **kwargs (): - """ super().__init__(*args, **kwargs) - geom = self.instance.geometry.geom + + # Initialize geometry + try: + geom = self.instance.geometry.geom + if geom is None: + raise AttributeError + except AttributeError: + # catches if no geometry has been added, yet. Replace with empty placeholder polygon. + geom = Polygon.from_bbox([0, 0, 0, 0]) + # Zoom out to a very high level, so the user can see directly that there is no geometry for this entry + self.fields["geom"].widget.attrs["default_zoom"] = 1 self.initialize_form_field("geom", geom) - self.disable_form_field("geom") + self.area = geom.area diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 725ccf0371b8a97e2f4669b912cfbf74170bd97b..0db3be9ea43e65b269c6a08e229cb3bf173cfe62 100644 GIT binary patch delta 2567 zcmXxkdrZ}39LMo5iE=R#xr7ktQ5F~F;sul_G$9bBloSn7%OmHYh;W3EfNH-@x8|tj z+|kx%qczu!{u2D7Hgwqr4mMr4t=ZJ9wpvEat+upU_5Q%aZ+y?|d4A9D_gucu^W*!+ z&X##M6CzI=S1*xHOw2Mni^Ea;a8<{eg>fS$;0;vM9ZbTzI1l6In(?Y-;2d0x_hSy~ zy<+51t9I?%FyG9x1`11PIF9Q0BTU30R0o$a4!?HoKe+bWuKq7BqJ0hzYv3%@K>4Wm zN-!C#T>EZ}q27qmjBl+J__Hp4=*x~_B%Z+ecnYFQGa-i4Wo# zR3-*76-RLa-g52taB7@+uDuI2poiM3H&6qA zfI1Vy*pJsy@4d)sHO^7g!u#UMzh-`hno{&G>cIh2N9UX)SVsLCYGNsjrakwe-pfMW zUxu1+5o#gjsOPpgw2c125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KXhqGu8}slbEW;D12Y>MU7jYK#5c{I`1z3(9sONfd z0=|Npz-y?L9>e+s&I%r-{wJ#}!Jvh zjk(z3_t&Am_f4pY?C|<-uOIMwFKV1uQ44(w)Aap+NkQNJ2r{<)jGD*#qbr?Z)kmvR3ZaHeA zx1t7IfXYw<>hLwAQo9oM+tE4a3&6;2FPGvw8DJUUYDXWSB=VS6KcG6)Hs`S$-fFub3>D1m&LuIy#pV_z^HO@XPz=Q1+N+=BC zJUoZWK=!ow3hGb;G@=G*LCrjhe9mK++I4LuwEr~O7NR-!T}mXhky0_SJ$5xEvSt~j zIfTY)Bb1f<2yJr}q3h;2)````T4E8=LM$hg0A0~IV`oao;z8oE*tXRC;2ui)FQgRd zQ{jNy4&pZAZbGTKlh{U#Uk_2Zmw1$Tl2}cY5z5Z^)j?q{v6xsvu-(>0Y$6^Z>WLfm z+7lESh(@A@C?ML2BH|8WA)#wYtS(fXzLU~=;$dP#Y-?yr&`oLlQo7f9<#tzxRom3$ z^;RtOaxJbTmJ+Lo`w4x9d`x548h&pfX2q+v86PJqy$(9NW_QIx;TZ`J4Aq9eO&luA M=nM}X&$&GDf0<;@`2YX_ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 2af3bcc5..4d480dbe 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:70 +#: intervention/filters.py:38 intervention/filters.py:39 konova/forms.py:73 #: user/forms.py:38 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-07-22 14:57+0200\n" +"POT-Creation-Date: 2021-07-22 16:04+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -23,14 +23,14 @@ msgstr "" #: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26 #: intervention/tables.py:23 -#: intervention/templates/intervention/detail-view.html:159 +#: intervention/templates/intervention/detail-view.html:162 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:162 +#: intervention/templates/intervention/detail-view.html:165 msgid "Title" msgstr "Bezeichnung" @@ -43,7 +43,7 @@ msgid "Actions" msgstr "Aktionen" #: compensation/tables.py:44 -#: intervention/templates/intervention/detail-view.html:139 +#: intervention/templates/intervention/detail-view.html:142 msgid "Compensations" msgstr "Kompensationen" @@ -268,23 +268,27 @@ msgstr "Zuletzt bearbeitet" msgid "by" msgstr "von" -#: intervention/templates/intervention/detail-view.html:144 +#: intervention/templates/intervention/detail-view.html:126 +msgid "No geometry added, yet." +msgstr "Keine Geometrie vorhanden" + +#: intervention/templates/intervention/detail-view.html:147 msgid "Add new compensation" msgstr "Neue Kompensation hinzufügen" -#: intervention/templates/intervention/detail-view.html:189 +#: intervention/templates/intervention/detail-view.html:192 msgid "Payments" msgstr "Ersatzzahlungen" -#: intervention/templates/intervention/detail-view.html:194 +#: intervention/templates/intervention/detail-view.html:197 msgid "Add new payment" msgstr "Neue Zahlung hinzufügen" -#: intervention/templates/intervention/detail-view.html:209 +#: intervention/templates/intervention/detail-view.html:212 msgid "Amount" msgstr "Betrag" -#: intervention/templates/intervention/detail-view.html:212 +#: intervention/templates/intervention/detail-view.html:215 msgid "Transfer comment" msgstr "Verwendungszweck" @@ -292,11 +296,11 @@ msgstr "Verwendungszweck" msgid "Intervention {} added" msgstr "Eingriff {} hinzugefügt" -#: intervention/views.py:65 intervention/views.py:127 +#: intervention/views.py:65 intervention/views.py:128 msgid "Invalid input" msgstr "Eingabe fehlerhaft" -#: intervention/views.py:92 +#: intervention/views.py:102 msgid "" "Remember: This data has not been shared with you, yet. This means you can " "only read but can not edit or perform any actions like running a check or " @@ -306,7 +310,7 @@ msgstr "" "bedeutet, dass Sie nur lesenden Zugriff hierauf haben und weder bearbeiten, " "noch Prüfungen durchführen oder verzeichnen können." -#: intervention/views.py:124 +#: intervention/views.py:125 msgid "{} edited" msgstr "{} bearbeitet" @@ -322,19 +326,19 @@ 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:43 +#: konova/forms.py:46 msgid "Not editable" msgstr "Nicht editierbar" -#: konova/forms.py:69 +#: konova/forms.py:72 msgid "Confirm" msgstr "Bestätigen" -#: konova/forms.py:81 +#: konova/forms.py:84 msgid "Remove" msgstr "Entferne" -#: konova/forms.py:83 +#: konova/forms.py:86 msgid "You are about to remove {} {}" msgstr "Sie sind dabei {} {} zu löschen"