Feat: Assessment page completed with save method combining Assessment, Distraction, Assessment Command Modality Link, and Assessment Response save for creating new complete Assessnent.

This commit is contained in:
2025-07-28 22:41:38 +01:00
parent 1bbe6f0040
commit 574d60442a
122 changed files with 3261 additions and 1057 deletions

View File

@@ -56,10 +56,11 @@ class Assessment(SQLAlchemy_ABC, Base):
self.is_new = False
self.weather = None
self.lighting_level = None
self.temperature_celcius = 22
self.location = None
self.user_handler = None
self.distractions = None
self.assessment_command_modality_links = None
self.distractions = []
self.assessment_command_modality_links = []
super().__init__()
@classmethod
@@ -99,18 +100,15 @@ class Assessment(SQLAlchemy_ABC, Base):
_m = f'{cls.__qualname__}.from_json'
assessment = cls()
if json is None: return assessment
# Helper_App.console_log(f'{_m}\njson: {json}')
assessment.id_assessment = json.get(Assessment.ATTR_ID_ASSESSMENT, -1)
assessment.id_weather = json[Weather.ATTR_ID_WEATHER]
assessment.id_lighting_level = json[Lighting_Level.ATTR_ID_LIGHTING_LEVEL]
assessment.id_location = json[Location.ATTR_ID_LOCATION]
assessment.user_handler = json[cls.FLAG_USER_HANDLER]
assessment.id_user_handler = json[cls.FLAG_USER_HANDLER]
assessment.notes = json[cls.FLAG_NOTES]
assessment.temperature_celcius = json[cls.FLAG_TEMPERATURE_CELCIUS]
assessment.active = json[cls.FLAG_ACTIVE]
assessment.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
assessment.created_on = json.get(cls.FLAG_CREATED_ON, None)
# assessment.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
# Helper_App.console_log(f'Dog Command Link: {assessment}')
return assessment
def to_json(self):
@@ -129,8 +127,6 @@ class Assessment(SQLAlchemy_ABC, Base):
, self.FLAG_DISTRACTION: [distraction.to_json() for distraction in self.distractions] if (self.distractions is not None and len(self.distractions) > 0) else []
, self.FLAG_ASSESSMENT_COMMAND_MODALITY_LINK: [link.to_json() for link in self.assessment_command_modality_links] if (self.assessment_command_modality_links is not None and len(self.assessment_command_modality_links) > 0) else []
}
# , Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
# Helper_App.console_log(f'as_json: {as_json}')
return as_json
def __repr__(self):
@@ -283,8 +279,6 @@ class Parameters_Assessment(Get_Many_Parameters_Base):
@classmethod
def from_form_filters_assessment(cls, form):
_m = f'{cls.__qualname__}.from_form_filters_assessment'
Helper_App.console_log(_m)
Helper_App.console_log(f'Filters: {form}')
av.val_instance(form, 'form', _m, Filters_Assessment)
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
has_filter_weather = not (form.id_weather.data == '0' or form.id_weather.data == '' or form.id_weather.data is None)
@@ -292,14 +286,7 @@ class Parameters_Assessment(Get_Many_Parameters_Base):
has_filter_location = not (form.id_location.data == '0' or form.id_location.data == '' or form.id_location.data is None)
has_filter_user_handler = not (form.id_user_handler.data == '0' or form.id_user_handler.data == '' or form.id_user_handler.data is None)
active_only = av.input_bool(form.active_only.data, "active", _m)
Helper_App.console_log(f'''
has_filter_search_text: {has_filter_search_text}
has_filter_weather: {has_filter_weather}
has_filter_lighting_level: {has_filter_lighting_level}
has_filter_location: {has_filter_location}
has_filter_user_handler: {has_filter_user_handler}
active_only: {active_only}
''')
filters = cls.get_default()
filters.get_all_assessment = True
filters.get_inactive_assessment = not active_only