# 86 Proper log detail
* adds support for payment adding/deleting to intervention log * adds support for deduction adding/deleting to intervention/ecoaccount log * improves code snippets * drops add_deduction() methods for ecoaccount and intervention in favor of simpler creation in NewDeductionModalForm * adds messages * adds/updates translations
This commit is contained in:
@@ -6,13 +6,14 @@ Created on: 27.09.21
|
||||
|
||||
"""
|
||||
from dal import autocomplete
|
||||
from user.models import User
|
||||
|
||||
from konova.utils.message_templates import DEDUCTION_ADDED
|
||||
from user.models import User, UserActionLogEntry
|
||||
from django.db import transaction
|
||||
from django import forms
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from compensation.models import EcoAccount
|
||||
from compensation.models import EcoAccount, EcoAccountDeduction
|
||||
from intervention.inputs import TextToClipboardInput
|
||||
from intervention.models import Intervention, InterventionDocument
|
||||
from konova.forms import BaseModalForm, NewDocumentForm
|
||||
@@ -366,9 +367,26 @@ class NewDeductionModalForm(BaseModalForm):
|
||||
)
|
||||
return is_valid_surface and super_result
|
||||
|
||||
def __create_deduction(self):
|
||||
""" Creates the deduction
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
with transaction.atomic():
|
||||
user_action_create = UserActionLogEntry.get_created_action(self.user)
|
||||
deduction = EcoAccountDeduction.objects.create(
|
||||
intervention=self.cleaned_data["intervention"],
|
||||
account=self.cleaned_data["account"],
|
||||
surface=self.cleaned_data["surface"],
|
||||
created=user_action_create,
|
||||
)
|
||||
return deduction
|
||||
|
||||
def save(self):
|
||||
deduction = self.instance.add_deduction(self)
|
||||
self.instance.mark_as_edited(self.user, self.request, reset_recorded=False)
|
||||
deduction = self.__create_deduction()
|
||||
self.cleaned_data["intervention"].mark_as_edited(self.user, edit_comment=DEDUCTION_ADDED)
|
||||
self.cleaned_data["account"].mark_as_edited(self.user, edit_comment=DEDUCTION_ADDED, reset_recorded=False)
|
||||
return deduction
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user