#57 Deduction shortcut remove
* removes deduction shortcut * adds missing quality checks on intervention deduction accounts validity * fixes error if checked intervention shall be checked again * adds/updates translations
This commit is contained in:
@@ -189,27 +189,43 @@ class CheckModalForm(BaseModalForm):
|
||||
widget=forms.CheckboxInput(),
|
||||
required=True
|
||||
)
|
||||
valid = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Run check")
|
||||
self.form_caption = _("I, {} {}, confirm that all necessary control steps have been performed by myself.").format(self.user.first_name, self.user.last_name)
|
||||
self.valid = False
|
||||
|
||||
def is_valid(self) -> bool:
|
||||
""" Perform a validity check based on quality_check() logic
|
||||
def _are_deductions_valid(self):
|
||||
""" Performs validity checks on deductions and their eco-account
|
||||
|
||||
Returns:
|
||||
result (bool)
|
||||
|
||||
"""
|
||||
deductions = self.instance.deductions.all()
|
||||
for deduction in deductions:
|
||||
checker = deduction.account.quality_check()
|
||||
for msg in checker.messages:
|
||||
self.add_error(
|
||||
"checked_comps",
|
||||
f"{deduction.account.identifier}: {msg}"
|
||||
)
|
||||
return checker.valid
|
||||
return True
|
||||
|
||||
def _are_comps_valid(self):
|
||||
""" Performs validity checks on all types of compensations
|
||||
|
||||
Types of compensations are
|
||||
* regular Compensations
|
||||
* deductions from EcoAccounts
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
super_result = super().is_valid()
|
||||
# Perform check
|
||||
checker = self.instance.quality_check()
|
||||
for msg in checker.messages:
|
||||
self.add_error(
|
||||
"checked_intervention",
|
||||
msg
|
||||
)
|
||||
comps = self.instance.compensations.all()
|
||||
comps_valid = True
|
||||
for comp in comps:
|
||||
checker = comp.quality_check()
|
||||
for msg in checker.messages:
|
||||
@@ -217,7 +233,28 @@ class CheckModalForm(BaseModalForm):
|
||||
"checked_comps",
|
||||
f"{comp.identifier}: {msg}"
|
||||
)
|
||||
return super_result and checker.valid
|
||||
comps_valid = checker.valid
|
||||
deductions_valid = self._are_deductions_valid()
|
||||
return deductions_valid and comps_valid
|
||||
|
||||
def is_valid(self) -> bool:
|
||||
""" Perform a validity check based on quality_check() logic
|
||||
|
||||
Returns:
|
||||
result (bool)
|
||||
"""
|
||||
super_valid = super().is_valid()
|
||||
# Perform check
|
||||
checker = self.instance.quality_check()
|
||||
for msg in checker.messages:
|
||||
self.add_error(
|
||||
"checked_intervention",
|
||||
msg
|
||||
)
|
||||
all_comps_valid = self._are_comps_valid()
|
||||
intervention_valid = checker.valid
|
||||
|
||||
return super_valid and intervention_valid and all_comps_valid
|
||||
|
||||
def save(self):
|
||||
""" Saving logic
|
||||
|
||||
@@ -145,7 +145,8 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
||||
|
||||
def set_checked(self, user: User) -> UserActionLogEntry:
|
||||
log_entry = super().set_checked(user)
|
||||
self.add_log_entry_to_compensations(log_entry)
|
||||
if log_entry is not None:
|
||||
self.add_log_entry_to_compensations(log_entry)
|
||||
return log_entry
|
||||
|
||||
def set_unrecorded(self, user: User):
|
||||
|
||||
Reference in New Issue
Block a user