|
|
@ -16,7 +16,6 @@ from django.db import models, transaction
|
|
|
|
from django.db.models import QuerySet
|
|
|
|
from django.db.models import QuerySet
|
|
|
|
from django.http import HttpRequest
|
|
|
|
from django.http import HttpRequest
|
|
|
|
|
|
|
|
|
|
|
|
from compensation.models import EcoAccountDeduction
|
|
|
|
|
|
|
|
from intervention.managers import InterventionManager
|
|
|
|
from intervention.managers import InterventionManager
|
|
|
|
from intervention.models.legal import Legal
|
|
|
|
from intervention.models.legal import Legal
|
|
|
|
from intervention.models.responsibility import Responsibility
|
|
|
|
from intervention.models.responsibility import Responsibility
|
|
|
@ -26,7 +25,8 @@ from konova.models import generate_document_file_upload_path, AbstractDocument,
|
|
|
|
ShareableObjectMixin, \
|
|
|
|
ShareableObjectMixin, \
|
|
|
|
RecordableObjectMixin, CheckableObjectMixin, GeoReferencedMixin
|
|
|
|
RecordableObjectMixin, CheckableObjectMixin, GeoReferencedMixin
|
|
|
|
from konova.settings import LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT, DEFAULT_SRID_RLP
|
|
|
|
from konova.settings import LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT, DEFAULT_SRID_RLP
|
|
|
|
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DEDUCTION_ADDED, DOCUMENT_REMOVED_TEMPLATE
|
|
|
|
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DOCUMENT_REMOVED_TEMPLATE, \
|
|
|
|
|
|
|
|
PAYMENT_REMOVED, PAYMENT_ADDED, REVOCATION_REMOVED
|
|
|
|
from user.models import UserActionLogEntry
|
|
|
|
from user.models import UserActionLogEntry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -196,6 +196,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|
|
|
comment=form_data.get("comment", None),
|
|
|
|
comment=form_data.get("comment", None),
|
|
|
|
intervention=self,
|
|
|
|
intervention=self,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
self.mark_as_edited(user, form.request, edit_comment=PAYMENT_ADDED)
|
|
|
|
return pay
|
|
|
|
return pay
|
|
|
|
|
|
|
|
|
|
|
|
def add_revocation(self, form):
|
|
|
|
def add_revocation(self, form):
|
|
|
@ -229,6 +230,21 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return revocation
|
|
|
|
return revocation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_revocation(self, form):
|
|
|
|
|
|
|
|
""" Removes a revocation from the intervention
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
form (RevocationRemoveModalForm): The form holding all relevant data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
revocation = form.revocation
|
|
|
|
|
|
|
|
user = form.user
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
|
|
|
|
revocation.delete()
|
|
|
|
|
|
|
|
self.mark_as_edited(user, request=form.request, edit_comment=REVOCATION_REMOVED)
|
|
|
|
|
|
|
|
|
|
|
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True):
|
|
|
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None, reset_recorded: bool = True):
|
|
|
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
|
|
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
|
|
|
unrecord and uncheck
|
|
|
|
unrecord and uncheck
|
|
|
@ -242,7 +258,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
action = super().mark_as_edited(performing_user, edit_comment)
|
|
|
|
action = super().mark_as_edited(performing_user, edit_comment=edit_comment)
|
|
|
|
if reset_recorded:
|
|
|
|
if reset_recorded:
|
|
|
|
self.unrecord(performing_user, request)
|
|
|
|
self.unrecord(performing_user, request)
|
|
|
|
if self.checked:
|
|
|
|
if self.checked:
|
|
|
@ -289,6 +305,21 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return reverse("intervention:share", args=(self.id, self.access_token))
|
|
|
|
return reverse("intervention:share", args=(self.id, self.access_token))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_payment(self, form):
|
|
|
|
|
|
|
|
""" Removes a Payment from the intervention
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
form (PaymentRemoveModalForm): The form holding all relevant data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
payment = form.payment
|
|
|
|
|
|
|
|
user = form.user
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
|
|
|
|
payment.delete()
|
|
|
|
|
|
|
|
self.mark_as_edited(user, request=form.request, edit_comment=PAYMENT_REMOVED)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InterventionDocument(AbstractDocument):
|
|
|
|
class InterventionDocument(AbstractDocument):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|