|
|
@ -14,6 +14,7 @@ from django.urls import reverse
|
|
|
|
from django.utils import timezone
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
|
|
|
|
from analysis.settings import LKOMPVZVO_PUBLISH_DATE
|
|
|
|
from analysis.settings import LKOMPVZVO_PUBLISH_DATE
|
|
|
|
|
|
|
|
from compensation.models import EcoAccountDeduction
|
|
|
|
from intervention.tasks import celery_export_to_egon
|
|
|
|
from intervention.tasks import celery_export_to_egon
|
|
|
|
from user.models import User
|
|
|
|
from user.models import User
|
|
|
|
from django.db import models, transaction
|
|
|
|
from django.db import models, transaction
|
|
|
@ -295,6 +296,27 @@ class Intervention(BaseObject,
|
|
|
|
self.set_unchecked()
|
|
|
|
self.set_unchecked()
|
|
|
|
return action
|
|
|
|
return action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mark_as_deleted(self, user, send_mail: bool = True):
|
|
|
|
|
|
|
|
""" Extends base mark_as_delete functionality
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removes related deductions from the database, which results in updating the deductable_rest of the
|
|
|
|
|
|
|
|
corresponding eco account.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
user (User): The performing user
|
|
|
|
|
|
|
|
send_mail (bool): Whether to send an info mail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
super().mark_as_deleted(user, send_mail)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Remove pending deductions to free booked capacities
|
|
|
|
|
|
|
|
deductions = self.deductions.all()
|
|
|
|
|
|
|
|
# Remove one by one instead of bulk to trigger EcoAccountDeduction custom delete() logic
|
|
|
|
|
|
|
|
for deduction in deductions:
|
|
|
|
|
|
|
|
deduction.delete()
|
|
|
|
|
|
|
|
|
|
|
|
def set_status_messages(self, request: HttpRequest):
|
|
|
|
def set_status_messages(self, request: HttpRequest):
|
|
|
|
""" Setter for different information that need to be rendered
|
|
|
|
""" Setter for different information that need to be rendered
|
|
|
|
|
|
|
|
|
|
|
|