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 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.geom}}
</div>

View File

@ -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)

View File

@ -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)
# 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

Binary file not shown.

View File

@ -4,14 +4,14 @@
# FIRST AUTHOR <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\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
#: 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"