Feat(SQL, UI): Redesign database with much more detailed command response quality analysis and created successfully loading Dog Command Links page
This commit is contained in:
@@ -8,18 +8,19 @@ Feature: Command Business Object
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.base import Base
|
||||
from business_objects.dog.command_category import Command_Category
|
||||
from business_objects.db_base import SQLAlchemy_ABC
|
||||
import lib.argument_validation as av
|
||||
from extensions import db
|
||||
from helpers.helper_app import Helper_App
|
||||
from dog_training.business_objects.base import Base
|
||||
from dog_training.business_objects.dog.command_category import Command_Category
|
||||
from dog_training.business_objects.db_base import SQLAlchemy_ABC, Get_Many_Parameters_Base
|
||||
import dog_training.lib.argument_validation as av
|
||||
from dog_training.extensions import db
|
||||
from dog_training.helpers.helper_app import Helper_App
|
||||
# external
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar
|
||||
|
||||
|
||||
class Command(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_COMMAND: ClassVar[str] = 'id_command'
|
||||
FLAG_COMMAND: ClassVar[str] = 'command'
|
||||
FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: ClassVar[str] = 'hand-signal-default-description'
|
||||
FLAG_CAN_HAVE_BUTTON: ClassVar[str] = 'can-have-button'
|
||||
@@ -44,12 +45,26 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
self.has_button = False
|
||||
super().__init__()
|
||||
|
||||
def from_DB_Dog_Command(query_row):
|
||||
_m = 'Command.from_DB_Dog_Command'
|
||||
def from_db_command(query_row):
|
||||
_m = 'Command.from_db_command'
|
||||
command = Command()
|
||||
command.id_command = query_row[0]
|
||||
command.id_command_category = query_row[1]
|
||||
command.name = query_row[2]
|
||||
command.hand_signal_default_description = query_row[3]
|
||||
command.can_have_button = av.input_bool(query_row[4], 'can_have_button', _m)
|
||||
# command.has_button = av.input_bool(query_row[7], 'has_button', _m)
|
||||
command.notes = query_row[5]
|
||||
command.active = av.input_bool(query_row[6], 'active', _m)
|
||||
# command.created_on = query_row[7]
|
||||
return command
|
||||
|
||||
def from_db_dog_command_link(query_row):
|
||||
_m = 'Command.from_db_dog_command_link'
|
||||
command = Command()
|
||||
command.id_command = query_row[5]
|
||||
command.id_command_category = query_row[3]
|
||||
command.name = query_row[7]
|
||||
command.name = query_row[6]
|
||||
# command.hand_signal_default_description = query_row[2]
|
||||
# command.can_have_button = av.input_bool(query_row[5], 'can_have_button', _m)
|
||||
command.has_button = av.input_bool(query_row[7], 'has_button', _m)
|
||||
@@ -132,4 +147,52 @@ class Command_Temp(db.Model, Base):
|
||||
temp.notes = command.notes
|
||||
temp.active = command.active
|
||||
temp.created_on = command.created_on
|
||||
return temp
|
||||
return temp
|
||||
|
||||
|
||||
class Parameters_Command(Get_Many_Parameters_Base):
|
||||
get_all_command: bool
|
||||
get_inactive_command: bool
|
||||
ids_command: str
|
||||
names_command: str
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
get_all_command = True
|
||||
, get_inactive_command = False
|
||||
, ids_command = ''
|
||||
, names_command = ''
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
get_all_command = json.get('a_get_all_command', False)
|
||||
, get_inactive_command = json.get('a_get_inactive_command', False)
|
||||
, ids_command = json.get('a_ids_command', '')
|
||||
, names_command = json.get('a_names_command', '')
|
||||
)
|
||||
|
||||
"""
|
||||
@classmethod
|
||||
def from_form_filters_command(cls, form):
|
||||
av.val_instance(form, 'form', 'Parameters_Command.from_form_filters_command', Filters_Command)
|
||||
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.data, "active", "Parameters_Command.from_form_filters_command")
|
||||
return cls(
|
||||
get_all_command = not has_filter_command
|
||||
, get_inactive_command = not active_only
|
||||
, ids_command = form.id_command.data if has_filter_id else ''
|
||||
, names_command = form.name_command.data if has_filter_name else ''
|
||||
)
|
||||
"""
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_get_all_command': self.get_all_command
|
||||
, 'a_get_inactive_command': self.get_inactive_command
|
||||
, 'a_ids_command': self.ids_command
|
||||
, 'a_names_command': self.names_command
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user