Feat(SQL, UI): Logic for Get-Many SQL Stored Procedures refactored to use Calc Stored Procedures and Dog Command Links page styling improved.
This commit is contained in:
@@ -24,7 +24,7 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
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'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_COMMAND
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_COMMAND
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
|
||||
__tablename__ = 'DOG_Command'
|
||||
@@ -78,7 +78,7 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
_m = 'Command.from_json'
|
||||
command = cls()
|
||||
if json is None: return Command
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
command.id_command = -1
|
||||
command.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
command.name = json[cls.FLAG_NAME]
|
||||
@@ -87,12 +87,13 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
command.notes = json[cls.FLAG_NOTES]
|
||||
command.active = json[cls.FLAG_ACTIVE]
|
||||
command.created_on = json.get(cls.FLAG_CREATED_ON, None)
|
||||
Helper_App.console_log(f'Command: {command}')
|
||||
# Helper_App.console_log(f'Command: {command}')
|
||||
return command
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
self.FLAG_COMMAND: self.id_command
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_COMMAND: self.id_command
|
||||
, Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: self.hand_signal_default_description
|
||||
@@ -101,7 +102,7 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
, self.FLAG_CREATED_ON: self.created_on
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -19,8 +19,9 @@ from typing import ClassVar
|
||||
|
||||
|
||||
class Command_Category(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_COMMAND_CATEGORY: ClassVar[str] = 'id_command_category'
|
||||
FLAG_COMMAND_CATEGORY: ClassVar[str] = 'command-category'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_COMMAND_CATEGORY
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_COMMAND_CATEGORY
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
|
||||
__tablename__ = 'DOG_Command_Category'
|
||||
@@ -50,23 +51,24 @@ class Command_Category(SQLAlchemy_ABC, Base):
|
||||
_m = 'Command_Category.from_json'
|
||||
command_category = cls()
|
||||
if json is None: return Command_Category
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
command_category.id_command_category = -1
|
||||
command_category.code = json[cls.FLAG_CODE]
|
||||
command_category.name = json[cls.FLAG_NAME]
|
||||
command_category.active = json[cls.FLAG_ACTIVE]
|
||||
Helper_App.console_log(f'Command_Category: {command_category}')
|
||||
# Helper_App.console_log(f'Command_Category: {command_category}')
|
||||
return command_category
|
||||
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
self.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_COMMAND_CATEGORY: self.id_command_category
|
||||
, self.FLAG_CODE: self.code
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -24,8 +24,8 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
FLAG_APPEARANCE: ClassVar[str] = 'appearance'
|
||||
FLAG_MASS_KG: ClassVar[str] = 'mass-kg'
|
||||
FLAG_NOTES: ClassVar[str] = 'notes'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_DOG
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_EMAIL
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_DOG
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
|
||||
__tablename__ = 'DOG_Dog'
|
||||
__table_args__ = { 'extend_existing': True }
|
||||
@@ -71,27 +71,28 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
_m = 'Dog.from_json'
|
||||
dog = cls()
|
||||
if json is None: return Dog
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
dog.id_dog = -1
|
||||
dog.name = json[cls.FLAG_NAME]
|
||||
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]
|
||||
Helper_App.console_log(f'Dog: {dog}')
|
||||
# Helper_App.console_log(f'Dog: {dog}')
|
||||
return dog
|
||||
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
self.FLAG_DOG: self.id_dog
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_DOG: self.id_dog
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_APPEARANCE: self.appearance
|
||||
, self.FLAG_MASS_KG: self.mass_kg
|
||||
, self.FLAG_NOTES: self.notes
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
}
|
||||
Helper_App.console_log(f'as_json: {as_json}')
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
@@ -24,10 +24,11 @@ from typing import ClassVar
|
||||
|
||||
|
||||
class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_DOG_COMMAND_LINK: ClassVar[str] = 'id_link'
|
||||
FLAG_DOG_COMMAND_LINK: ClassVar[str] = 'dog_command_link'
|
||||
FLAG_HAND_SIGNAL_DESCRIPTION: ClassVar[str] = 'hand-signal-description'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_DOG_COMMAND_LINK
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = ATTR_ID_DOG_COMMAND_LINK
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = FLAG_HAND_SIGNAL_DESCRIPTION
|
||||
|
||||
__tablename__ = 'DOG_Dog_Command_Link'
|
||||
__table_args__ = { 'extend_existing': True }
|
||||
@@ -67,7 +68,7 @@ class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
_m = 'Dog_Command_Link.from_json'
|
||||
dog_command_link = cls()
|
||||
if json is None: return dog_command_link
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
dog_command_link.id_link = -1
|
||||
dog_command_link.id_dog = json[Dog.FLAG_DOG]
|
||||
dog_command_link.id_command = json[Command.FLAG_COMMAND]
|
||||
@@ -76,12 +77,13 @@ class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
dog_command_link.active = json[cls.FLAG_ACTIVE]
|
||||
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}')
|
||||
# Helper_App.console_log(f'Dog Command Link: {dog_command_link}')
|
||||
return dog_command_link
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
self.FLAG_DOG_COMMAND_LINK: self.id_link
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_DOG_COMMAND_LINK: self.id_link
|
||||
, Dog.FLAG_DOG: self.id_dog
|
||||
, Command.FLAG_COMMAND: self.id_command
|
||||
, self.FLAG_HAND_SIGNAL_DESCRIPTION: self.hand_signal_description
|
||||
@@ -90,7 +92,7 @@ class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
, 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}')
|
||||
# Helper_App.console_log(f'as_json: {as_json}')
|
||||
return as_json
|
||||
|
||||
def __repr__(self):
|
||||
@@ -170,16 +172,17 @@ class Parameters_Dog_Command_Link(Get_Many_Parameters_Base):
|
||||
@classmethod
|
||||
def from_form_filters_dog_command_link(cls, form):
|
||||
av.val_instance(form, 'form', 'Parameters_Dog_Command_Link.from_form_filters_dog_command_link', Filters_Dog_Command_Link)
|
||||
has_filter_dog = not (form.id_dog.data == '0' or form.id_dog.data == '' or form.id_dog.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.data, "active", "Parameters_Dog_Command_Link.from_form_filters_dog_command_link")
|
||||
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
|
||||
has_filter_dog = not (has_filter_search_text or form.id_dog.data == '0' or form.id_dog.data == '' or form.id_dog.data is None)
|
||||
has_filter_command = not (has_filter_search_text or 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", "Parameters_Dog_Command_Link.from_form_filters_dog_command_link")
|
||||
return cls(
|
||||
get_all_dog = not has_filter_dog
|
||||
, get_inactive_dog = not active_only
|
||||
, ids_dog = form.id_dog.data if has_filter_dog else ''
|
||||
, ids_dog = form.id_dog.data if has_filter_dog else form.search.data if has_filter_search_text else ''
|
||||
, get_all_command = not has_filter_command
|
||||
, get_inactive_command = not active_only
|
||||
, ids_command = form.id_command.data if has_filter_command else ''
|
||||
, ids_command = form.id_command.data if has_filter_command else form.search.data if has_filter_search_text else ''
|
||||
)
|
||||
|
||||
def to_json(self):
|
||||
|
||||
@@ -19,6 +19,7 @@ from typing import ClassVar
|
||||
|
||||
|
||||
class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
ATTR_ID_OBEDIENCE_LEVEL: ClassVar[str] = "id_obedience_level"
|
||||
FLAG_OBEDIENCE_LEVEL: ClassVar[str] = 'obedience-level'
|
||||
NAME_ATTR_OPTION_VALUE: ClassVar[str] = FLAG_OBEDIENCE_LEVEL
|
||||
NAME_ATTR_OPTION_TEXT: ClassVar[str] = Base.FLAG_NAME
|
||||
@@ -61,7 +62,8 @@ class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
self.FLAG_OBEDIENCE_LEVEL: self.id_obedience_level
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_OBEDIENCE_LEVEL: self.id_obedience_level
|
||||
, self.FLAG_CODE: self.code
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_ACTIVE: self.active
|
||||
|
||||
@@ -38,6 +38,7 @@ class User(SQLAlchemy_ABC, Base):
|
||||
def __init__(self):
|
||||
self.id_user = 0
|
||||
self.is_new = False
|
||||
self.can_admin_dog = False
|
||||
super().__init__()
|
||||
|
||||
def from_DB_user(query_row):
|
||||
@@ -51,6 +52,8 @@ class User(SQLAlchemy_ABC, Base):
|
||||
user.is_email_verified = av.input_bool(query_row[5], 'is_email_verified', _m)
|
||||
user.is_super_user = av.input_bool(query_row[9], 'is_super_user', _m)
|
||||
user.is_new = av.input_bool(query_row[12], 'is_new', _m)
|
||||
|
||||
user.can_admin_dog = user.is_super_user
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
@@ -66,6 +69,9 @@ class User(SQLAlchemy_ABC, Base):
|
||||
user.email = json['email']
|
||||
user.is_email_verified = av.input_bool(json['is_email_verified'], 'is_email_verified', _m)
|
||||
user.is_super_user = av.input_bool(json['is_super_user'], 'is_super_user', _m)
|
||||
|
||||
user.can_admin_dog = user.is_super_user
|
||||
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
@@ -83,11 +89,15 @@ class User(SQLAlchemy_ABC, Base):
|
||||
user.email = user_info['email']
|
||||
user.is_email_verified = av.input_bool(user_info['email_verified'], 'is_email_verified', _m)
|
||||
user.is_super_user = None
|
||||
|
||||
user.can_admin_dog = user.is_super_user
|
||||
|
||||
Helper_App.console_log(f'user: {user}')
|
||||
return user
|
||||
|
||||
def to_json(self):
|
||||
as_json = {
|
||||
**self.get_shared_json_attributes(self),
|
||||
'id_user': self.id_user,
|
||||
'id_user_auth0': self.id_user_auth0,
|
||||
'firstname': self.firstname,
|
||||
|
||||
Reference in New Issue
Block a user