#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
This commit is contained in:
2022-05-11 15:52:29 +02:00
parent 3ba3785ef1
commit d1dc61cbd7
7 changed files with 113 additions and 83 deletions

View File

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