# 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:
@@ -7,6 +7,8 @@ Created on: 02.12.20
|
||||
"""
|
||||
from dal import autocomplete
|
||||
from django import forms
|
||||
|
||||
from konova.utils.message_templates import EDITED_GENERAL_DATA
|
||||
from user.models import User
|
||||
from django.db import transaction
|
||||
from django.urls import reverse, reverse_lazy
|
||||
@@ -333,7 +335,7 @@ class EditInterventionForm(NewInterventionForm):
|
||||
self.instance.responsible.conservation_file_number = conservation_file_number
|
||||
self.instance.responsible.save()
|
||||
|
||||
user_action = UserActionLogEntry.get_edited_action(user)
|
||||
user_action = self.instance.mark_as_edited(user, edit_comment=EDITED_GENERAL_DATA)
|
||||
|
||||
geometry = geom_form.save(user_action)
|
||||
self.instance.geometry = geometry
|
||||
@@ -347,8 +349,5 @@ class EditInterventionForm(NewInterventionForm):
|
||||
self.instance.modified = user_action
|
||||
self.instance.save()
|
||||
|
||||
# Uncheck and unrecord intervention due to changed data
|
||||
self.instance.mark_as_edited(user)
|
||||
|
||||
return self.instance
|
||||
|
||||
|
||||
@@ -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