#160 Parcel number to parcel table

* adds number of all underlying parcels into parcel table
* reworks minor code parts of parcel related logic
* fixes bug where under certain circumstances a parcel would have been added twice to a geometry
* removes unused parcel fetching on intervention detail view
pull/162/head
mpeltriaux 2 years ago
parent 21d1fabeec
commit 3535aba30f

@ -266,14 +266,11 @@ def detail_view(request: HttpRequest, id: str):
instance=intervention,
)
parcels = intervention.get_underlying_parcels()
context = {
"obj": intervention,
"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),

@ -152,6 +152,7 @@ class Geometry(BaseResource):
underlying_parcels.append(parcel_obj)
# Update the linked parcels
self.parcels.clear()
self.parcels.set(underlying_parcels)
# Set the calculated_on intermediate field, so this related data will be found on lookups
@ -172,7 +173,6 @@ class Geometry(BaseResource):
Returns:
parcels (QuerySet): The related parcels as queryset
"""
parcels = self.parcels.filter(
parcelintersection__calculated_on__isnull=False,
).prefetch_related(
@ -184,6 +184,17 @@ class Geometry(BaseResource):
return parcels
def count_underlying_parcels(self):
""" Getter for number of underlying parcels
Returns:
"""
num_parcels = self.parcels.filter(
parcelintersection__calculated_on__isnull=False,
).count()
return num_parcels
class GeometryConflict(UuidModel):
"""

@ -652,10 +652,21 @@ class GeoReferencedMixin(models.Model):
Returns:
parcels (Iterable): An empty list or a Queryset
"""
result = []
if self.geometry is not None:
return self.geometry.get_underlying_parcels()
else:
return []
result = self.geometry.get_underlying_parcels()
return result
def count_underlying_parcels(self):
""" Getter for number of underlying parcels
Returns:
"""
result = 0
if self.geometry is not None:
result = self.geometry.count_underlying_parcels()
return result
def set_geometry_conflict_message(self, request: HttpRequest):
if self.geometry is None:

@ -5,6 +5,11 @@
{% trans 'Parcels can not be calculated, since no geometry is given.' %}
</article>
{% else %}
<div>
<h4 class="">
<span class="badge rlp-r">{{num_parcels}}</span>
{% trans 'Parcels found' %}</h4>
</div>
<table id="upper-spatial-table" class="table table-hover">
<thead>
<tr>

@ -135,12 +135,14 @@ def get_geom_parcels(request: HttpRequest, id: str):
municipals = Municipal.objects.filter(id__in=municipals)
rpp = 100
num_all_parcels = parcels.count()
parcels = parcels[:rpp]
next_page = 1
if len(parcels) < rpp:
next_page = None
context = {
"num_parcels": num_all_parcels,
"parcels": parcels,
"municipals": municipals,
"geom_id": str(id),

Binary file not shown.

@ -3,9 +3,9 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: compensation/filters.py:123 compensation/forms/modalForms.py:36
#: compensation/forms/modalForms.py:47 compensation/forms/modalForms.py:63
#: compensation/forms/modalForms.py:358 compensation/forms/modalForms.py:466
#: compensation/filters.py:123 compensation/forms/modalForms.py:37
#: compensation/forms/modalForms.py:48 compensation/forms/modalForms.py:64
#: compensation/forms/modalForms.py:362 compensation/forms/modalForms.py:470
#: intervention/forms/forms.py:54 intervention/forms/forms.py:174
#: intervention/forms/forms.py:186 intervention/forms/modalForms.py:150
#: intervention/forms/modalForms.py:163 intervention/forms/modalForms.py:176
@ -26,7 +26,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-21 14:16+0200\n"
"POT-Creation-Date: 2022-05-11 13:41+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"
@ -97,7 +97,7 @@ msgstr ""
#: analysis/templates/analysis/reports/includes/eco_account/amount.html:3
#: analysis/templates/analysis/reports/includes/intervention/amount.html:3
#: analysis/templates/analysis/reports/includes/old_data/amount.html:3
#: compensation/forms/modalForms.py:450
#: compensation/forms/modalForms.py:454
#: compensation/templates/compensation/detail/eco_account/includes/deductions.html:34
#: intervention/templates/intervention/detail/includes/deductions.html:31
msgid "Amount"
@ -215,7 +215,7 @@ msgstr "Abbuchungen"
#: analysis/templates/analysis/reports/includes/eco_account/deductions.html:9
#: analysis/templates/analysis/reports/includes/eco_account/deductions.html:11
#: compensation/forms/modalForms.py:195
#: compensation/forms/modalForms.py:187
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:36
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:36
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:36
@ -248,7 +248,7 @@ msgid "Compensation"
msgstr "Kompensation"
#: analysis/templates/analysis/reports/includes/intervention/compensated_by.html:21
#: compensation/forms/modalForms.py:76
#: compensation/forms/modalForms.py:77
msgid "Payment"
msgstr "Zahlung"
@ -354,8 +354,8 @@ msgstr "Aussagekräftiger Titel"
msgid "Compensation XY; Location ABC"
msgstr "Kompensation XY; Flur ABC"
#: compensation/forms/forms.py:57 compensation/forms/modalForms.py:62
#: compensation/forms/modalForms.py:357 compensation/forms/modalForms.py:465
#: compensation/forms/forms.py:57 compensation/forms/modalForms.py:63
#: compensation/forms/modalForms.py:361 compensation/forms/modalForms.py:469
#: compensation/templates/compensation/detail/compensation/includes/actions.html:35
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:34
#: compensation/templates/compensation/detail/compensation/includes/documents.html:34
@ -373,7 +373,7 @@ msgstr "Kompensation XY; Flur ABC"
msgid "Comment"
msgstr "Kommentar"
#: compensation/forms/forms.py:59 compensation/forms/modalForms.py:467
#: compensation/forms/forms.py:59 compensation/forms/modalForms.py:471
#: intervention/forms/forms.py:200
msgid "Additional comment"
msgstr "Zusätzlicher Kommentar"
@ -479,70 +479,70 @@ msgstr "Ökokonto XY; Flur ABC"
msgid "Edit Eco-Account"
msgstr "Ökokonto bearbeiten"
#: compensation/forms/modalForms.py:37
#: compensation/forms/modalForms.py:38
msgid "in Euro"
msgstr "in Euro"
#: compensation/forms/modalForms.py:46
#: compensation/forms/modalForms.py:47
#: intervention/templates/intervention/detail/includes/payments.html:31
msgid "Due on"
msgstr "Fällig am"
#: compensation/forms/modalForms.py:49
#: compensation/forms/modalForms.py:50
msgid "Due on which date"
msgstr "Zahlung wird an diesem Datum erwartet"
#: compensation/forms/modalForms.py:64 compensation/forms/modalForms.py:359
#: compensation/forms/modalForms.py:65 compensation/forms/modalForms.py:363
#: intervention/forms/modalForms.py:177 konova/forms.py:429
msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
#: compensation/forms/modalForms.py:77
#: compensation/forms/modalForms.py:78
msgid "Add a payment for intervention '{}'"
msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen"
#: compensation/forms/modalForms.py:97
#: compensation/forms/modalForms.py:98
msgid "If there is no date you can enter, please explain why."
msgstr "Falls Sie kein Datum angeben können, erklären Sie bitte weshalb."
#: compensation/forms/modalForms.py:116
#: compensation/forms/modalForms.py:117
#: intervention/templates/intervention/detail/includes/payments.html:59
msgid "Edit payment"
msgstr "Zahlung bearbeiten"
#: compensation/forms/modalForms.py:159 compensation/forms/modalForms.py:171
#: compensation/forms/modalForms.py:161
msgid "Biotope Type"
msgstr "Biotoptyp"
#: compensation/forms/modalForms.py:162
#: compensation/forms/modalForms.py:164
msgid "Select the biotope type"
msgstr "Biotoptyp wählen"
#: compensation/forms/modalForms.py:176 compensation/forms/modalForms.py:188
#: compensation/forms/modalForms.py:168 compensation/forms/modalForms.py:180
msgid "Biotope additional type"
msgstr "Zusatzbezeichnung"
#: compensation/forms/modalForms.py:179
#: compensation/forms/modalForms.py:171
msgid "Select an additional biotope type"
msgstr "Zusatzbezeichnung wählen"
#: compensation/forms/modalForms.py:198 intervention/forms/modalForms.py:366
#: compensation/forms/modalForms.py:190 intervention/forms/modalForms.py:366
msgid "in m²"
msgstr ""
#: compensation/forms/modalForms.py:209
#: compensation/forms/modalForms.py:201
msgid "New state"
msgstr "Neuer Zustand"
#: compensation/forms/modalForms.py:210
#: compensation/forms/modalForms.py:202
msgid "Insert data for the new state"
msgstr "Geben Sie die Daten des neuen Zustandes ein"
#: compensation/forms/modalForms.py:217 konova/forms.py:227
#: compensation/forms/modalForms.py:219 konova/forms.py:227
msgid "Object removed"
msgstr "Objekt entfernt"
#: compensation/forms/modalForms.py:272
#: compensation/forms/modalForms.py:274
#: compensation/templates/compensation/detail/compensation/includes/states-after.html:62
#: compensation/templates/compensation/detail/compensation/includes/states-before.html:62
#: compensation/templates/compensation/detail/eco_account/includes/states-after.html:62
@ -552,15 +552,15 @@ msgstr "Objekt entfernt"
msgid "Edit state"
msgstr "Zustand bearbeiten"
#: compensation/forms/modalForms.py:329
#: compensation/forms/modalForms.py:333
msgid "Deadline Type"
msgstr "Fristart"
#: compensation/forms/modalForms.py:332
#: compensation/forms/modalForms.py:336
msgid "Select the deadline type"
msgstr "Fristart wählen"
#: compensation/forms/modalForms.py:341
#: compensation/forms/modalForms.py:345
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:31
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:31
#: ema/templates/ema/detail/includes/deadlines.html:31
@ -568,30 +568,30 @@ msgstr "Fristart wählen"
msgid "Date"
msgstr "Datum"
#: compensation/forms/modalForms.py:344
#: compensation/forms/modalForms.py:348
msgid "Select date"
msgstr "Datum wählen"
#: compensation/forms/modalForms.py:371
#: compensation/forms/modalForms.py:375
msgid "New deadline"
msgstr "Neue Frist"
#: compensation/forms/modalForms.py:372
#: compensation/forms/modalForms.py:376
msgid "Insert data for the new deadline"
msgstr "Geben Sie die Daten der neuen Frist ein"
#: compensation/forms/modalForms.py:385
#: compensation/forms/modalForms.py:389
#: compensation/templates/compensation/detail/compensation/includes/deadlines.html:59
#: compensation/templates/compensation/detail/eco_account/includes/deadlines.html:57
#: ema/templates/ema/detail/includes/deadlines.html:57
msgid "Edit deadline"
msgstr "Frist/Termin bearbeiten"
#: compensation/forms/modalForms.py:413
#: compensation/forms/modalForms.py:417
msgid "Action Type"
msgstr "Maßnahmentyp"
#: compensation/forms/modalForms.py:416
#: compensation/forms/modalForms.py:420
msgid ""
"An action can consist of multiple different action types. All the selected "
"action types are expected to be performed according to the amount and unit "
@ -601,35 +601,35 @@ msgstr ""
"hier gewählten Einträge sollen mit der weiter unten angegebenen Einheit und "
"Menge umgesetzt werden. "
#: compensation/forms/modalForms.py:421 compensation/forms/modalForms.py:433
#: compensation/forms/modalForms.py:425 compensation/forms/modalForms.py:437
msgid "Action Type detail"
msgstr "Zusatzmerkmal"
#: compensation/forms/modalForms.py:424
#: compensation/forms/modalForms.py:428
msgid "Select the action type detail"
msgstr "Zusatzmerkmal wählen"
#: compensation/forms/modalForms.py:438
#: compensation/forms/modalForms.py:442
msgid "Unit"
msgstr "Einheit"
#: compensation/forms/modalForms.py:441
#: compensation/forms/modalForms.py:445
msgid "Select the unit"
msgstr "Einheit wählen"
#: compensation/forms/modalForms.py:453
#: compensation/forms/modalForms.py:457
msgid "Insert the amount"
msgstr "Menge eingeben"
#: compensation/forms/modalForms.py:478
#: compensation/forms/modalForms.py:482
msgid "New action"
msgstr "Neue Maßnahme"
#: compensation/forms/modalForms.py:479
#: compensation/forms/modalForms.py:483
msgid "Insert data for the new action"
msgstr "Geben Sie die Daten der neuen Maßnahme ein"
#: compensation/forms/modalForms.py:503
#: compensation/forms/modalForms.py:507
#: compensation/templates/compensation/detail/compensation/includes/actions.html:68
#: compensation/templates/compensation/detail/eco_account/includes/actions.html:67
#: ema/templates/ema/detail/includes/actions.html:65
@ -1150,17 +1150,17 @@ msgid "Compensation {} edited"
msgstr "Kompensation {} bearbeitet"
#: compensation/views/compensation.py:182 compensation/views/eco_account.py:173
#: ema/views.py:240 intervention/views.py:335
#: ema/views.py:240 intervention/views.py:334
msgid "Edit {}"
msgstr "Bearbeite {}"
#: compensation/views/compensation.py:261 compensation/views/eco_account.py:359
#: ema/views.py:194 intervention/views.py:539
#: ema/views.py:194 intervention/views.py:538
msgid "Log"
msgstr "Log"
#: compensation/views/compensation.py:605 compensation/views/eco_account.py:727
#: ema/views.py:558 intervention/views.py:685
#: ema/views.py:558 intervention/views.py:684
msgid "Report {}"
msgstr "Bericht {}"
@ -1181,32 +1181,32 @@ msgid "Eco-account removed"
msgstr "Ökokonto entfernt"
#: compensation/views/eco_account.py:380 ema/views.py:282
#: intervention/views.py:638
#: intervention/views.py:637
msgid "{} unrecorded"
msgstr "{} entzeichnet"
#: compensation/views/eco_account.py:380 ema/views.py:282
#: intervention/views.py:638
#: intervention/views.py:637
msgid "{} recorded"
msgstr "{} verzeichnet"
#: compensation/views/eco_account.py:804 ema/views.py:628
#: intervention/views.py:436
#: intervention/views.py:435
msgid "{} has already been shared with you"
msgstr "{} wurde bereits für Sie freigegeben"
#: compensation/views/eco_account.py:809 ema/views.py:633
#: intervention/views.py:441
#: intervention/views.py:440
msgid "{} has been shared with you"
msgstr "{} ist nun für Sie freigegeben"
#: compensation/views/eco_account.py:816 ema/views.py:640
#: intervention/views.py:448
#: intervention/views.py:447
msgid "Share link invalid"
msgstr "Freigabelink ungültig"
#: compensation/views/eco_account.py:839 ema/views.py:663
#: intervention/views.py:471
#: intervention/views.py:470
msgid "Share settings updated"
msgstr "Freigabe Einstellungen aktualisiert"
@ -1312,7 +1312,7 @@ msgstr "Datum Zulassung bzw. Satzungsbeschluss"
msgid "Binding on"
msgstr "Datum Bestandskraft"
#: intervention/forms/forms.py:211 intervention/views.py:95
#: intervention/forms/forms.py:211 intervention/views.py:97
msgid "New intervention"
msgstr "Neuer Eingriff"
@ -1532,27 +1532,27 @@ msgstr ""
"Kein Ausgleich jeglicher Art gefunden (Kompensation, Ersatzzahlung, "
"Abbuchung)"
#: intervention/views.py:52
#: intervention/views.py:54
msgid "Interventions - Overview"
msgstr "Eingriffe - Übersicht"
#: intervention/views.py:85
#: intervention/views.py:87
msgid "Intervention {} added"
msgstr "Eingriff {} hinzugefügt"
#: intervention/views.py:323
#: intervention/views.py:322
msgid "Intervention {} edited"
msgstr "Eingriff {} bearbeitet"
#: intervention/views.py:359
#: intervention/views.py:358
msgid "{} removed"
msgstr "{} entfernt"
#: intervention/views.py:492
#: intervention/views.py:491
msgid "Check performed"
msgstr "Prüfung durchgeführt"
#: intervention/views.py:643
#: intervention/views.py:642
msgid "There are errors on this intervention:"
msgstr "Es liegen Fehler in diesem Eingriff vor:"
@ -1582,7 +1582,7 @@ msgid "Search for file number"
msgstr "Nach Aktenzeichen suchen"
#: konova/filters/mixins.py:85
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:13
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:18
msgid "District"
msgstr "Kreis"
@ -1595,7 +1595,7 @@ msgid "Search for parcel gmrkng"
msgstr "Nach Gemarkung suchen"
#: konova/filters/mixins.py:111
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:34
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:39
msgid "Parcel"
msgstr "Flur"
@ -1604,7 +1604,7 @@ msgid "Search for parcel"
msgstr "Nach Flur suchen"
#: konova/filters/mixins.py:124
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:35
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:40
msgid "Parcel counter"
msgstr "Flurstückzähler"
@ -1613,7 +1613,7 @@ msgid "Search for parcel counter"
msgstr "Nach Flurstückzähler suchen"
#: konova/filters/mixins.py:138
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:36
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:41
msgid "Parcel number"
msgstr "Flurstücknenner"
@ -1748,10 +1748,6 @@ msgstr ""
msgid "English"
msgstr ""
#: konova/templates/konova/includes/parcels/parcel_table_content.html:18
msgid "Show more..."
msgstr "Mehr anzeigen..."
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:5
msgid "Parcels can not be calculated, since no geometry is given."
msgstr ""
@ -1759,22 +1755,26 @@ msgstr ""
"wurde."
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:11
msgid "Parcels found"
msgstr "Flurstücke"
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:16
msgid "Municipal"
msgstr "Gemeinde"
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:12
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:17
msgid "Municipal key"
msgstr "Gemeindeschlüssel"
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:14
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:19
msgid "District key"
msgstr "Kreisschlüssel"
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:32
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:37
msgid "Parcel group"
msgstr "Gemarkung"
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:33
#: konova/templates/konova/includes/parcels/parcel_table_frame.html:38
msgid "Parcel group key"
msgstr "Gemarkungsschlüssel"
@ -1808,11 +1808,6 @@ msgstr "Im Browser öffnen"
msgid "View in LANIS"
msgstr "In LANIS öffnen"
#: konova/templates/konova/widgets/checkbox-tree-select.html:4
#: templates/generic_index.html:56
msgid "Search"
msgstr "Suchen"
#: konova/templates/konova/widgets/generate-content-input.html:6
msgid "Generate new"
msgstr "Neu generieren"
@ -1825,6 +1820,12 @@ msgstr "In Zwischenablage kopieren"
msgid "Copied to clipboard"
msgstr "In Zwischenablage kopiert"
#: konova/templates/konova/widgets/tree/checkbox/checkbox-tree-select.html:4
#: konova/templates/konova/widgets/tree/radio/radio-tree-select.html:4
#: templates/generic_index.html:56
msgid "Search"
msgstr "Suchen"
#: konova/utils/mailer.py:68 konova/utils/mailer.py:137
msgid "{} - Shared access removed"
msgstr "{} - Zugriff entzogen"
@ -4245,6 +4246,9 @@ msgstr ""
msgid "Unable to connect to qpid with SASL mechanism %s"
msgstr ""
#~ msgid "Show more..."
#~ msgstr "Mehr anzeigen..."
#~ msgid "Kreis"
#~ msgstr "Kreis"

Loading…
Cancel
Save