|
|
|
@ -15,7 +15,7 @@ from django.utils.translation import gettext_lazy as _
|
|
|
|
|
from intervention.managers import InterventionManager
|
|
|
|
|
from intervention.models.legal import Legal
|
|
|
|
|
from intervention.models.responsibility import Responsibility
|
|
|
|
|
from intervention.models.revocation import RevocationDocument
|
|
|
|
|
from intervention.models.revocation import RevocationDocument, Revocation
|
|
|
|
|
from intervention.utils.quality import InterventionQualityChecker
|
|
|
|
|
from konova.models import generate_document_file_upload_path, AbstractDocument, Geometry, BaseObject, ShareableObjectMixin, \
|
|
|
|
|
RecordableObjectMixin, CheckableObjectMixin
|
|
|
|
@ -209,6 +209,46 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|
|
|
|
self.save()
|
|
|
|
|
return pay
|
|
|
|
|
|
|
|
|
|
def add_revocation(self, form):
|
|
|
|
|
""" Adds a new revocation to the intervention
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
form (NewPaymentForm): The form holding the data
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
form_data = form.cleaned_data
|
|
|
|
|
user = form.user
|
|
|
|
|
with transaction.atomic():
|
|
|
|
|
created_action = UserActionLogEntry.objects.create(
|
|
|
|
|
user=user,
|
|
|
|
|
action=UserAction.CREATED
|
|
|
|
|
)
|
|
|
|
|
edited_action = UserActionLogEntry.objects.create(
|
|
|
|
|
user=user,
|
|
|
|
|
action=UserAction.EDITED
|
|
|
|
|
)
|
|
|
|
|
revocation = Revocation.objects.create(
|
|
|
|
|
date=form_data["date"],
|
|
|
|
|
legal=self.legal,
|
|
|
|
|
comment=form_data["comment"],
|
|
|
|
|
created=created_action,
|
|
|
|
|
)
|
|
|
|
|
self.modified = edited_action
|
|
|
|
|
self.save()
|
|
|
|
|
self.log.add(edited_action)
|
|
|
|
|
|
|
|
|
|
if form_data["file"]:
|
|
|
|
|
RevocationDocument.objects.create(
|
|
|
|
|
title="revocation_of_{}".format(self.identifier),
|
|
|
|
|
date_of_creation=form_data["date"],
|
|
|
|
|
comment=form_data["comment"],
|
|
|
|
|
file=form_data["file"],
|
|
|
|
|
instance=revocation
|
|
|
|
|
)
|
|
|
|
|
return revocation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InterventionDocument(AbstractDocument):
|
|
|
|
|
"""
|
|
|
|
|