#36 Quality checks

* adds quality check logic for Compensations with CompensationQUalityChecker
* adds compensation quality checking to checking routine of RunCheckModalForm.is_valid()
* adds/updates translations
This commit is contained in:
2021-10-25 13:44:54 +02:00
parent efd5b6bb98
commit ba04788064
6 changed files with 159 additions and 43 deletions

View File

@@ -0,0 +1,48 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 25.10.21
"""
from django.utils.translation import gettext_lazy as _, pgettext_lazy as _con
from konova.utils.quality import AbstractQualityChecker
class CompensationQualityChecker(AbstractQualityChecker):
def run_check(self):
""" Perform all defined data checks
Returns:
"""
self._check_states()
self._check_actions()
self._check_geometry()
self.valid = len(self.messages) == 0
def _check_states(self):
""" Checks data quality for related CompensationState objects
Returns:
"""
after_states = self.obj.get_surface_after_states()
before_states = self.obj.get_surface_before_states()
if after_states != before_states:
self.messages.append(
_("States unequal")
)
if before_states == 0:
self._add_missing_attr_name(_("States before"))
if after_states == 0:
self._add_missing_attr_name(_("States after"))
def _check_actions(self):
""" Checks data quality for related CompensationState objects
Returns:
"""
if not self.obj.actions.all():
self._add_missing_attr_name(_con("Compensation", "Actions"))