|
|
|
@ -15,6 +15,7 @@ from django.utils.translation import gettext_lazy as _
|
|
|
|
|
from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE
|
|
|
|
|
from intervention.models import Intervention, ResponsibilityData
|
|
|
|
|
from konova.models import BaseObject, BaseResource, Geometry, UuidModel
|
|
|
|
|
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE
|
|
|
|
|
from konova.utils.generators import generate_random_string
|
|
|
|
|
from user.models import UserActionLogEntry
|
|
|
|
|
|
|
|
|
@ -169,6 +170,28 @@ class Compensation(AbstractCompensation):
|
|
|
|
|
self.identifier = new_id
|
|
|
|
|
super().save(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
def get_LANIS_link(self) -> str:
|
|
|
|
|
""" Generates a link for LANIS depending on the geometry
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
geom = self.geometry.geom.transform(DEFAULT_SRID_RLP, clone=True)
|
|
|
|
|
x = geom.centroid.x
|
|
|
|
|
y = geom.centroid.y
|
|
|
|
|
zoom_lvl = 16
|
|
|
|
|
except AttributeError:
|
|
|
|
|
# If no geometry has been added, yet.
|
|
|
|
|
x = 1
|
|
|
|
|
y = 1
|
|
|
|
|
zoom_lvl = 6
|
|
|
|
|
return LANIS_LINK_TEMPLATE.format(
|
|
|
|
|
zoom_lvl,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EcoAccount(AbstractCompensation):
|
|
|
|
|
"""
|
|
|
|
@ -203,6 +226,28 @@ class EcoAccount(AbstractCompensation):
|
|
|
|
|
"""
|
|
|
|
|
return self.withdraws.all().aggregate(Sum("surface"))["surface__sum"]
|
|
|
|
|
|
|
|
|
|
def get_LANIS_link(self) -> str:
|
|
|
|
|
""" Generates a link for LANIS depending on the geometry
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
geom = self.geometry.geom.transform(DEFAULT_SRID_RLP, clone=True)
|
|
|
|
|
x = geom.centroid.x
|
|
|
|
|
y = geom.centroid.y
|
|
|
|
|
zoom_lvl = 16
|
|
|
|
|
except AttributeError:
|
|
|
|
|
# If no geometry has been added, yet.
|
|
|
|
|
x = 1
|
|
|
|
|
y = 1
|
|
|
|
|
zoom_lvl = 6
|
|
|
|
|
return LANIS_LINK_TEMPLATE.format(
|
|
|
|
|
zoom_lvl,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EcoAccountWithdraw(BaseResource):
|
|
|
|
|
"""
|
|
|
|
|