Recording data
* adds dynamic icon for recording and unrecording of data * adds record view to intervention and eco accounts * adds quality_check() method for Intervention and EcoAccount class which holds logic for data quality checking * adds UserAction "unrecorded"
This commit is contained in:
+48
-25
@@ -194,39 +194,62 @@ class Intervention(BaseObject):
|
||||
self.identifier = new_id
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def check_validity(self) -> (bool, dict):
|
||||
""" Validity check
|
||||
def quality_check(self) -> list:
|
||||
""" Quality check
|
||||
|
||||
Returns:
|
||||
ret_msgs (list): True if quality acceptable, False otherwise
|
||||
"""
|
||||
ret_msgs = []
|
||||
|
||||
self._check_quality_responsible_data(ret_msgs)
|
||||
self._check_quality_legal_data(ret_msgs)
|
||||
|
||||
# ToDo: Extend for more!
|
||||
|
||||
return ret_msgs
|
||||
|
||||
def _check_quality_responsible_data(self, ret_msgs: list):
|
||||
""" Checks data quality of related ResponsibilityData
|
||||
|
||||
Args:
|
||||
ret_msgs (dict): Holds error messages
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
ret_msgs = {}
|
||||
missing_str = _("Missing")
|
||||
not_missing_str = _("Exists")
|
||||
try:
|
||||
# Check for file numbers
|
||||
if not self.responsible.registration_file_number or len(self.responsible.registration_file_number) == 0:
|
||||
ret_msgs.append(_("Registration office file number missing"))
|
||||
|
||||
# Check responsible data
|
||||
if self.responsible:
|
||||
if self.responsible.registration_file_number is None or len(self.responsible.registration_file_number) == 0:
|
||||
ret_msgs["Registration office file number"] = missing_str
|
||||
if self.responsible.conservation_file_number is None or len(self.responsible.conservation_file_number) == 0:
|
||||
ret_msgs["Conversation office file number"] = missing_str
|
||||
else:
|
||||
ret_msgs["responsible"] = missing_str
|
||||
if not self.responsible.conservation_file_number or len(self.responsible.conservation_file_number) == 0:
|
||||
ret_msgs.append(_("Conversation office file number missing"))
|
||||
except AttributeError:
|
||||
# responsible data not found
|
||||
ret_msgs.append(_("Responsible data missing"))
|
||||
|
||||
# Check revocation
|
||||
if self.legal.revocation:
|
||||
ret_msgs["Revocation"] = not_missing_str
|
||||
def _check_quality_legal_data(self, ret_msgs: list):
|
||||
""" Checks data quality of related LegalData
|
||||
|
||||
Args:
|
||||
ret_msgs (dict): Holds error messages
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
try:
|
||||
# Check for a revocation
|
||||
if self.legal.revocation:
|
||||
ret_msgs.append(_("Revocation exists"))
|
||||
|
||||
if self.legal:
|
||||
if self.legal.registration_date is None:
|
||||
ret_msgs["Registration date"] = missing_str
|
||||
if self.legal.binding_date is None:
|
||||
ret_msgs["Binding on"] = missing_str
|
||||
else:
|
||||
ret_msgs["legal"] = missing_str
|
||||
ret_msgs.append(_("Registration date missing"))
|
||||
|
||||
ret_result = len(ret_msgs) == 0
|
||||
return ret_result, ret_msgs
|
||||
if self.legal.binding_date is None:
|
||||
ret_msgs.append(_("Binding on missing"))
|
||||
except AttributeError:
|
||||
ret_msgs.append(_("Legal data missing"))
|
||||
|
||||
def get_LANIS_link(self) -> str:
|
||||
""" Generates a link for LANIS depending on the geometry
|
||||
@@ -248,4 +271,4 @@ class Intervention(BaseObject):
|
||||
zoom_lvl,
|
||||
x,
|
||||
y,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user