Improvements

* improves response and functionality
    * first test passed
    * repair() as main method currently commented out for production usage
This commit is contained in:
mpeltriaux 2023-03-13 07:47:35 +01:00
parent b941b4236e
commit bae1b90979

View File

@ -32,6 +32,8 @@ class Command(BaseKonovaCommand):
for entry in self.interventions: for entry in self.interventions:
self._write_warning(f"{entry.identifier};{entry.responsible.registration_file_number}; {entry.responsible.registration_office}, {list(entry.legal.laws.all())}") self._write_warning(f"{entry.identifier};{entry.responsible.registration_file_number}; {entry.responsible.registration_office}, {list(entry.legal.laws.all())}")
#self.repair()
def get_law(self): def get_law(self):
""" Returns the expected law (LBauO; id=1935994) """ Returns the expected law (LBauO; id=1935994)
@ -93,6 +95,7 @@ class Command(BaseKonovaCommand):
for entry in interventions: for entry in interventions:
self._repair_laws(entry) self._repair_laws(entry)
self._repair_registration_office(entry) self._repair_registration_office(entry)
self._repair_recording(entry)
def _repair_laws(self, entry): def _repair_laws(self, entry):
""" Fixes missing law """ Fixes missing law
@ -103,13 +106,12 @@ class Command(BaseKonovaCommand):
correct_law = self.get_law() correct_law = self.get_law()
laws = entry.legal.laws.all() laws = entry.legal.laws.all()
if correct_law not in laws: if correct_law not in laws:
laws.add(correct_law) entry.legal.laws.add(correct_law)
def _repair_registration_office(self, entry): def _repair_registration_office(self, entry):
""" Fixes missing registration office """ Fixes missing registration office
""" """
assert entry.responsible.registration_office is None
reg_office = self.get_registration_office() reg_office = self.get_registration_office()
entry.responsible.registration_office = reg_office entry.responsible.registration_office = reg_office
@ -144,4 +146,5 @@ class Command(BaseKonovaCommand):
coms_valid = False coms_valid = False
if coms_valid and intervention_valid: if coms_valid and intervention_valid:
self._write_success(f" {entry.identifier} recorded!")
entry.set_recorded(user=user) entry.set_recorded(user=user)