#300 Extend mail templates

* extends all relevant mail templates such that municipals of an entry will be shown in the mail
This commit is contained in:
2023-02-23 10:17:45 +01:00
parent e1259b276c
commit bf41559c56
23 changed files with 383 additions and 158 deletions

View File

@@ -276,6 +276,22 @@ class Geometry(BaseResource):
return parcels
def get_underlying_municipals(self, parcels=None):
""" Getter for related municipals
If no QuerySet of parcels is provided, the parcels will be fetched
Returns:
municipals (QuerySet): The related municipals as queryset
"""
from konova.models import Municipal
if parcels is None:
parcels = self.get_underlying_parcels()
municipals = parcels.order_by("municipal").distinct("municipal").values("municipal__id")
municipals = Municipal.objects.filter(id__in=municipals).order_by("name")
return municipals
def count_underlying_parcels(self):
""" Getter for number of underlying parcels