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,17 +8,18 @@ Feature: Dog Business Object
|
||||
"""
|
||||
|
||||
# internal
|
||||
from business_objects.base import Base
|
||||
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.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 Dog(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_DOG: ClassVar[str] = 'id_dog'
|
||||
FLAG_DOG: ClassVar[str] = 'dog'
|
||||
FLAG_APPEARANCE: ClassVar[str] = 'appearance'
|
||||
FLAG_MASS_KG: ClassVar[str] = 'mass-kg'
|
||||
@@ -41,8 +42,19 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
self.is_new = False
|
||||
super().__init__()
|
||||
|
||||
def from_DB_Dog_Command(query_row):
|
||||
_m = 'Dog.from_DB_Dog'
|
||||
def from_db_dog(query_row):
|
||||
_m = 'Dog.from_db_dog'
|
||||
dog = Dog()
|
||||
dog.id_dog = query_row[0]
|
||||
dog.name = query_row[1]
|
||||
dog.appearance = query_row[2]
|
||||
dog.mass_kg = query_row[3]
|
||||
dog.notes = query_row[4]
|
||||
dog.active = av.input_bool(query_row[5], 'active', _m)
|
||||
return dog
|
||||
|
||||
def from_db_dog_command_link(query_row):
|
||||
_m = 'Dog.from_db_dog_command_link'
|
||||
dog = Dog()
|
||||
dog.id_dog = query_row[1]
|
||||
dog.name = query_row[2]
|
||||
@@ -122,3 +134,53 @@ class Dog_Temp(db.Model, Base):
|
||||
temp.active = dog.active
|
||||
temp.created_on = dog.created_on
|
||||
return temp
|
||||
|
||||
|
||||
class Parameters_Dog(Get_Many_Parameters_Base):
|
||||
get_all_dog: bool
|
||||
get_inactive_dog: bool
|
||||
ids_dog: str
|
||||
names_dog: str
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
get_all_dog = True
|
||||
, get_inactive_dog = False
|
||||
, ids_dog = ''
|
||||
, names_dog = ''
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
get_all_dog = json.get('a_get_all_dog', False)
|
||||
, get_inactive_dog = json.get('a_get_inactive_dog', False)
|
||||
, ids_dog = json.get('a_ids_dog', '')
|
||||
, names_dog = json.get('names_dog', '')
|
||||
)
|
||||
|
||||
"""
|
||||
@classmethod
|
||||
def from_form_filters_dog(cls, form):
|
||||
av.val_instance(form, 'form', 'Parameters_Dog.from_form_filters_dog', Filters_Dog)
|
||||
has_filter_id = not (form.id_dog.data == '0' or form.id_dog.data == '' or form.id_dog.data is None)
|
||||
has_filter_name = not (form.name_dog.data == '0' or form.name_dog.data == '' or form.name_dog.data is None)
|
||||
has_filter_dog = has_filter_id or has_filter_name
|
||||
active_only = av.input_bool(form.active.data, "active", "Parameters_Dog.from_form_filters_dog")
|
||||
return cls(
|
||||
get_all_dog = not has_filter_dog
|
||||
, get_inactive_dog = not active_only
|
||||
, ids_dog = form.id_dog.data if has_filter_id else ''
|
||||
, names_dog = form.name_dog.data if has_filter_name else ''
|
||||
)
|
||||
"""
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_get_all_dog': self.get_all_dog
|
||||
, 'a_get_inactive_dog': self.get_inactive_dog
|
||||
, 'a_ids_dog': self.ids_dog
|
||||
, 'a_names_dog': self.names_dog
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user