#36 Quality checks
* adds check on recording of intervention in case of invalid compensations
This commit is contained in:
parent
4a4c9ad049
commit
da23761f88
@ -481,8 +481,27 @@ class RecordModalForm(BaseModalForm):
|
|||||||
"confirm",
|
"confirm",
|
||||||
msg
|
msg
|
||||||
)
|
)
|
||||||
|
# Special case: Intervention
|
||||||
|
# Add direct checks for related compensations
|
||||||
|
if isinstance(self.instance, Intervention):
|
||||||
|
self._are_compensations_valid()
|
||||||
return super_val and checker.valid
|
return super_val and checker.valid
|
||||||
|
|
||||||
|
def _are_compensations_valid(self):
|
||||||
|
""" Runs a special case for intervention-compensations validity
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
comps = self.instance.compensations.all()
|
||||||
|
for comp in comps:
|
||||||
|
checker = comp.quality_check()
|
||||||
|
for msg in checker.messages:
|
||||||
|
self.add_error(
|
||||||
|
"confirm",
|
||||||
|
f"{comp.identifier}: {msg}"
|
||||||
|
)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
if self.cleaned_data["confirm"]:
|
if self.cleaned_data["confirm"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user