#86 Log detail enhancements

* restructures removing of related data into separate sub-delete forms for easier logic handling
This commit is contained in:
2022-02-08 13:16:20 +01:00
parent 13fd3e1fcb
commit 6cdf355063
21 changed files with 206 additions and 75 deletions

View File

@@ -7,7 +7,7 @@ Created on: 27.09.21
"""
from dal import autocomplete
from konova.utils.message_templates import DEDUCTION_ADDED, REVOCATION_ADDED
from konova.utils.message_templates import DEDUCTION_ADDED, REVOCATION_ADDED, DEDUCTION_REMOVED
from user.models import User, UserActionLogEntry
from django.db import transaction
from django import forms
@@ -16,7 +16,7 @@ from django.utils.translation import gettext_lazy as _
from compensation.models import EcoAccount, EcoAccountDeduction
from intervention.inputs import TextToClipboardInput
from intervention.models import Intervention, InterventionDocument
from konova.forms import BaseModalForm, NewDocumentForm
from konova.forms import BaseModalForm, NewDocumentForm, RemoveModalForm
from konova.utils.general import format_german_float
from konova.utils.user_checks import is_default_group_only
@@ -172,6 +172,23 @@ class NewRevocationModalForm(BaseModalForm):
return revocation
class RevocationRemoveModalForm(RemoveModalForm):
""" Removing modal form for Revocation
Can be used for anything, where removing shall be confirmed by the user a second time.
"""
revocation = None
def __init__(self, *args, **kwargs):
revocation = kwargs.pop("revocation", None)
self.revocation = revocation
super().__init__(*args, **kwargs)
def save(self):
self.instance.remove_revocation(self)
class CheckModalForm(BaseModalForm):
""" The modal form for running a check on interventions and their compensations
@@ -390,5 +407,25 @@ class NewDeductionModalForm(BaseModalForm):
return deduction
class DeductionRemoveModalForm(RemoveModalForm):
""" Removing modal form for EcoAccountDeduction
Can be used for anything, where removing shall be confirmed by the user a second time.
"""
deduction = None
def __init__(self, *args, **kwargs):
deduction = kwargs.pop("deduction", None)
self.deduction = deduction
super().__init__(*args, **kwargs)
def save(self):
with transaction.atomic():
self.deduction.intervention.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED)
self.deduction.account.mark_as_edited(self.user, edit_comment=DEDUCTION_REMOVED)
self.deduction.delete()
class NewInterventionDocumentForm(NewDocumentForm):
document_model = InterventionDocument