#49 Frontend rendering

* adds rendering for detail view
* adds new includable html snippet for parcel rendering
* refactors generic includables in konova/ app into konova/templates/includes/...
* fixes bug where parcels have been reused from the database due to wrong model structure
* adds get_underlying_parcels() for Geometry model
* adds get_underlying_parcels() for GeoReferencedMixin models
* fixes bug where missing geometry would lead to an error during geometry conflict check
* removes unused wfs attribute from AbstractWFSFetcher
* adds/updates translations
This commit is contained in:
mpeltriaux 2022-01-05 14:13:26 +01:00
parent b43beffc6b
commit 49859d17d2
20 changed files with 183 additions and 75 deletions

View File

@ -170,7 +170,7 @@ class AbstractCompensation(BaseObject, GeoReferencedMixin):
"""
if not self.is_shared_with(request.user):
messages.info(request, DATA_UNSHARED_EXPLANATION)
request = self._set_geometry_conflict_message(request)
request = self.set_geometry_conflict_message(request)
return request

View File

@ -110,7 +110,10 @@
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'konova/comment_card.html' %}
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row">
{% include 'konova/includes/comment_card.html' %}
</div>
</div>
</div>

View File

@ -93,7 +93,10 @@
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'konova/comment_card.html' %}
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row">
{% include 'konova/includes/comment_card.html' %}
</div>
</div>
</div>

View File

@ -170,6 +170,7 @@ def detail_view(request: HttpRequest, id: str):
template = "compensation/detail/compensation/view.html"
comp = get_object_or_404(Compensation, id=id)
geom_form = SimpleGeomForm(instance=comp)
parcels = comp.get_underlying_parcels()
_user = request.user
is_data_shared = comp.intervention.is_shared_with(_user)
@ -189,6 +190,7 @@ def detail_view(request: HttpRequest, id: str):
context = {
"obj": comp,
"geom_form": geom_form,
"parcels": parcels,
"has_access": is_data_shared,
"actions": actions,
"before_states": before_states,

View File

@ -181,6 +181,7 @@ def detail_view(request: HttpRequest, id: str):
id=id
)
geom_form = SimpleGeomForm(instance=acc)
parcels = acc.get_underlying_parcels()
_user = request.user
is_data_shared = acc.is_shared_with(_user)
@ -207,6 +208,7 @@ def detail_view(request: HttpRequest, id: str):
context = {
"obj": acc,
"geom_form": geom_form,
"parcels": parcels,
"has_access": is_data_shared,
"before_states": before_states,
"after_states": after_states,

View File

@ -106,7 +106,7 @@ class Ema(AbstractCompensation, ShareableObjectMixin, RecordableObjectMixin):
"""
if not self.is_shared_with(request.user):
messages.info(request, DATA_UNSHARED_EXPLANATION)
self._set_geometry_conflict_message(request)
self.set_geometry_conflict_message(request)
return request

View File

@ -77,7 +77,15 @@
</div>
</div>
<div class="col-sm-12 col-md-12 col-lg-6">
<div class="row">
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row">
{% include 'konova/includes/comment_card.html' %}
</div>
</div>
</div>
<hr>

View File

@ -125,6 +125,7 @@ def detail_view(request: HttpRequest, id: str):
ema = get_object_or_404(Ema, id=id, deleted=None)
geom_form = SimpleGeomForm(instance=ema)
parcels = ema.get_underlying_parcels()
_user = request.user
is_data_shared = ema.is_shared_with(_user)
@ -143,6 +144,7 @@ def detail_view(request: HttpRequest, id: str):
context = {
"obj": ema,
"geom_form": geom_form,
"parcels": parcels,
"has_access": is_data_shared,
"before_states": before_states,
"after_states": after_states,

View File

@ -278,7 +278,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
"""
if not self.is_shared_with(request.user):
messages.info(request, DATA_UNSHARED_EXPLANATION)
request = self._set_geometry_conflict_message(request)
request = self.set_geometry_conflict_message(request)
return request

View File

@ -127,7 +127,10 @@
{% include 'map/geom_form.html' %}
</div>
<div class="row">
{% include 'konova/comment_card.html' %}
{% include 'konova/includes/parcels.html' %}
</div>
<div class="row">
{% include 'konova/includes/comment_card.html' %}
</div>
</div>
</div>

View File

@ -236,6 +236,8 @@ def detail_view(request: HttpRequest, id: str):
instance=intervention,
)
parcels = intervention.get_underlying_parcels()
# Inform user about revocation
if intervention.legal.revocations.exists():
messages.error(
@ -249,6 +251,7 @@ def detail_view(request: HttpRequest, id: str):
"compensations": compensations,
"has_access": is_data_shared,
"geom_form": geom_form,
"parcels": parcels,
"is_default_member": in_group(_user, DEFAULT_GROUP),
"is_zb_member": in_group(_user, ZB_GROUP),
"is_ets_member": in_group(_user, ETS_GROUP),

View File

@ -20,6 +20,7 @@ class GeometryAdmin(admin.ModelAdmin):
class ParcelAdmin(admin.ModelAdmin):
list_display = [
"id",
"gmrkng",
"flr",
"flrstck_nnr",
"flrstck_zhlr",
@ -30,7 +31,6 @@ class ParcelAdmin(admin.ModelAdmin):
class DistrictAdmin(admin.ModelAdmin):
list_display = [
"id",
"gmrkng",
"gmnd",
"krs",
]

View File

@ -111,12 +111,12 @@ class Geometry(BaseResource):
for result in fetched_parcels:
fetched_parcel = result[typename]
parcel_obj = Parcel.objects.get_or_create(
gmrkng=fetched_parcel["ave:gemarkung"],
flr=fetched_parcel["ave:flur"],
flrstck_nnr=fetched_parcel['ave:flstnrnen'],
flrstck_zhlr=fetched_parcel['ave:flstnrzae'],
)[0]
district = District.objects.get_or_create(
gmrkng=fetched_parcel["ave:gemarkung"],
gmnd=fetched_parcel["ave:gemeinde"],
krs=fetched_parcel["ave:kreis"],
)[0]
@ -127,6 +127,20 @@ class Geometry(BaseResource):
self.parcels.set(underlying_parcels)
def get_underlying_parcels(self):
""" Getter for related parcels and their districts
Returns:
parcels (QuerySet): The related parcels as queryset
"""
parcels = self.parcels.all().prefetch_related(
"district"
).order_by(
"gmrkng",
)
return parcels
class GeometryConflict(UuidModel):
"""

View File

@ -420,13 +420,29 @@ class GeoReferencedMixin(models.Model):
class Meta:
abstract = True
def _set_geometry_conflict_message(self, request: HttpRequest):
def get_underlying_parcels(self):
""" Getter for related parcels
Returns:
parcels (Iterable): An empty list or a Queryset
"""
if self.geometry is not None:
return self.geometry.get_underlying_parcels()
else:
return []
def set_geometry_conflict_message(self, request: HttpRequest):
if self.geometry is None:
return request
instance_objs = []
add_message = False
conflicts = self.geometry.conflicts_geometries.all()
for conflict in conflicts:
instance_objs += conflict.affected_geometry.get_data_objects()
add_message = True
conflicts = self.geometry.conflicted_by_geometries.all()
for conflict in conflicts:
instance_objs += conflict.conflicting_geometry.get_data_objects()

View File

@ -24,6 +24,12 @@ class Parcel(UuidModel):
"""
geometries = models.ManyToManyField("konova.Geometry", related_name="parcels", blank=True)
district = models.ForeignKey("konova.District", on_delete=models.SET_NULL, null=True, blank=True, related_name="parcels")
gmrkng = models.CharField(
max_length=1000,
help_text="Gemarkung",
null=True,
blank=True,
)
flrstck_nnr = models.CharField(
max_length=1000,
help_text="Flurstücksnenner",
@ -45,7 +51,7 @@ class Parcel(UuidModel):
updated_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.flr} | {self.flrstck_nnr} | {self.flrstck_zhlr}"
return f"{self.gmrkng} | {self.flr} | {self.flrstck_zhlr} | {self.flrstck_nnr}"
class District(UuidModel):
@ -56,12 +62,6 @@ class District(UuidModel):
District.
"""
gmrkng = models.CharField(
max_length=1000,
help_text="Gemarkung",
null=True,
blank=True,
)
gmnd = models.CharField(
max_length=1000,
help_text="Gemeinde",
@ -76,4 +76,4 @@ class District(UuidModel):
)
def __str__(self):
return f"{self.gmrkng} | {self.gmnd} | {self.krs}"
return f"{self.gmnd} | {self.krs}"

View File

@ -0,0 +1,29 @@
{% load i18n %}
<div>
<h3>{% trans 'Spatial reference' %}</h3>
</div>
<div class="table-container w-100 scroll-300">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">{% trans 'Kreis' %}</th>
<th scope="col">{% trans 'Gemarkung' %}</th>
<th scope="col">{% trans 'Parcel' %}</th>
<th scope="col">{% trans 'Parcel counter' %}</th>
<th scope="col">{% trans 'Parcel number' %}</th>
</tr>
</thead>
<tbody>
{% for parcel in parcels %}
<tr>
<td>{{parcel.district.krs|default_if_none:"-"}}</td>
<td>{{parcel.gmrkng|default_if_none:"-"}}</td>
<td>{{parcel.flr|default_if_none:"-"}}</td>
<td>{{parcel.flrstck_zhlr|default_if_none:"-"}}</td>
<td>{{parcel.flrstck_nnr|default_if_none:"-"}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

View File

@ -22,7 +22,6 @@ class AbstractWFSFetcher:
# base_url represents not the capabilities url but the parameter-free base url
base_url = None
version = None
wfs = None
auth_user = None
auth_pw = None
auth_digest_obj = None

Binary file not shown.

View File

@ -11,15 +11,15 @@
#: intervention/forms/forms.py:52 intervention/forms/forms.py:154
#: intervention/forms/forms.py:166 intervention/forms/modalForms.py:125
#: intervention/forms/modalForms.py:138 intervention/forms/modalForms.py:151
#: konova/forms.py:139 konova/forms.py:240 konova/forms.py:308
#: konova/forms.py:335 konova/forms.py:345 konova/forms.py:358
#: konova/forms.py:370 konova/forms.py:388 user/forms.py:38
#: konova/forms.py:139 konova/forms.py:240 konova/forms.py:309
#: konova/forms.py:336 konova/forms.py:346 konova/forms.py:359
#: konova/forms.py:371 konova/forms.py:389 user/forms.py:38
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-16 09:17+0100\n"
"POT-Creation-Date: 2022-01-05 14:04+0100\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"
@ -329,7 +329,7 @@ msgstr "Automatisch generiert"
#: intervention/templates/intervention/detail/includes/documents.html:28
#: intervention/templates/intervention/detail/view.html:31
#: intervention/templates/intervention/report/report.html:12
#: konova/forms.py:334
#: konova/forms.py:335
msgid "Title"
msgstr "Bezeichnung"
@ -356,7 +356,7 @@ msgstr "Kompensation XY; Flur ABC"
#: intervention/templates/intervention/detail/includes/documents.html:31
#: intervention/templates/intervention/detail/includes/payments.html:34
#: intervention/templates/intervention/detail/includes/revocation.html:38
#: konova/forms.py:369 konova/templates/konova/comment_card.html:16
#: konova/forms.py:370 konova/templates/konova/includes/comment_card.html:16
msgid "Comment"
msgstr "Kommentar"
@ -472,7 +472,7 @@ msgstr "Zahlung wird an diesem Datum erwartet"
#: compensation/forms/modalForms.py:62 compensation/forms/modalForms.py:239
#: compensation/forms/modalForms.py:317 intervention/forms/modalForms.py:152
#: konova/forms.py:371
#: konova/forms.py:372
msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
@ -793,7 +793,7 @@ msgstr "Dokumente"
#: compensation/templates/compensation/detail/eco_account/includes/documents.html:14
#: ema/templates/ema/detail/includes/documents.html:14
#: intervention/templates/intervention/detail/includes/documents.html:14
#: konova/forms.py:387
#: konova/forms.py:388
msgid "Add new document"
msgstr "Neues Dokument hinzufügen"
@ -1056,41 +1056,41 @@ msgstr "Kompensation {} hinzugefügt"
msgid "Compensation {} edited"
msgstr "Kompensation {} bearbeitet"
#: compensation/views/compensation.py:228 compensation/views/eco_account.py:307
#: ema/views.py:181 intervention/views.py:474
#: compensation/views/compensation.py:230 compensation/views/eco_account.py:309
#: ema/views.py:181 intervention/views.py:477
msgid "Log"
msgstr "Log"
#: compensation/views/compensation.py:251
#: compensation/views/compensation.py:253
msgid "Compensation removed"
msgstr "Kompensation entfernt"
#: compensation/views/compensation.py:272 compensation/views/eco_account.py:459
#: compensation/views/compensation.py:274 compensation/views/eco_account.py:461
#: ema/views.py:348 intervention/views.py:129
msgid "Document added"
msgstr "Dokument hinzugefügt"
#: compensation/views/compensation.py:341 compensation/views/eco_account.py:353
#: compensation/views/compensation.py:343 compensation/views/eco_account.py:355
#: ema/views.py:286
msgid "State added"
msgstr "Zustand hinzugefügt"
#: compensation/views/compensation.py:362 compensation/views/eco_account.py:374
#: compensation/views/compensation.py:364 compensation/views/eco_account.py:376
#: ema/views.py:307
msgid "Action added"
msgstr "Maßnahme hinzugefügt"
#: compensation/views/compensation.py:383 compensation/views/eco_account.py:439
#: compensation/views/compensation.py:385 compensation/views/eco_account.py:441
#: ema/views.py:328
msgid "Deadline added"
msgstr "Frist/Termin hinzugefügt"
#: compensation/views/compensation.py:405 compensation/views/eco_account.py:396
#: compensation/views/compensation.py:407 compensation/views/eco_account.py:398
#: ema/views.py:418
msgid "State removed"
msgstr "Zustand gelöscht"
#: compensation/views/compensation.py:427 compensation/views/eco_account.py:418
#: compensation/views/compensation.py:429 compensation/views/eco_account.py:420
#: ema/views.py:440
msgid "Action removed"
msgstr "Maßnahme entfernt"
@ -1103,45 +1103,45 @@ msgstr "Ökokonto {} hinzugefügt"
msgid "Eco-Account {} edited"
msgstr "Ökokonto {} bearbeitet"
#: compensation/views/eco_account.py:255
#: compensation/views/eco_account.py:257
msgid "Eco-account removed"
msgstr "Ökokonto entfernt"
#: compensation/views/eco_account.py:283
#: compensation/views/eco_account.py:285
msgid "Deduction removed"
msgstr "Abbuchung entfernt"
#: compensation/views/eco_account.py:328 ema/views.py:261
#: intervention/views.py:516
#: compensation/views/eco_account.py:330 ema/views.py:261
#: intervention/views.py:519
msgid "{} unrecorded"
msgstr "{} entzeichnet"
#: compensation/views/eco_account.py:328 ema/views.py:261
#: intervention/views.py:516
#: compensation/views/eco_account.py:330 ema/views.py:261
#: intervention/views.py:519
msgid "{} recorded"
msgstr "{} verzeichnet"
#: compensation/views/eco_account.py:529 intervention/views.py:497
#: compensation/views/eco_account.py:531 intervention/views.py:500
msgid "Deduction added"
msgstr "Abbuchung hinzugefügt"
#: compensation/views/eco_account.py:612 ema/views.py:516
#: intervention/views.py:372
#: compensation/views/eco_account.py:614 ema/views.py:516
#: intervention/views.py:375
msgid "{} has already been shared with you"
msgstr "{} wurde bereits für Sie freigegeben"
#: compensation/views/eco_account.py:617 ema/views.py:521
#: intervention/views.py:377
#: compensation/views/eco_account.py:619 ema/views.py:521
#: intervention/views.py:380
msgid "{} has been shared with you"
msgstr "{} ist nun für Sie freigegeben"
#: compensation/views/eco_account.py:624 ema/views.py:528
#: intervention/views.py:384
#: compensation/views/eco_account.py:626 ema/views.py:528
#: intervention/views.py:387
msgid "Share link invalid"
msgstr "Freigabelink ungültig"
#: compensation/views/eco_account.py:647 ema/views.py:551
#: intervention/views.py:407
#: compensation/views/eco_account.py:649 ema/views.py:551
#: intervention/views.py:410
msgid "Share settings updated"
msgstr "Freigabe Einstellungen aktualisiert"
@ -1333,7 +1333,7 @@ msgstr "Kompensationen und Zahlungen geprüft"
msgid "Run check"
msgstr "Prüfung vornehmen"
#: intervention/forms/modalForms.py:196 konova/forms.py:453
#: intervention/forms/modalForms.py:196 konova/forms.py:454
msgid ""
"I, {} {}, confirm that all necessary control steps have been performed by "
"myself."
@ -1472,31 +1472,31 @@ msgstr ""
msgid "Intervention {} added"
msgstr "Eingriff {} hinzugefügt"
#: intervention/views.py:243
#: intervention/views.py:245
msgid "This intervention has {} revocations"
msgstr "Dem Eingriff liegen {} Widersprüche vor"
#: intervention/views.py:290
#: intervention/views.py:293
msgid "Intervention {} edited"
msgstr "Eingriff {} bearbeitet"
#: intervention/views.py:325
#: intervention/views.py:328
msgid "{} removed"
msgstr "{} entfernt"
#: intervention/views.py:346
#: intervention/views.py:349
msgid "Revocation removed"
msgstr "Widerspruch entfernt"
#: intervention/views.py:428
#: intervention/views.py:431
msgid "Check performed"
msgstr "Prüfung durchgeführt"
#: intervention/views.py:450
#: intervention/views.py:453
msgid "Revocation added"
msgstr "Widerspruch hinzugefügt"
#: intervention/views.py:521
#: intervention/views.py:524
msgid "There are errors on this intervention:"
msgstr "Es liegen Fehler in diesem Eingriff vor:"
@ -1525,11 +1525,11 @@ msgstr "Speichern"
msgid "Not editable"
msgstr "Nicht editierbar"
#: konova/forms.py:138 konova/forms.py:307
#: konova/forms.py:138 konova/forms.py:308
msgid "Confirm"
msgstr "Bestätige"
#: konova/forms.py:150 konova/forms.py:316
#: konova/forms.py:150 konova/forms.py:317
msgid "Remove"
msgstr "Löschen"
@ -1542,56 +1542,56 @@ msgstr "Sie sind dabei {} {} zu löschen"
msgid "Geometry"
msgstr "Geometrie"
#: konova/forms.py:317
#: konova/forms.py:318
msgid "Are you sure?"
msgstr "Sind Sie sicher?"
#: konova/forms.py:344
#: konova/forms.py:345
msgid "Created on"
msgstr "Erstellt"
#: konova/forms.py:346
#: konova/forms.py:347
msgid "When has this file been created? Important for photos."
msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?"
#: konova/forms.py:357
#: konova/forms.py:358
#: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231
msgid "File"
msgstr "Datei"
#: konova/forms.py:359
#: konova/forms.py:360
msgid "Allowed formats: pdf, jpg, png. Max size 15 MB."
msgstr "Formate: pdf, jpg, png. Maximal 15 MB."
#: konova/forms.py:405
#: konova/forms.py:406
msgid "Unsupported file type"
msgstr "Dateiformat nicht unterstützt"
#: konova/forms.py:412
#: konova/forms.py:413
msgid "File too large"
msgstr "Datei zu groß"
#: konova/forms.py:421
#: konova/forms.py:422
msgid "Added document"
msgstr "Dokument hinzugefügt"
#: konova/forms.py:444
#: konova/forms.py:445
msgid "Confirm record"
msgstr "Verzeichnen bestätigen"
#: konova/forms.py:452
#: konova/forms.py:453
msgid "Record data"
msgstr "Daten verzeichnen"
#: konova/forms.py:459
#: konova/forms.py:460
msgid "Confirm unrecord"
msgstr "Entzeichnen bestätigen"
#: konova/forms.py:460
#: konova/forms.py:461
msgid "Unrecord data"
msgstr "Daten entzeichnen"
#: konova/forms.py:461
#: konova/forms.py:462
msgid "I, {} {}, confirm that this data must be unrecorded."
msgstr ""
"Ich, {} {}, bestätige, dass diese Daten wieder entzeichnet werden müssen."
@ -1663,6 +1663,30 @@ msgstr "Anzeigen"
msgid "Deduct"
msgstr "Abbuchen"
#: konova/templates/konova/includes/parcels.html:3
msgid "Spatial reference"
msgstr "Raumreferenz"
#: konova/templates/konova/includes/parcels.html:9
msgid "Kreis"
msgstr "Kreis"
#: konova/templates/konova/includes/parcels.html:10
msgid "Gemarkung"
msgstr "Gemarkung"
#: konova/templates/konova/includes/parcels.html:11
msgid "Parcel"
msgstr "Flur"
#: konova/templates/konova/includes/parcels.html:12
msgid "Parcel counter"
msgstr "Flurstückzähler"
#: konova/templates/konova/includes/parcels.html:13
msgid "Parcel number"
msgstr "Flurstücknenner"
#: konova/templates/konova/widgets/generate-content-input.html:6
msgid "Generate new"
msgstr "Neu generieren"
@ -1726,8 +1750,8 @@ msgid ""
"Action canceled. Eco account is recorded or deductions exist. Only "
"conservation office member can perform this action."
msgstr ""
"Aktion abgebrochen. Ökokonto ist bereits verzeichnet oder Abbuchungen liegen vor. Nur "
"Eintragungsstellennutzer können diese Aktion jetzt durchführen."
"Aktion abgebrochen. Ökokonto ist bereits verzeichnet oder Abbuchungen liegen "
"vor. Nur Eintragungsstellennutzer können diese Aktion jetzt durchführen."
#: konova/utils/message_templates.py:25
msgid "Edited general data"