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:
@@ -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
|
||||
|
||||
@@ -33,7 +33,7 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_ASSESSMENT_COMMAND_MODALITY_LINK: ClassVar[str] = 'id_link'
|
||||
FLAG_ASSESSMENT_COMMAND_MODALITY_LINK: ClassVar[str] = Assessment.FLAG_ASSESSMENT_COMMAND_MODALITY_LINK
|
||||
FLAG_ASSESSMENT_RESPONSE: ClassVar[str] = 'assessment_response'
|
||||
FLAG_DISTANCE_FROM_HANDLER: ClassVar[str] = 'distance-from-handler'
|
||||
FLAG_DISTANCE_FROM_HANDLER_METRES: ClassVar[str] = 'distance-from-handler-metres'
|
||||
FLAG_IS_IN_HEARING_RANGE_OF_HANDLER: ClassVar[str] = 'is-in-hearing-range-of-handler'
|
||||
FLAG_IS_IN_SCENT_RANGE_OF_HANDLER: ClassVar[str] = 'is-in-scent-range-of-handler'
|
||||
FLAG_IS_IN_SIGHT_OF_HANDLER: ClassVar[str] = 'is-in-sight-of-handler'
|
||||
@@ -50,7 +50,7 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
id_command = db.Column(db.Integer)
|
||||
id_command_modality = db.Column(db.Integer)
|
||||
id_bribe = db.Column(db.Integer)
|
||||
distance_from_handler = db.Column(db.Float)
|
||||
distance_from_handler_metres = db.Column(db.Float)
|
||||
is_in_hearing_range_of_handler = db.Column(db.Boolean)
|
||||
is_in_scent_range_of_handler = db.Column(db.Boolean)
|
||||
is_in_sight_of_handler = db.Column(db.Boolean)
|
||||
@@ -78,7 +78,7 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
assessment_command_modality_link.id_command = query_row[5]
|
||||
assessment_command_modality_link.id_command_modality = query_row[7]
|
||||
assessment_command_modality_link.id_bribe = query_row[9]
|
||||
assessment_command_modality_link.distance_from_handler = query_row[11]
|
||||
assessment_command_modality_link.distance_from_handler_metres = query_row[11]
|
||||
assessment_command_modality_link.is_in_hearing_range_of_handler = av.input_bool(query_row[12], 'is_in_hearing_range_of_handler', _m)
|
||||
assessment_command_modality_link.is_in_scent_range_of_handler = av.input_bool(query_row[13], 'is_in_scent_range_of_handler', _m)
|
||||
assessment_command_modality_link.is_in_sight_of_handler = av.input_bool(query_row[14], 'is_in_sight_of_handler', _m)
|
||||
@@ -104,22 +104,19 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
assessment_command_modality_link = cls()
|
||||
if json is None: return assessment_command_modality_link
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
assessment_command_modality_link.id_link = json.get(Assessment_Command_Modality_Link.ATTR_ID_ASSESSMENT_COMMAND_MODALITY_LINK, -1)
|
||||
assessment_command_modality_link.id_assessment = json[Assessment.ATTR_ID_ASSESSMENT]
|
||||
assessment_command_modality_link.id_command = json[Command.ATTR_ID_COMMAND]
|
||||
assessment_command_modality_link.id_command_modality = json[Command_Modality.ATTR_ID_COMMAND_MODALITY]
|
||||
assessment_command_modality_link.id_bribe = json[Bribe.ATTR_ID_BRIBE]
|
||||
assessment_command_modality_link.distance_from_handler = json[cls.FLAG_DISTANCE_FROM_HANDLER]
|
||||
assessment_command_modality_link.is_in_hearing_range_of_handler = json[cls.FLAG_IS_IN_HEARING_RANGE_OF_HANDLER]
|
||||
assessment_command_modality_link.is_in_scent_range_of_handler = json[cls.FLAG_IS_IN_SCENT_RANGE_OF_HANDLER]
|
||||
assessment_command_modality_link.is_in_sight_of_handler = json[cls.FLAG_IS_IN_SIGHT_OF_HANDLER]
|
||||
assessment_command_modality_link.is_on_lead = json[cls.FLAG_IS_ON_LEAD]
|
||||
assessment_command_modality_link.trial_count = json[cls.FLAG_TRIAL_COUNT]
|
||||
assessment_command_modality_link.active = json[cls.FLAG_ACTIVE]
|
||||
assessment_command_modality_link.distance_from_handler_metres = json[cls.FLAG_DISTANCE_FROM_HANDLER_METRES]
|
||||
assessment_command_modality_link.is_in_hearing_range_of_handler = av.input_bool(json[cls.FLAG_IS_IN_HEARING_RANGE_OF_HANDLER], cls.FLAG_IS_IN_HEARING_RANGE_OF_HANDLER, _m)
|
||||
assessment_command_modality_link.is_in_scent_range_of_handler = av.input_bool(json[cls.FLAG_IS_IN_SCENT_RANGE_OF_HANDLER], cls.FLAG_IS_IN_SCENT_RANGE_OF_HANDLER, _m)
|
||||
assessment_command_modality_link.is_in_sight_of_handler = av.input_bool(json[cls.FLAG_IS_IN_SIGHT_OF_HANDLER], cls.FLAG_IS_IN_SIGHT_OF_HANDLER, _m)
|
||||
assessment_command_modality_link.is_on_lead = av.input_bool(json[cls.FLAG_IS_ON_LEAD], cls.FLAG_IS_ON_LEAD, _m)
|
||||
assessment_command_modality_link.trial_count = json.get(cls.FLAG_TRIAL_COUNT)
|
||||
assessment_command_modality_link.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
assessment_command_modality_link.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# assessment_command_modality_link.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
# Helper_App.console_log(f'Dog Command Link: {assessment_command_modality_link}')
|
||||
return assessment_command_modality_link
|
||||
|
||||
def to_json(self):
|
||||
@@ -130,7 +127,7 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
, Command.ATTR_ID_COMMAND: { Command.ATTR_ID_COMMAND: None } if self.command is None else self.command.to_json()
|
||||
, Command_Modality.ATTR_ID_COMMAND_MODALITY: { Command_Modality.ATTR_ID_COMMAND_MODALITY: None } if self.command_modality is None else self.command_modality.to_json()
|
||||
, Bribe.FLAG_BRIBE: { Bribe.FLAG_BRIBE: None } if self.bribe is None else self.bribe.to_json()
|
||||
, self.FLAG_DISTANCE_FROM_HANDLER: self.distance_from_handler
|
||||
, self.FLAG_DISTANCE_FROM_HANDLER_METRES: self.distance_from_handler_metres
|
||||
, self.FLAG_IS_IN_HEARING_RANGE_OF_HANDLER: self.is_in_hearing_range_of_handler
|
||||
, self.FLAG_IS_IN_SCENT_RANGE_OF_HANDLER: self.is_in_scent_range_of_handler
|
||||
, self.FLAG_IS_IN_SIGHT_OF_HANDLER: self.is_in_sight_of_handler
|
||||
@@ -140,8 +137,6 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
, self.FLAG_ASSESSMENT_RESPONSE: [] if self.assessment_responses is None else [response.to_json() for response in self.assessment_responses]
|
||||
}
|
||||
# , Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
@@ -152,7 +147,7 @@ class Assessment_Command_Modality_Link(SQLAlchemy_ABC, Base):
|
||||
{Command.FLAG_COMMAND}: {self.command}
|
||||
{Command_Modality.FLAG_COMMAND_MODALITY}: {self.command_modality}
|
||||
{Bribe.FLAG_BRIBE}: {self.bribe}
|
||||
{self.FLAG_DISTANCE_FROM_HANDLER}: {self.distance_from_handler}
|
||||
{self.FLAG_DISTANCE_FROM_HANDLER_METRES}: {self.distance_from_handler_metres}
|
||||
{self.FLAG_IS_IN_HEARING_RANGE_OF_HANDLER}: {self.is_in_hearing_range_of_handler}
|
||||
{self.FLAG_IS_IN_SCENT_RANGE_OF_HANDLER}: {self.is_in_scent_range_of_handler}
|
||||
{self.FLAG_IS_IN_SIGHT_OF_HANDLER}: {self.is_in_sight_of_handler}
|
||||
@@ -173,7 +168,7 @@ class Assessment_Command_Modality_Link_Temp(db.Model, Base):
|
||||
id_command = db.Column(db.Integer)
|
||||
id_command_modality = db.Column(db.Integer)
|
||||
id_bribe = db.Column(db.Integer)
|
||||
distance_from_handler = db.Column(db.Float)
|
||||
distance_from_handler_metres = db.Column(db.Float)
|
||||
is_in_hearing_range_of_handler = db.Column(db.Boolean)
|
||||
is_in_scent_range_of_handler = db.Column(db.Boolean)
|
||||
is_in_sight_of_handler = db.Column(db.Boolean)
|
||||
@@ -195,7 +190,7 @@ class Assessment_Command_Modality_Link_Temp(db.Model, Base):
|
||||
temp.id_command = assessment_command_modality_link.id_command
|
||||
temp.id_command_modality = assessment_command_modality_link.id_command_modality
|
||||
temp.id_bribe = assessment_command_modality_link.id_bribe
|
||||
temp.distance_from_handler = assessment_command_modality_link.distance_from_handler
|
||||
temp.distance_from_handler_metres = assessment_command_modality_link.distance_from_handler_metres
|
||||
temp.is_in_hearing_range_of_handler = assessment_command_modality_link.is_in_hearing_range_of_handler
|
||||
temp.is_in_scent_range_of_handler = assessment_command_modality_link.is_in_scent_range_of_handler
|
||||
temp.is_in_sight_of_handler = assessment_command_modality_link.is_in_sight_of_handler
|
||||
@@ -210,8 +205,8 @@ class Parameters_Assessment_Command_Modality_Link(Get_Many_Parameters_Base):
|
||||
get_all_link: bool
|
||||
get_inactive_link: bool
|
||||
ids_link: str
|
||||
min_distance_from_handler_link: Optional[float]
|
||||
max_distance_from_handler_link: Optional[float]
|
||||
min_distance_from_handler_metres_link: Optional[float]
|
||||
max_distance_from_handler_metres_link: Optional[float]
|
||||
value_is_in_sight_of_handler_link: Optional[bool]
|
||||
value_is_in_scent_range_of_handler_link: Optional[bool]
|
||||
value_is_in_hearing_range_of_handler_link: Optional[bool]
|
||||
@@ -276,8 +271,8 @@ class Parameters_Assessment_Command_Modality_Link(Get_Many_Parameters_Base):
|
||||
get_all_link = True
|
||||
, get_inactive_link = False
|
||||
, ids_link = ''
|
||||
, min_distance_from_handler_link = None
|
||||
, max_distance_from_handler_link = None
|
||||
, min_distance_from_handler_metres_link = None
|
||||
, max_distance_from_handler_metres_link = None
|
||||
, value_is_in_sight_of_handler_link = None
|
||||
, value_is_in_scent_range_of_handler_link = None
|
||||
, value_is_in_hearing_range_of_handler_link = None
|
||||
@@ -344,8 +339,8 @@ class Parameters_Assessment_Command_Modality_Link(Get_Many_Parameters_Base):
|
||||
, get_inactive_link = json.get('a_get_inactive_link', False)
|
||||
, ids_link = json.get('a_ids_link', '')
|
||||
, notes_assessment_command_modality_link = json.get('a_notes_assessment_command_modality_link', '')
|
||||
, min_distance_from_handler_link = json.get('a_min_distance_from_handler_link', None)
|
||||
, max_distance_from_handler_link = json.get('a_max_distance_from_handler_link', None)
|
||||
, min_distance_from_handler_metres_link = json.get('a_min_distance_from_handler_metres_link', None)
|
||||
, max_distance_from_handler_metres_link = json.get('a_max_distance_from_handler_metres_link', None)
|
||||
, value_is_in_sight_of_handler_link = json.get('a_value_is_in_sight_of_handler_link', None)
|
||||
, value_is_in_scent_range_of_handler_link = json.get('a_value_is_in_scent_range_of_handler_link', None)
|
||||
, value_is_in_hearing_range_of_handler_link = json.get('a_value_is_in_hearing_range_of_handler_link', None)
|
||||
@@ -408,8 +403,6 @@ class Parameters_Assessment_Command_Modality_Link(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_assessment = not (form.id_assessment.data == '0' or form.id_assessment.data == '' or form.id_assessment.data is None)
|
||||
@@ -417,14 +410,7 @@ class Parameters_Assessment_Command_Modality_Link(Get_Many_Parameters_Base):
|
||||
has_filter_command_modality = False
|
||||
has_filter_bribe = False
|
||||
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_assessment: {has_filter_assessment}
|
||||
has_filter_command: {has_filter_command}
|
||||
has_filter_command_modality: {has_filter_command_modality}
|
||||
has_filter_bribe: {has_filter_bribe}
|
||||
active_only: {active_only}
|
||||
''')
|
||||
|
||||
filters = cls.get_default()
|
||||
filters.get_all_link = True
|
||||
filters.get_inactive_link = not active_only
|
||||
@@ -451,8 +437,8 @@ active_only: {active_only}
|
||||
'a_get_all_link': self.get_all_link
|
||||
, 'a_get_inactive_link': self.get_inactive_link
|
||||
, 'a_ids_link': self.ids_link
|
||||
, 'a_min_distance_from_handler_link': self.min_distance_from_handler_link
|
||||
, 'a_max_distance_from_handler_link': self.max_distance_from_handler_link
|
||||
, 'a_min_distance_from_handler_metres_link': self.min_distance_from_handler_metres_link
|
||||
, 'a_max_distance_from_handler_metres_link': self.max_distance_from_handler_metres_link
|
||||
, 'a_value_is_in_sight_of_handler_link': self.value_is_in_sight_of_handler_link
|
||||
, 'a_value_is_in_scent_range_of_handler_link': self.value_is_in_scent_range_of_handler_link
|
||||
, 'a_value_is_in_hearing_range_of_handler_link': self.value_is_in_hearing_range_of_handler_link
|
||||
|
||||
@@ -61,10 +61,10 @@ class Assessment_Response(SQLAlchemy_ABC, Base):
|
||||
assessment_response.id_response = query_row[0]
|
||||
assessment_response.id_assessment_command_modality_link = query_row[1]
|
||||
assessment_response.id_response_quality_metric = query_row[2]
|
||||
assessment_response.id_obedience_level = query_row[3]
|
||||
assessment_response.value_measured = query_row[11]
|
||||
assessment_response.notes = query_row[10]
|
||||
assessment_response.active = av.input_bool(query_row[12], 'active', _m)
|
||||
assessment_response.id_obedience_level = query_row[4]
|
||||
assessment_response.value_measured = query_row[6]
|
||||
assessment_response.notes = query_row[7]
|
||||
assessment_response.active = av.input_bool(query_row[8], 'active', _m)
|
||||
|
||||
assessment_response.assessment_command_modality_link = Assessment_Command_Modality_Link.from_db_assessment_response(query_row)
|
||||
assessment_response.response_quality_metric = Response_Quality_Metric.from_db_assessment_response(query_row)
|
||||
@@ -76,17 +76,14 @@ class Assessment_Response(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
assessment_response = cls()
|
||||
if json is None: return assessment_response
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
assessment_response.id_response = json.get(Assessment_Response.ATTR_ID_ASSESSMENT_RESPONSE, -1)
|
||||
assessment_response.id_assessment_command_modality_link = json[Assessment_Command_Modality_Link.ATTR_ID_ASSESSMENT_COMMAND_MODALITY_LINK]
|
||||
assessment_response.id_response_quality_metric = json[Response_Quality_Metric.ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC]
|
||||
assessment_response.id_response_quality_metric = json[Response_Quality_Metric.ATTR_ID_RESPONSE_QUALITY_METRIC]
|
||||
assessment_response.id_obedience_level = json[Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL]
|
||||
assessment_response.value_measured = json[cls.FLAG_VALUE_MEASURED]
|
||||
assessment_response.notes = json[cls.FLAG_NOTES]
|
||||
assessment_response.active = json[cls.FLAG_ACTIVE]
|
||||
assessment_response.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
assessment_response.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# assessment_response.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
# Helper_App.console_log(f'Dog Command Link: {assessment_response}')
|
||||
return assessment_response
|
||||
|
||||
def to_json(self):
|
||||
@@ -94,15 +91,13 @@ class Assessment_Response(SQLAlchemy_ABC, Base):
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_ASSESSMENT_RESPONSE: self.id_response
|
||||
, Assessment_Command_Modality_Link.ATTR_ID_ASSESSMENT_COMMAND_MODALITY_LINK: { Assessment_Command_Modality_Link.ATTR_ID_ASSESSMENT_COMMAND_MODALITY_LINK: None } if self.assessment_command_modality_link is None else self.assessment_command_modality_link.to_json()
|
||||
, Response_Quality_Metric.ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC: { Response_Quality_Metric.ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC: None } if self.response_quality_metric is None else self.response_quality_metric.to_json()
|
||||
, Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL: { Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL: None } if self.assessment_command_modality_link is None else self.assessment_command_modality_link.to_json()
|
||||
, Response_Quality_Metric.ATTR_ID_RESPONSE_QUALITY_METRIC: { Response_Quality_Metric.ATTR_ID_RESPONSE_QUALITY_METRIC: None } if self.response_quality_metric is None else self.response_quality_metric.to_json()
|
||||
, Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL: { Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL: None } if self.obedience_level is None else self.obedience_level.to_json()
|
||||
, self.FLAG_VALUE_MEASURED: self.value_measured
|
||||
, self.FLAG_NOTES: self.notes
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
# , Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
@@ -163,8 +158,8 @@ class Parameters_Assessment_Response(Get_Many_Parameters_Base):
|
||||
get_all_ACM_link: bool
|
||||
get_inactive_ACM_link: bool
|
||||
ids_ACM_link: str
|
||||
min_distance_from_handler_ACM_link: Optional[float]
|
||||
max_distance_from_handler_ACM_link: Optional[float]
|
||||
min_distance_from_handler_metres_ACM_link: Optional[float]
|
||||
max_distance_from_handler_metres_ACM_link: Optional[float]
|
||||
value_is_in_sight_of_handler_ACM_link: Optional[bool]
|
||||
value_is_in_scent_range_of_handler_ACM_link: Optional[bool]
|
||||
value_is_in_hearing_range_of_handler_ACM_link: Optional[bool]
|
||||
@@ -242,8 +237,8 @@ class Parameters_Assessment_Response(Get_Many_Parameters_Base):
|
||||
, get_all_ACM_link = True
|
||||
, get_inactive_ACM_link = False
|
||||
, ids_ACM_link = ''
|
||||
, min_distance_from_handler_ACM_link = None
|
||||
, max_distance_from_handler_ACM_link = None
|
||||
, min_distance_from_handler_metres_ACM_link = None
|
||||
, max_distance_from_handler_metres_ACM_link = None
|
||||
, value_is_in_sight_of_handler_ACM_link = None
|
||||
, value_is_in_scent_range_of_handler_ACM_link = None
|
||||
, value_is_in_hearing_range_of_handler_ACM_link = None
|
||||
@@ -323,8 +318,8 @@ class Parameters_Assessment_Response(Get_Many_Parameters_Base):
|
||||
, get_inactive_ACM_link = json.get('a_get_inactive_ACM_link', False)
|
||||
, ids_ACM_link = json.get('a_ids_ACM_link', '')
|
||||
, notes_assessment_command_modality_link = json.get('a_notes_assessment_command_modality_link', '')
|
||||
, min_distance_from_handler_ACM_link = json.get('a_min_distance_from_handler_ACM_link', None)
|
||||
, max_distance_from_handler_ACM_link = json.get('a_max_distance_from_handler_ACM_link', None)
|
||||
, min_distance_from_handler_metres_ACM_link = json.get('a_min_distance_from_handler_metres_ACM_link', None)
|
||||
, max_distance_from_handler_metres_ACM_link = json.get('a_max_distance_from_handler_metres_ACM_link', None)
|
||||
, value_is_in_sight_of_handler_ACM_link = json.get('a_value_is_in_sight_of_handler_ACM_link', None)
|
||||
, value_is_in_scent_range_of_handler_ACM_link = json.get('a_value_is_in_scent_range_of_handler_ACM_link', None)
|
||||
, value_is_in_hearing_range_of_handler_ACM_link = json.get('a_value_is_in_hearing_range_of_handler_ACM_link', None)
|
||||
@@ -393,8 +388,6 @@ class Parameters_Assessment_Response(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_assessment_command_modality_link = False
|
||||
@@ -403,14 +396,7 @@ class Parameters_Assessment_Response(Get_Many_Parameters_Base):
|
||||
has_filter_user_handler = False
|
||||
has_filter_assessment = not (form.id_assessment.data == '' or form.id_assessment.data == '0' or form.id_assessment.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_assessment_command_modality_link: {has_filter_assessment_command_modality_link}
|
||||
has_filter_response_quality_metric: {has_filter_response_quality_metric}
|
||||
has_filter_obedience_level: {has_filter_obedience_level}
|
||||
has_filter_user_handler: {has_filter_user_handler}
|
||||
active_only: {active_only}
|
||||
''')
|
||||
|
||||
filters = cls.get_default()
|
||||
filters.get_all_assessment_response = True
|
||||
filters.get_inactive_assessment_response = not active_only
|
||||
@@ -448,8 +434,8 @@ active_only: {active_only}
|
||||
, 'a_get_all_ACM_link': self.get_all_ACM_link
|
||||
, 'a_get_inactive_ACM_link': self.get_inactive_ACM_link
|
||||
, 'a_ids_ACM_link': self.ids_ACM_link
|
||||
, 'a_min_distance_from_handler_ACM_link': self.min_distance_from_handler_ACM_link
|
||||
, 'a_max_distance_from_handler_ACM_link': self.max_distance_from_handler_ACM_link
|
||||
, 'a_min_distance_from_handler_metres_ACM_link': self.min_distance_from_handler_metres_ACM_link
|
||||
, 'a_max_distance_from_handler_metres_ACM_link': self.max_distance_from_handler_metres_ACM_link
|
||||
, 'a_value_is_in_sight_of_handler_ACM_link': self.value_is_in_sight_of_handler_ACM_link
|
||||
, 'a_value_is_in_scent_range_of_handler_ACM_link': self.value_is_in_scent_range_of_handler_ACM_link
|
||||
, 'a_value_is_in_hearing_range_of_handler_ACM_link': self.value_is_in_hearing_range_of_handler_ACM_link
|
||||
|
||||
@@ -71,12 +71,10 @@ class Bribe(SQLAlchemy_ABC, Base):
|
||||
_m = 'Bribe.from_json'
|
||||
bribe = cls()
|
||||
if json is None: return Bribe
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
bribe.id_bribe = json.get(cls.ATTR_ID_BRIBE, -1)
|
||||
bribe.name = json[cls.FLAG_NAME]
|
||||
bribe.code = json.get(cls.FLAG_CODE, bribe.name.upper().replace(" ", "_"))
|
||||
bribe.active = json[cls.FLAG_ACTIVE]
|
||||
# Helper_App.console_log(f'Bribe: {bribe}')
|
||||
bribe.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
return bribe
|
||||
|
||||
|
||||
@@ -88,7 +86,6 @@ class Bribe(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -72,15 +72,13 @@ class Button_Icon(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
button_icon = cls()
|
||||
if json is None: return button_icon
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
button_icon.id_button_icon = json.get(Button_Icon.ATTR_ID_BUTTON_ICON, -1)
|
||||
button_icon.id_image = json[Image.FLAG_IMAGE]
|
||||
button_icon.name = json[cls.FLAG_NAME]
|
||||
button_icon.code = json.get(cls.FLAG_CODE, button_icon.name.upper().replace(" ", "_"))
|
||||
button_icon.notes = json[cls.FLAG_NOTES]
|
||||
button_icon.active = json[cls.FLAG_ACTIVE]
|
||||
button_icon.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
button_icon.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Button_Icon: {button_icon}')
|
||||
return button_icon
|
||||
|
||||
def to_json(self):
|
||||
@@ -94,7 +92,6 @@ class Button_Icon(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -66,14 +66,12 @@ class Button_Shape(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
button_shape = cls()
|
||||
if json is None: return button_shape
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
button_shape.id_button_shape = json.get(Button_Shape.ATTR_ID_BUTTON_SHAPE, -1)
|
||||
button_shape.name = json[cls.FLAG_NAME]
|
||||
button_shape.code = json.get(cls.FLAG_CODE, button_shape.name.upper().replace(" ", "_"))
|
||||
button_shape.notes = json[cls.FLAG_NOTES]
|
||||
button_shape.active = json[cls.FLAG_ACTIVE]
|
||||
button_shape.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
button_shape.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Button_Shape: {button_shape}')
|
||||
return button_shape
|
||||
|
||||
def to_json(self):
|
||||
@@ -86,7 +84,6 @@ class Button_Shape(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -64,13 +64,11 @@ class Colour(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
colour = cls()
|
||||
if json is None: return colour
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
colour.id_colour = json.get(Colour.ATTR_ID_COLOUR, -1)
|
||||
colour.name = json[cls.FLAG_NAME]
|
||||
colour.code = json.get(cls.FLAG_CODE, colour.name.upper().replace(" ", "_"))
|
||||
colour.active = json[cls.FLAG_ACTIVE]
|
||||
colour.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
colour.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Colour: {colour}')
|
||||
return colour
|
||||
|
||||
def to_json(self):
|
||||
@@ -82,7 +80,6 @@ class Colour(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -112,7 +112,7 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
command.hand_signal_default_description = json[cls.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION]
|
||||
command.can_have_button = json[cls.FLAG_CAN_HAVE_BUTTON]
|
||||
command.notes = json[cls.FLAG_NOTES]
|
||||
command.active = json[cls.FLAG_ACTIVE]
|
||||
command.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
command.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Command: {command}')
|
||||
return command
|
||||
|
||||
@@ -79,17 +79,14 @@ class Command_Button_Link(SQLAlchemy_ABC, Base):
|
||||
_m = 'Command_Button_Link.from_json'
|
||||
command_button_link = cls()
|
||||
if json is None: return command_button_link
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
command_button_link.id_link = json.get(Command_Button_Link.ATTR_ID_COMMAND_BUTTON_LINK, -1)
|
||||
command_button_link.id_command = json[Command.FLAG_COMMAND]
|
||||
command_button_link.id_button_shape = json[Button_Shape.FLAG_BUTTON_SHAPE]
|
||||
command_button_link.id_button_colour = json[Colour.FLAG_COLOUR]
|
||||
command_button_link.id_button_icon = json[Button_Icon.FLAG_BUTTON_ICON]
|
||||
command_button_link.id_location = json[Location.FLAG_LOCATION]
|
||||
command_button_link.active = json[cls.FLAG_ACTIVE]
|
||||
command_button_link.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
command_button_link.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# command_button_link.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
# Helper_App.console_log(f'Dog Command Link: {command_button_link}')
|
||||
return command_button_link
|
||||
|
||||
def to_json(self):
|
||||
@@ -104,8 +101,6 @@ class Command_Button_Link(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
# , Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
@@ -299,8 +294,6 @@ class Parameters_Command_Button_Link(Get_Many_Parameters_Base):
|
||||
@classmethod
|
||||
def from_form_filters_command_button_link(cls, form):
|
||||
_m = f'{cls.__qualname__}.from_form_filters_command_button_link'
|
||||
Helper_App.console_log(_m)
|
||||
Helper_App.console_log(f'Filters: {form}')
|
||||
av.val_instance(form, 'form', _m, Filters_Command_Button_Link)
|
||||
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
|
||||
has_filter_command_category = not (form.id_command_category.data == '0' or form.id_command_category.data == '' or form.id_command_category.data is None)
|
||||
@@ -310,16 +303,7 @@ class Parameters_Command_Button_Link(Get_Many_Parameters_Base):
|
||||
has_filter_button_icon = not (form.id_button_icon.data == '0' or form.id_button_icon.data == '' or form.id_button_icon.data is None)
|
||||
has_filter_location = not (form.id_location.data == '0' or form.id_location.data == '' or form.id_location.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_command_category: {has_filter_command_category}
|
||||
has_filter_command: {has_filter_command}
|
||||
has_filter_button_shape: {has_filter_button_shape}
|
||||
has_filter_colour: {has_filter_colour}
|
||||
has_filter_button_icon: {has_filter_button_icon}
|
||||
has_filter_location: {has_filter_location}
|
||||
active_only: {active_only}
|
||||
''')
|
||||
|
||||
filters = cls.get_default()
|
||||
filters.get_all_link = True
|
||||
filters.get_inactive_link = not active_only
|
||||
|
||||
@@ -85,7 +85,7 @@ class Command_Category(SQLAlchemy_ABC, Base):
|
||||
command_category.id_command_category = json.get(cls.ATTR_ID_COMMAND_CATEGORY, -1)
|
||||
command_category.name = json[cls.FLAG_NAME]
|
||||
command_category.code = json.get(cls.FLAG_CODE, command_category.name.upper().replace(" ", "_"))
|
||||
command_category.active = json[cls.FLAG_ACTIVE]
|
||||
command_category.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
# Helper_App.console_log(f'Command_Category: {command_category}')
|
||||
return command_category
|
||||
|
||||
|
||||
@@ -71,12 +71,10 @@ class Command_Modality(SQLAlchemy_ABC, Base):
|
||||
_m = 'Command_Modality.from_json'
|
||||
command_modality = cls()
|
||||
if json is None: return Command_Modality
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
command_modality.id_command_modality = json.get(cls.ATTR_ID_COMMAND_MODALITY, -1)
|
||||
command_modality.name = json[cls.FLAG_NAME]
|
||||
command_modality.code = json.get(cls.FLAG_CODE, command_modality.name.upper().replace(" ", "_"))
|
||||
command_modality.active = json[cls.FLAG_ACTIVE]
|
||||
# Helper_App.console_log(f'Command_Modality: {command_modality}')
|
||||
command_modality.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
return command_modality
|
||||
|
||||
|
||||
@@ -88,7 +86,6 @@ class Command_Modality(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -111,7 +111,7 @@ class Distraction(SQLAlchemy_ABC, Base):
|
||||
distraction.quantity = json[cls.FLAG_QUANTITY]
|
||||
distraction.proximity_metres = json[cls.FLAG_PROXIMITY_METRES]
|
||||
distraction.notes = json[cls.FLAG_NOTES]
|
||||
distraction.active = json[cls.FLAG_ACTIVE]
|
||||
distraction.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
distraction.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# distraction.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
# Helper_App.console_log(f'Dog Command Link: {distraction}')
|
||||
|
||||
@@ -102,7 +102,7 @@ class Distraction_Intensity_Level(SQLAlchemy_ABC, Base):
|
||||
distraction_intensity_level.id_intensity_level = json.get(cls.ATTR_ID_DISTRACTION_INTENSITY_LEVEL, -1)
|
||||
distraction_intensity_level.name = json[cls.FLAG_NAME]
|
||||
distraction_intensity_level.code = json.get(cls.FLAG_CODE, distraction_intensity_level.name.upper().replace(" ", "_"))
|
||||
distraction_intensity_level.active = json[cls.FLAG_ACTIVE]
|
||||
distraction_intensity_level.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
# Helper_App.console_log(f'Distraction_Intensity_Level: {distraction_intensity_level}')
|
||||
return distraction_intensity_level
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class Distraction_Type(SQLAlchemy_ABC, Base):
|
||||
distraction_type.id_distraction_type = json.get(cls.ATTR_ID_DISTRACTION_TYPE, -1)
|
||||
distraction_type.name = json[cls.FLAG_NAME]
|
||||
distraction_type.code = json.get(cls.FLAG_CODE, distraction_type.name.upper().replace(" ", "_"))
|
||||
distraction_type.active = json[cls.FLAG_ACTIVE]
|
||||
distraction_type.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
# Helper_App.console_log(f'Distraction_Type: {distraction_type}')
|
||||
return distraction_type
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
dog.appearance = json[cls.FLAG_APPEARANCE]
|
||||
dog.mass_kg = json[cls.FLAG_MASS_KG]
|
||||
dog.notes = json[cls.FLAG_NOTES]
|
||||
dog.active = json[cls.FLAG_ACTIVE]
|
||||
dog.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
# Helper_App.console_log(f'Dog: {dog}')
|
||||
return dog
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
dog_command_link.id_command = json[Command.ATTR_ID_COMMAND]
|
||||
dog_command_link.hand_signal_description = json[cls.FLAG_HAND_SIGNAL_DESCRIPTION]
|
||||
dog_command_link.notes = json[cls.FLAG_NOTES]
|
||||
dog_command_link.active = json[cls.FLAG_ACTIVE]
|
||||
dog_command_link.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
dog_command_link.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# dog_command_link.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
# Helper_App.console_log(f'Dog Command Link: {dog_command_link}')
|
||||
@@ -221,21 +221,13 @@ class Parameters_Dog_Command_Link(Get_Many_Parameters_Base):
|
||||
@classmethod
|
||||
def from_form_filters_dog_command_link(cls, form):
|
||||
_m = f'{cls.__qualname__}.from_form_filters_dog_command_link'
|
||||
Helper_App.console_log(_m)
|
||||
Helper_App.console_log(f'Filters: {form}')
|
||||
av.val_instance(form, 'form', _m, Filters_Dog_Command_Link)
|
||||
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
|
||||
has_filter_dog = not (form.id_dog.data == '0' or form.id_dog.data == '' or form.id_dog.data is None)
|
||||
has_filter_command_category = not (form.id_command_category.data == '0' or form.id_command_category.data == '' or form.id_command_category.data is None)
|
||||
has_filter_command = not (form.id_command.data == '0' or form.id_command.data == '' or form.id_command.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_dog: {has_filter_dog}
|
||||
has_filter_command_category: {has_filter_command_category}
|
||||
has_filter_command: {has_filter_command}
|
||||
active_only: {active_only}
|
||||
''')
|
||||
|
||||
filters = cls.get_default()
|
||||
filters.get_all_link = True
|
||||
filters.get_inactive_link = not active_only
|
||||
|
||||
@@ -85,7 +85,7 @@ class Image(SQLAlchemy_ABC, Base):
|
||||
image.id_dog = json[Dog.FLAG_DOG]
|
||||
image.path = json[cls.FLAG_PATH]
|
||||
image.name = json[cls.FLAG_NAME]
|
||||
image.active = json[cls.FLAG_ACTIVE]
|
||||
image.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
image.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Image: {image}')
|
||||
return image
|
||||
|
||||
@@ -68,7 +68,7 @@ class Lighting_Level(SQLAlchemy_ABC, Base):
|
||||
lighting_level.id_lighting_level = json.get(Lighting_Level.ATTR_ID_LIGHTING_LEVEL, -1)
|
||||
lighting_level.name = json[cls.FLAG_NAME]
|
||||
lighting_level.code = json.get(cls.FLAG_CODE, lighting_level.name.upper().replace(" ", "_"))
|
||||
lighting_level.active = json[cls.FLAG_ACTIVE]
|
||||
lighting_level.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
lighting_level.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Lighting_Level: {lighting_level}')
|
||||
return lighting_level
|
||||
|
||||
@@ -85,7 +85,7 @@ class Location(SQLAlchemy_ABC, Base):
|
||||
location.id_location_parent = json[Location.FLAG_LOCATION_PARENT]
|
||||
location.name = json[cls.FLAG_NAME]
|
||||
location.code = json.get(cls.FLAG_CODE, location.name.upper().replace(" ", "_"))
|
||||
location.active = json[cls.FLAG_ACTIVE]
|
||||
location.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
location.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Location: {location}')
|
||||
return location
|
||||
|
||||
@@ -61,12 +61,10 @@ class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
obedience_level = cls()
|
||||
if json is None: return Obedience_Level
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
obedience_level.id_obedience_level = json.get(Obedience_Level.ATTR_ID_OBEDIENCE_LEVEL, -1)
|
||||
obedience_level.code = json[cls.FLAG_CODE]
|
||||
obedience_level.name = json[cls.FLAG_NAME]
|
||||
obedience_level.active = json[cls.FLAG_ACTIVE]
|
||||
Helper_App.console_log(f'Obedience_Level: {obedience_level}')
|
||||
obedience_level.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
return obedience_level
|
||||
|
||||
|
||||
@@ -78,7 +76,6 @@ class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -20,11 +20,11 @@ from typing import ClassVar
|
||||
|
||||
|
||||
class Response_Quality_Metric(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC: ClassVar[str] = 'id_response_quality_metric'
|
||||
ATTR_ID_RESPONSE_QUALITY_METRIC: ClassVar[str] = 'id_response_quality_metric'
|
||||
FLAG_RESPONSE_QUALITY_METRIC: ClassVar[str] = 'response-quality-metric'
|
||||
FLAG_VALUE_MIN: ClassVar[str] = 'value-min'
|
||||
FLAG_VALUE_MAX: ClassVar[str] = 'value-max'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_RESPONSE_QUALITY_METRIC
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
|
||||
__tablename__ = 'DOG_Response_Quality_Metric'
|
||||
@@ -47,25 +47,26 @@ class Response_Quality_Metric(SQLAlchemy_ABC, Base):
|
||||
@classmethod
|
||||
def from_db_response_quality_metric(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_response_quality_metric'
|
||||
response = cls()
|
||||
response.id_response_quality_metric = query_row[0]
|
||||
response.id_unit_measurement = query_row[1]
|
||||
response.code = query_row[5]
|
||||
response.name = query_row[6]
|
||||
response.value_min = query_row[7]
|
||||
response.value_max = query_row[8]
|
||||
response.active = av.input_bool(query_row[9], 'active', _m)
|
||||
response.unit_measurement = Unit_Measurement.from_db_response_quality_metric(query_row)
|
||||
return response
|
||||
metric = cls()
|
||||
metric.id_response_quality_metric = query_row[0]
|
||||
metric.id_unit_measurement = query_row[1]
|
||||
metric.code = query_row[5]
|
||||
metric.name = query_row[6]
|
||||
metric.value_min = query_row[7]
|
||||
metric.value_max = query_row[8]
|
||||
metric.active = av.input_bool(query_row[9], 'active', _m)
|
||||
metric.unit_measurement = Unit_Measurement.from_db_response_quality_metric(query_row)
|
||||
return metric
|
||||
|
||||
@classmethod
|
||||
def from_db_assessment_response(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_assessment_response'
|
||||
level = cls()
|
||||
level.id_response_quality_metric = query_row[2]
|
||||
level.name = query_row[3]
|
||||
level.active = True
|
||||
return level
|
||||
metric = cls()
|
||||
metric.id_response_quality_metric = query_row[2]
|
||||
metric.name = query_row[3]
|
||||
metric.active = True
|
||||
metric.unit_measurement = Unit_Measurement.from_db_assessment_response(query_row)
|
||||
return metric
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
@@ -73,12 +74,12 @@ class Response_Quality_Metric(SQLAlchemy_ABC, Base):
|
||||
response_quality_metric = cls()
|
||||
if json is None: return Response_Quality_Metric
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
response_quality_metric.id_response_quality_metric = json.get(cls.ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC, -1)
|
||||
response_quality_metric.id_response_quality_metric = json.get(cls.ATTR_ID_RESPONSE_QUALITY_METRIC, -1)
|
||||
response_quality_metric.name = json[cls.FLAG_NAME]
|
||||
response_quality_metric.code = json.get(cls.FLAG_CODE, response_quality_metric.name.upper().replace(" ", "_"))
|
||||
response_quality_metric.value_min = json[cls.FLAG_VALUE_MIN]
|
||||
response_quality_metric.value_max = json[cls.FLAG_VALUE_MAX]
|
||||
response_quality_metric.active = json[cls.FLAG_ACTIVE]
|
||||
response_quality_metric.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
# Helper_App.console_log(f'Response_Quality_Metric: {response_quality_metric}')
|
||||
return response_quality_metric
|
||||
|
||||
@@ -86,7 +87,7 @@ class Response_Quality_Metric(SQLAlchemy_ABC, Base):
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_ASSESSMENT_RESPONSE_QUALITY_METRIC: self.id_response_quality_metric
|
||||
, self.ATTR_ID_RESPONSE_QUALITY_METRIC: self.id_response_quality_metric
|
||||
, self.FLAG_CODE: self.code
|
||||
, self.FLAG_NAME: f'{self.name} ({self.unit_measurement.symbol})'
|
||||
, self.FLAG_VALUE_MIN: self.value_min
|
||||
|
||||
@@ -53,49 +53,57 @@ class Unit_Measurement(SQLAlchemy_ABC, Base):
|
||||
@classmethod
|
||||
def from_db_unit_measurement(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_unit_measurement'
|
||||
level = cls()
|
||||
level.id_unit_measurement = query_row[0]
|
||||
level.name_singular = query_row[1]
|
||||
level.name_plural = query_row[2]
|
||||
level.symbol = query_row[3]
|
||||
level.symbol_is_suffix_not_prefix = query_row[4]
|
||||
level.is_base_unit = query_row[5]
|
||||
level.is_unit_of_distance = query_row[6]
|
||||
level.is_unit_of_mass = query_row[7]
|
||||
level.is_unit_of_time = query_row[8]
|
||||
level.is_unit_of_volume = query_row[9]
|
||||
level.active = True
|
||||
return level
|
||||
unit = cls()
|
||||
unit.id_unit_measurement = query_row[0]
|
||||
unit.name_singular = query_row[1]
|
||||
unit.name_plural = query_row[2]
|
||||
unit.symbol = query_row[3]
|
||||
unit.symbol_is_suffix_not_prefix = query_row[4]
|
||||
unit.is_base_unit = av.input_bool(query_row[5], 'is_base_unit', _m)
|
||||
unit.is_unit_of_distance = av.input_bool(query_row[6], 'is_base_unit', _m)
|
||||
unit.is_unit_of_mass = av.input_bool(query_row[7], 'is_base_unit', _m)
|
||||
unit.is_unit_of_time = av.input_bool(query_row[8], 'is_base_unit', _m)
|
||||
unit.is_unit_of_volume = av.input_bool(query_row[9], 'is_base_unit', _m)
|
||||
unit.active = True
|
||||
return unit
|
||||
|
||||
@classmethod
|
||||
def from_db_response_quality_metric(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_response_quality_metric'
|
||||
level = cls()
|
||||
level.id_unit_measurement = query_row[1]
|
||||
level.name_singular = query_row[2]
|
||||
level.name_plural = query_row[3]
|
||||
level.symbol = query_row[4]
|
||||
level.active = True
|
||||
return level
|
||||
unit = cls()
|
||||
unit.id_unit_measurement = query_row[1]
|
||||
unit.name_singular = query_row[2]
|
||||
unit.name_plural = query_row[3]
|
||||
unit.symbol = query_row[4]
|
||||
unit.active = True
|
||||
return unit
|
||||
|
||||
@classmethod
|
||||
def from_db_assessment_response(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_assessment_response'
|
||||
unit = cls()
|
||||
unit.id_unit_measurement = None
|
||||
unit.name_singular = ''
|
||||
unit.name_plural = ''
|
||||
unit.symbol = ''
|
||||
return unit
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
unit_measurement = cls()
|
||||
if json is None: return Unit_Measurement
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
unit_measurement.id_unit_measurement = json.get(Unit_Measurement.ATTR_ID_UNIT_MEASUREMENT, -1)
|
||||
unit_measurement.name_singular = json[cls.FLAG_NAME_SINGULAR]
|
||||
unit_measurement.name_plural = json[cls.FLAG_NAME_PLURAL]
|
||||
unit_measurement.symbol = json[cls.FLAG_SYMBOL]
|
||||
unit_measurement.symbol_is_suffix_not_prefix = json[cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX]
|
||||
unit_measurement.is_base_unit = json[cls.FLAG_IS_BASE_UNIT]
|
||||
unit_measurement.is_unit_of_distance = json[cls.FLAG_IS_UNIT_OF_DISTANCE]
|
||||
unit_measurement.is_unit_of_mass = json[cls.FLAG_IS_UNIT_OF_MASS]
|
||||
unit_measurement.is_unit_of_time = json[cls.FLAG_IS_UNIT_OF_TIME]
|
||||
unit_measurement.is_unit_of_volume = json[cls.FLAG_IS_UNIT_OF_VOLUME]
|
||||
unit_measurement.active = json[cls.FLAG_ACTIVE]
|
||||
Helper_App.console_log(f'Unit_Measurement: {unit_measurement}')
|
||||
unit_measurement.symbol_is_suffix_not_prefix = av.input_bool(json[cls.FLAG_SYMBOL_IS_SUFFIX_NOT_PREFIX], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.is_base_unit = av.input_bool(json[cls.FLAG_IS_BASE_UNIT], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.is_unit_of_distance = av.input_bool(json[cls.FLAG_IS_UNIT_OF_DISTANCE], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.is_unit_of_mass = av.input_bool(json[cls.FLAG_IS_UNIT_OF_MASS], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.is_unit_of_time = av.input_bool(json[cls.FLAG_IS_UNIT_OF_TIME], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.is_unit_of_volume = av.input_bool(json[cls.FLAG_IS_UNIT_OF_VOLUME], cls.FLAG_ACTIVE, _m)
|
||||
unit_measurement.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
return unit_measurement
|
||||
|
||||
|
||||
@@ -114,7 +122,6 @@ class Unit_Measurement(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_IS_UNIT_OF_VOLUME: self.is_unit_of_volume
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -72,7 +72,6 @@ class User(SQLAlchemy_ABC, Base):
|
||||
_m = 'User.from_json'
|
||||
user = User()
|
||||
if json is None: return user
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
user.id_user = json['id_user']
|
||||
user.id_user_auth0 = json['id_user_auth0']
|
||||
user.firstname = json['firstname']
|
||||
@@ -83,7 +82,6 @@ class User(SQLAlchemy_ABC, Base):
|
||||
|
||||
user.can_admin_dog = user.is_super_user
|
||||
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
@@ -91,7 +89,6 @@ class User(SQLAlchemy_ABC, Base):
|
||||
_m = 'User.from_json_auth0'
|
||||
user = User()
|
||||
if json is None: return user
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
user_info = json['userinfo']
|
||||
user.id_user = None
|
||||
user.id_user_auth0 = user_info['sub']
|
||||
@@ -103,7 +100,6 @@ class User(SQLAlchemy_ABC, Base):
|
||||
|
||||
user.can_admin_dog = user.is_super_user
|
||||
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
def to_json(self):
|
||||
@@ -118,7 +114,6 @@ class User(SQLAlchemy_ABC, Base):
|
||||
, 'is_email_verified': self.is_email_verified
|
||||
, 'is_super_user': self.is_super_user
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -68,7 +68,7 @@ class Weather(SQLAlchemy_ABC, Base):
|
||||
weather.id_weather = json.get(Weather.ATTR_ID_WEATHER, -1)
|
||||
weather.name = json[cls.FLAG_NAME]
|
||||
weather.code = json.get(cls.FLAG_CODE, weather.name.upper().replace(" ", "_"))
|
||||
weather.active = json[cls.FLAG_ACTIVE]
|
||||
weather.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
weather.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
# Helper_App.console_log(f'Weather: {weather}')
|
||||
return weather
|
||||
|
||||
@@ -56,13 +56,11 @@ class File_Type(SQLAlchemy_ABC, Base):
|
||||
_m = 'File_Type.from_json'
|
||||
file_type = cls()
|
||||
if json is None: return File_Type
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
file_type.id_file_type = json.get(cls.ATTR_ID_FILE_TYPE, -1)
|
||||
file_type.name = json[cls.FLAG_NAME]
|
||||
file_type.code = json.get(cls.FLAG_CODE, file_type.name.upper().replace(" ", "_"))
|
||||
file_type.is_image = json[cls.FLAG_IS_IMAGE]
|
||||
file_type.active = json[cls.FLAG_ACTIVE]
|
||||
# Helper_App.console_log(f'File_Type: {file_type}')
|
||||
return file_type
|
||||
|
||||
|
||||
@@ -75,7 +73,6 @@ class File_Type(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_IS_IMAGE: self.is_image
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -63,16 +63,14 @@ class Contact_Form(SQLAlchemy_ABC, Base):
|
||||
_m = 'Contact_Form.from_json'
|
||||
contact_form = cls()
|
||||
if json is None: return Contact_Form
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
contact_form.id_contact_form = -1
|
||||
contact_form.email = json[cls.FLAG_EMAIL]
|
||||
contact_form.name_contact = json[cls.FLAG_NAME_CONTACT]
|
||||
contact_form.name_company = json[cls.FLAG_NAME_COMPANY]
|
||||
contact_form.message = json[cls.FLAG_MESSAGE]
|
||||
contact_form.receive_marketing_communications = json[cls.FLAG_RECEIVE_MARKETING_COMMUNICATIONS]
|
||||
contact_form.active = json[cls.FLAG_ACTIVE]
|
||||
contact_form.active = av.input_bool(json[cls.FLAG_ACTIVE], cls.FLAG_ACTIVE, _m)
|
||||
contact_form.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
Helper_App.console_log(f'Contact_Form: {contact_form}')
|
||||
return contact_form
|
||||
|
||||
|
||||
@@ -87,7 +85,6 @@ class Contact_Form(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user