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
This commit is contained in:
mipel 2021-07-22 16:06:13 +02:00
parent ff11051fbb
commit 82be1511db
5 changed files with 44 additions and 31 deletions

View File

@ -122,6 +122,9 @@
</div> </div>
</div> </div>
<div class="col-sm-12 col-md-12 col-lg-6"> <div class="col-sm-12 col-md-12 col-lg-6">
{% if geom_form.area == 0 %}
<div class="alert alert-info">{% trans 'No geometry added, yet.' %}</div>
{% endif %}
{{geom_form.media}} {{geom_form.media}}
{{geom_form.geom}} {{geom_form.geom}}
</div> </div>

View File

@ -88,9 +88,6 @@ def open_view(request: HttpRequest, id: str):
intervention = get_object_or_404(Intervention, id=id) intervention = get_object_or_404(Intervention, id=id)
has_access = intervention.has_access(user=request.user) 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( geom_form = SimpleGeomForm(
instance=intervention instance=intervention
) )
@ -100,6 +97,10 @@ def open_view(request: HttpRequest, id: str):
"has_access": has_access, "has_access": has_access,
"geom_form": geom_form, "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 context = BaseContext(request, context).context
return render(request, template, context) return render(request, template, context)

View File

@ -10,7 +10,8 @@ from abc import abstractmethod
from django import forms from django import forms
from django.contrib.auth.models import User 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 import timezone
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -101,6 +102,8 @@ class SimpleGeomForm(BaseForm):
""" """
geom = GeometryField( geom = GeometryField(
required=False,
disabled=True,
widget=OSMWidget( widget=OSMWidget(
attrs={ attrs={
"map_width": 600, "map_width": 600,
@ -110,15 +113,17 @@ class SimpleGeomForm(BaseForm):
) )
def __init__(self, *args, **kwargs): 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) 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.initialize_form_field("geom", geom)
self.disable_form_field("geom") self.area = geom.area

Binary file not shown.

View File

@ -4,14 +4,14 @@
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#: intervention/filters.py:25 intervention/filters.py:31 #: 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 #: user/forms.py:38
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -23,14 +23,14 @@ msgstr ""
#: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26 #: compensation/tables.py:18 compensation/tables.py:71 intervention/forms.py:26
#: intervention/tables.py:23 #: intervention/tables.py:23
#: intervention/templates/intervention/detail-view.html:159 #: intervention/templates/intervention/detail-view.html:162
msgid "Identifier" msgid "Identifier"
msgstr "Kennung" msgstr "Kennung"
#: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33 #: compensation/tables.py:23 compensation/tables.py:76 intervention/forms.py:33
#: intervention/tables.py:28 #: intervention/tables.py:28
#: intervention/templates/intervention/detail-view.html:57 #: intervention/templates/intervention/detail-view.html:57
#: intervention/templates/intervention/detail-view.html:162 #: intervention/templates/intervention/detail-view.html:165
msgid "Title" msgid "Title"
msgstr "Bezeichnung" msgstr "Bezeichnung"
@ -43,7 +43,7 @@ msgid "Actions"
msgstr "Aktionen" msgstr "Aktionen"
#: compensation/tables.py:44 #: compensation/tables.py:44
#: intervention/templates/intervention/detail-view.html:139 #: intervention/templates/intervention/detail-view.html:142
msgid "Compensations" msgid "Compensations"
msgstr "Kompensationen" msgstr "Kompensationen"
@ -268,23 +268,27 @@ msgstr "Zuletzt bearbeitet"
msgid "by" msgid "by"
msgstr "von" 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" msgid "Add new compensation"
msgstr "Neue Kompensation hinzufügen" msgstr "Neue Kompensation hinzufügen"
#: intervention/templates/intervention/detail-view.html:189 #: intervention/templates/intervention/detail-view.html:192
msgid "Payments" msgid "Payments"
msgstr "Ersatzzahlungen" msgstr "Ersatzzahlungen"
#: intervention/templates/intervention/detail-view.html:194 #: intervention/templates/intervention/detail-view.html:197
msgid "Add new payment" msgid "Add new payment"
msgstr "Neue Zahlung hinzufügen" msgstr "Neue Zahlung hinzufügen"
#: intervention/templates/intervention/detail-view.html:209 #: intervention/templates/intervention/detail-view.html:212
msgid "Amount" msgid "Amount"
msgstr "Betrag" msgstr "Betrag"
#: intervention/templates/intervention/detail-view.html:212 #: intervention/templates/intervention/detail-view.html:215
msgid "Transfer comment" msgid "Transfer comment"
msgstr "Verwendungszweck" msgstr "Verwendungszweck"
@ -292,11 +296,11 @@ msgstr "Verwendungszweck"
msgid "Intervention {} added" msgid "Intervention {} added"
msgstr "Eingriff {} hinzugefügt" msgstr "Eingriff {} hinzugefügt"
#: intervention/views.py:65 intervention/views.py:127 #: intervention/views.py:65 intervention/views.py:128
msgid "Invalid input" msgid "Invalid input"
msgstr "Eingabe fehlerhaft" msgstr "Eingabe fehlerhaft"
#: intervention/views.py:92 #: intervention/views.py:102
msgid "" msgid ""
"Remember: This data has not been shared with you, yet. This means you can " "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 " "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, " "bedeutet, dass Sie nur lesenden Zugriff hierauf haben und weder bearbeiten, "
"noch Prüfungen durchführen oder verzeichnen können." "noch Prüfungen durchführen oder verzeichnen können."
#: intervention/views.py:124 #: intervention/views.py:125
msgid "{} edited" msgid "{} edited"
msgstr "{} bearbeitet" msgstr "{} bearbeitet"
@ -322,19 +326,19 @@ msgstr "Hierfür müssen Sie Administrator sein!"
msgid "You need to be part of another user group." msgid "You need to be part of another user group."
msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!" msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
#: konova/forms.py:43 #: konova/forms.py:46
msgid "Not editable" msgid "Not editable"
msgstr "Nicht editierbar" msgstr "Nicht editierbar"
#: konova/forms.py:69 #: konova/forms.py:72
msgid "Confirm" msgid "Confirm"
msgstr "Bestätigen" msgstr "Bestätigen"
#: konova/forms.py:81 #: konova/forms.py:84
msgid "Remove" msgid "Remove"
msgstr "Entferne" msgstr "Entferne"
#: konova/forms.py:83 #: konova/forms.py:86
msgid "You are about to remove {} {}" msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen" msgstr "Sie sind dabei {} {} zu löschen"