Feat(SQL, UI): 1. Perfected architecture for modular Search functionality across heirarchical Get Many and Calc Stored Procedures that allows text search filtering on different fields as well as by record Id with control over how the filters are applied. \n 2. Updated User Calc and Get Many Stored Procedures with new Search functionality. \n 3. Improved styles on Dog Command Link page.
This commit is contained in:
@@ -63,7 +63,7 @@ class Base():
|
||||
FLAG_PRIORITY: ClassVar[str] = 'priority'
|
||||
FLAG_REGION: ClassVar[str] = 'region'
|
||||
FLAG_ROWS: ClassVar[str] = 'rows'
|
||||
FLAG_SEARCH_TEXT: ClassVar[str] = 'search_text'
|
||||
FLAG_SEARCH: ClassVar[str] = 'search'
|
||||
FLAG_SYMBOL: ClassVar[str] = 'symbol'
|
||||
FLAG_URL: ClassVar[str] = 'url'
|
||||
FLAG_USER: ClassVar[str] = 'authorisedUser' # 'user' already used
|
||||
|
||||
@@ -41,13 +41,15 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
|
||||
def __init__(self):
|
||||
self.id_command = 0
|
||||
self.command_category = None
|
||||
self.is_new = False
|
||||
self.has_button = False
|
||||
super().__init__()
|
||||
|
||||
def from_db_command(query_row):
|
||||
_m = 'Command.from_db_command'
|
||||
command = Command()
|
||||
@classmethod
|
||||
def from_db_command(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_command'
|
||||
command = cls()
|
||||
command.id_command = query_row[0]
|
||||
command.id_command_category = query_row[1]
|
||||
command.name = query_row[2]
|
||||
@@ -59,25 +61,27 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
# 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()
|
||||
@classmethod
|
||||
def from_db_dog_command_link(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_dog_command_link'
|
||||
command = cls()
|
||||
command.id_command = query_row[5]
|
||||
command.id_command_category = query_row[3]
|
||||
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)
|
||||
command.can_have_button = av.input_bool(query_row[8], 'can_have_button', _m)
|
||||
# command.has_button = av.input_bool(query_row[7], 'has_button', _m)
|
||||
# command.notes = query_row[4]
|
||||
command.active = av.input_bool(True, 'active', _m)
|
||||
command.active = True # av.input_bool(True, 'active', _m)
|
||||
# command.created_on = query_row[7]
|
||||
command.command_category = Command_Category.from_db_dog_command_link(query_row)
|
||||
return command
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = 'Command.from_json'
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
command = cls()
|
||||
if json is None: return Command
|
||||
if json is None: return command
|
||||
# Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
command.id_command = -1
|
||||
command.id_command_category = json[Command_Category.FLAG_COMMAND_CATEGORY]
|
||||
@@ -94,7 +98,7 @@ class Command(SQLAlchemy_ABC, Base):
|
||||
as_json = {
|
||||
**self.get_shared_json_attributes(self)
|
||||
, self.ATTR_ID_COMMAND: self.id_command
|
||||
, Command_Category.FLAG_COMMAND_CATEGORY: self.id_command_category
|
||||
, Command_Category.ATTR_ID_COMMAND_CATEGORY: self.id_command_category
|
||||
, self.FLAG_NAME: self.name
|
||||
, self.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: self.hand_signal_default_description
|
||||
, self.FLAG_CAN_HAVE_BUTTON: self.can_have_button
|
||||
@@ -152,48 +156,102 @@ class Command_Temp(db.Model, Base):
|
||||
|
||||
|
||||
class Parameters_Command(Get_Many_Parameters_Base):
|
||||
get_all_command_category: bool
|
||||
get_inactive_command_category: bool
|
||||
ids_command_category: str
|
||||
names_command_category: str
|
||||
get_all_command: bool
|
||||
get_inactive_command: bool
|
||||
ids_command: str
|
||||
names_command: str
|
||||
hand_signal_default_descriptions_command: str
|
||||
notes_command: str
|
||||
require_all_id_search_filters_met: bool
|
||||
require_any_id_search_filters_met: bool
|
||||
require_all_non_id_search_filters_met: bool
|
||||
require_any_non_id_search_filters_met: bool
|
||||
output_command_categories: bool
|
||||
output_commands: bool
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
get_all_command = True
|
||||
get_all_command_category = True
|
||||
, get_inactive_command_category = False
|
||||
, ids_command_category = ''
|
||||
, names_command_category = ''
|
||||
, get_all_command = True
|
||||
, get_inactive_command = False
|
||||
, ids_command = ''
|
||||
, names_command = ''
|
||||
, hand_signal_default_descriptions_command = ''
|
||||
, notes_command = ''
|
||||
, require_all_id_search_filters_met = True
|
||||
, require_any_id_search_filters_met = True
|
||||
, require_all_non_id_search_filters_met = False
|
||||
, require_any_non_id_search_filters_met = True
|
||||
, output_command_categories = True
|
||||
, output_commands = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
get_all_command = json.get('a_get_all_command', False)
|
||||
get_all_command_category = json.get('a_get_all_command_category', False)
|
||||
, get_inactive_command_category = json.get('a_get_inactive_command_category', False)
|
||||
, ids_command_category = json.get('a_ids_command_category', '')
|
||||
, names_command_category = json.get('a_names_command_category', '')
|
||||
, 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', '')
|
||||
, hand_signal_default_descriptions_command = json.get('a_hand_signal_default_descriptions_command', '')
|
||||
, notes_command = json.get('a_notes_command', '')
|
||||
, require_all_id_search_filters_met = json.get('a_require_all_id_search_filters_met', True)
|
||||
, require_any_id_search_filters_met = json.get('a_require_any_id_search_filters_met', True)
|
||||
, require_all_non_id_search_filters_met = json.get('a_require_all_non_id_search_filters_met', False)
|
||||
, require_any_non_id_search_filters_met = json.get('a_require_any_non_id_search_filters_met', True)
|
||||
, output_command_categories = json.get('a_output_command_categories', False)
|
||||
, output_commands = json.get('a_output_commands', False)
|
||||
)
|
||||
|
||||
"""
|
||||
@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")
|
||||
def from_form_filters_dog_command_link(cls, form):
|
||||
av.val_instance(form, 'form', 'Parameters_Command.from_form_filters_dog_command_link', Filters_Dog_Command_Link)
|
||||
has_filter_search_text = not (form.search.data == '' or form.search.data is None)
|
||||
has_filter_command_category = not (has_filter_search_text or form.id_command_category.data == '0' or form.id_command_category.data == '' or form.id_command_category.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_Command.from_form_filters_dog_command_link")
|
||||
return cls(
|
||||
get_all_command = not has_filter_command
|
||||
get_all_command_category = not has_filter_command_category
|
||||
, get_inactive_command_category = not active_only
|
||||
, ids_command_category = form.id_command_category.data if has_filter_command_category else ''
|
||||
, names_command_category = form.search_text.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_id else ''
|
||||
, names_command = form.name_command.data if has_filter_name else ''
|
||||
, ids_command = form.id_command.data if has_filter_command else ''
|
||||
, names_command = form.search_text.data if has_filter_search_text else ''
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_get_all_command': self.get_all_command
|
||||
'a_get_all_command_category': self.get_all_command_category
|
||||
, 'a_get_inactive_command_category': self.get_inactive_command_category
|
||||
, 'a_ids_command_category': self.ids_command_category
|
||||
, 'a_names_command_category': self.names_command_category
|
||||
, '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
|
||||
, 'a_hand_signal_default_descriptions_command': self.hand_signal_default_descriptions_command
|
||||
, 'a_notes_command': self.notes_command
|
||||
, 'a_require_all_id_search_filters_met': self.require_all_id_search_filters_met
|
||||
, 'a_require_any_id_search_filters_met': self.require_any_id_search_filters_met
|
||||
, 'a_require_all_non_id_search_filters_met': self.require_all_non_id_search_filters_met
|
||||
, 'a_require_any_non_id_search_filters_met': self.require_any_non_id_search_filters_met
|
||||
, 'a_output_command_categories': self.output_command_categories
|
||||
, 'a_output_commands': self.output_commands
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,21 @@ class Command_Category(SQLAlchemy_ABC, Base):
|
||||
self.is_new = False
|
||||
super().__init__()
|
||||
|
||||
def from_db_dog_command_link(query_row):
|
||||
_m = 'Command_Category.from_db_dog_command_link'
|
||||
level = Command_Category()
|
||||
@classmethod
|
||||
def from_db_command(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_command'
|
||||
category = cls()
|
||||
category.id_command_category = query_row[0]
|
||||
category.code = query_row[1]
|
||||
category.name = query_row[2]
|
||||
category.active = av.input_bool(query_row[3], 'active', _m)
|
||||
# command.created_on = query_row[7]
|
||||
return category
|
||||
|
||||
@classmethod
|
||||
def from_db_dog_command_link(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_dog_command_link'
|
||||
level = cls()
|
||||
level.id_command_category = query_row[3]
|
||||
# level.code = query_row[6]
|
||||
level.name = query_row[4]
|
||||
|
||||
@@ -42,9 +42,10 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
self.is_new = False
|
||||
super().__init__()
|
||||
|
||||
def from_db_dog(query_row):
|
||||
@classmethod
|
||||
def from_db_dog(cls, query_row):
|
||||
_m = 'Dog.from_db_dog'
|
||||
dog = Dog()
|
||||
dog = cls()
|
||||
dog.id_dog = query_row[0]
|
||||
dog.name = query_row[1]
|
||||
dog.appearance = query_row[2]
|
||||
@@ -53,9 +54,10 @@ class Dog(SQLAlchemy_ABC, Base):
|
||||
dog.active = av.input_bool(query_row[5], 'active', _m)
|
||||
return dog
|
||||
|
||||
def from_db_dog_command_link(query_row):
|
||||
@classmethod
|
||||
def from_db_dog_command_link(cls, query_row):
|
||||
_m = 'Dog.from_db_dog_command_link'
|
||||
dog = Dog()
|
||||
dog = cls()
|
||||
dog.id_dog = query_row[1]
|
||||
dog.name = query_row[2]
|
||||
"""
|
||||
@@ -142,6 +144,10 @@ class Parameters_Dog(Get_Many_Parameters_Base):
|
||||
get_inactive_dog: bool
|
||||
ids_dog: str
|
||||
names_dog: str
|
||||
require_all_id_search_filters_met: bool
|
||||
require_any_id_search_filters_met: bool
|
||||
require_all_non_id_search_filters_met: bool
|
||||
require_any_non_id_search_filters_met: bool
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
@@ -150,6 +156,10 @@ class Parameters_Dog(Get_Many_Parameters_Base):
|
||||
, get_inactive_dog = False
|
||||
, ids_dog = ''
|
||||
, names_dog = ''
|
||||
, require_all_id_search_filters_met = True
|
||||
, require_any_id_search_filters_met = True
|
||||
, require_all_non_id_search_filters_met = False
|
||||
, require_any_non_id_search_filters_met = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -159,6 +169,10 @@ class Parameters_Dog(Get_Many_Parameters_Base):
|
||||
, get_inactive_dog = json.get('a_get_inactive_dog', False)
|
||||
, ids_dog = json.get('a_ids_dog', '')
|
||||
, names_dog = json.get('names_dog', '')
|
||||
, require_all_id_search_filters_met = json.get('a_require_all_id_search_filters_met', True)
|
||||
, require_any_id_search_filters_met = json.get('a_require_any_id_search_filters_met', True)
|
||||
, require_all_non_id_search_filters_met = json.get('a_require_all_non_id_search_filters_met', False)
|
||||
, require_any_non_id_search_filters_met = json.get('a_require_any_non_id_search_filters_met', True)
|
||||
)
|
||||
|
||||
"""
|
||||
@@ -183,5 +197,9 @@ class Parameters_Dog(Get_Many_Parameters_Base):
|
||||
, 'a_get_inactive_dog': self.get_inactive_dog
|
||||
, 'a_ids_dog': self.ids_dog
|
||||
, 'a_names_dog': self.names_dog
|
||||
, 'a_require_all_id_search_filters_met': self.require_all_id_search_filters_met
|
||||
, 'a_require_any_id_search_filters_met': self.require_any_id_search_filters_met
|
||||
, 'a_require_all_non_id_search_filters_met': self.require_all_non_id_search_filters_met
|
||||
, 'a_require_any_non_id_search_filters_met': self.require_any_non_id_search_filters_met
|
||||
}
|
||||
|
||||
|
||||
@@ -48,14 +48,15 @@ class Dog_Command_Link(SQLAlchemy_ABC, Base):
|
||||
self.command = None
|
||||
super().__init__()
|
||||
|
||||
def from_db_dog_command_link(query_row):
|
||||
@classmethod
|
||||
def from_db_dog_command_link(cls, query_row):
|
||||
_m = 'Dog_Command_Link.from_db_dog_command_link'
|
||||
dog_command_link = Dog_Command_Link()
|
||||
dog_command_link = cls()
|
||||
dog_command_link.id_link = query_row[0]
|
||||
dog_command_link.id_dog = query_row[1]
|
||||
#dog_command_link.id_command_category = query_row[3]
|
||||
dog_command_link.id_command = query_row[5]
|
||||
dog_command_link.hand_signal_description = query_row[8]
|
||||
dog_command_link.hand_signal_description = query_row[7]
|
||||
dog_command_link.notes = query_row[9]
|
||||
dog_command_link.active = av.input_bool(query_row[10], 'active', _m)
|
||||
# dog_command_link.created_on = query_row[7]
|
||||
@@ -140,58 +141,146 @@ class Dog_Command_Link_Temp(db.Model, Base):
|
||||
|
||||
|
||||
class Parameters_Dog_Command_Link(Get_Many_Parameters_Base):
|
||||
get_all_link: bool
|
||||
get_inactive_link: bool
|
||||
ids_link: str
|
||||
get_all_dog: bool
|
||||
get_inactive_dog: bool
|
||||
ids_dog: str
|
||||
names_dog: str
|
||||
get_all_command_category: bool
|
||||
get_inactive_command_category: bool
|
||||
ids_command_category: str
|
||||
names_command_category: str
|
||||
get_all_command: bool
|
||||
get_inactive_command: bool
|
||||
ids_command: str
|
||||
names_command: str
|
||||
hand_signal_descriptions_link: str
|
||||
notes_command: str
|
||||
notes_link: str
|
||||
require_all_id_search_filters_met: bool
|
||||
require_any_id_search_filters_met: bool
|
||||
require_all_non_id_search_filters_met: bool
|
||||
require_any_non_id_search_filters_met: bool
|
||||
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
get_all_dog = True
|
||||
get_all_link = True
|
||||
, get_inactive_link = False
|
||||
, ids_link = ''
|
||||
, get_all_dog = True
|
||||
, get_inactive_dog = False
|
||||
, ids_dog = ''
|
||||
, names_dog = ''
|
||||
, get_all_command_category = True
|
||||
, get_inactive_command_category = False
|
||||
, ids_command_category = ''
|
||||
, names_command_category = ''
|
||||
, get_all_command = True
|
||||
, get_inactive_command = False
|
||||
, ids_command = ''
|
||||
, names_command = ''
|
||||
, hand_signal_descriptions_link = ''
|
||||
, notes_command = ''
|
||||
, notes_link = ''
|
||||
, require_all_id_search_filters_met = True
|
||||
, require_any_id_search_filters_met = True
|
||||
, require_all_non_id_search_filters_met = False
|
||||
, require_any_non_id_search_filters_met = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
return cls(
|
||||
get_all_dog = json.get('a_get_all_dog', False)
|
||||
get_all_link = json.get('a_get_all_link', False)
|
||||
, get_inactive_link = json.get('a_get_inactive_link', False)
|
||||
, ids_link = json.get('a_ids_link', '')
|
||||
, 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('a_names_dog', '')
|
||||
, get_all_command_category = json.get('a_get_all_command_category', False)
|
||||
, get_inactive_command_category = json.get('a_get_inactive_command_category', False)
|
||||
, ids_command_category = json.get('a_ids_command_category', '')
|
||||
, names_command_category = json.get('a_names_command_category', '')
|
||||
, 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', '')
|
||||
, hand_signal_descriptions_link = json.get('a_hand_signal_descriptions_link', '')
|
||||
, notes_command = json.get('a_notes_command', '')
|
||||
, notes_link = json.get('a_notes_link', '')
|
||||
, require_all_id_search_filters_met = json.get('a_require_all_id_search_filters_met', True)
|
||||
, require_any_id_search_filters_met = json.get('a_require_any_id_search_filters_met', True)
|
||||
, require_all_non_id_search_filters_met = json.get('a_require_all_non_id_search_filters_met', False)
|
||||
, require_any_non_id_search_filters_met = json.get('a_require_any_non_id_search_filters_met', True)
|
||||
)
|
||||
|
||||
@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)
|
||||
_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 (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 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 form.search.data if has_filter_search_text else ''
|
||||
)
|
||||
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
|
||||
filters.ids_link = ''
|
||||
filters.get_all_dog = not has_filter_dog
|
||||
filters.get_inactive_dog = not active_only
|
||||
filters.ids_dog = form.id_dog.data if has_filter_dog else ''
|
||||
filters.names_dog = form.search.data if has_filter_search_text else ''
|
||||
filters.get_all_command_category = not has_filter_command_category
|
||||
filters.get_inactive_command_category = not active_only
|
||||
filters.ids_command_category = form.id_command_category.data if has_filter_command_category else ''
|
||||
filters.names_command_category = form.search.data if has_filter_search_text else ''
|
||||
filters.get_all_command = not has_filter_command
|
||||
filters.get_inactive_command = not active_only
|
||||
filters.ids_command = form.id_command.data if has_filter_command else ''
|
||||
filters.names_command = form.search.data if has_filter_search_text else ''
|
||||
filters.hand_signal_descriptions_link = form.search.data if has_filter_search_text else ''
|
||||
# filters.notes_command = form.search.data if has_filter_search_text else ''
|
||||
filters.notes_link = form.search.data if has_filter_search_text else ''
|
||||
return filters
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'a_get_all_dog': self.get_all_dog
|
||||
'a_get_all_link': self.get_all_link
|
||||
, 'a_get_inactive_link': self.get_inactive_link
|
||||
, 'a_ids_link': self.ids_link
|
||||
, '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
|
||||
, 'a_get_all_command_category': self.get_all_command_category
|
||||
, 'a_get_inactive_command_category': self.get_inactive_command_category
|
||||
, 'a_ids_command_category': self.ids_command_category
|
||||
, 'a_names_command_category': self.names_command_category
|
||||
, '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
|
||||
, 'a_hand_signal_descriptions_link': self.hand_signal_descriptions_link
|
||||
, 'a_notes_command': self.notes_command
|
||||
, 'a_notes_link': self.notes_link
|
||||
, 'a_require_all_id_search_filters_met': self.require_all_id_search_filters_met
|
||||
, 'a_require_any_id_search_filters_met': self.require_any_id_search_filters_met
|
||||
, 'a_require_all_non_id_search_filters_met': self.require_all_non_id_search_filters_met
|
||||
, 'a_require_any_non_id_search_filters_met': self.require_any_non_id_search_filters_met
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,10 @@ class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
self.is_new = False
|
||||
super().__init__()
|
||||
"""
|
||||
def from_db_dog_command_link(query_row):
|
||||
_m = 'Obedience_Level.from_db_dog_command_link'
|
||||
level = Obedience_Level()
|
||||
@classmethod
|
||||
def from_db_dog_command_link(cls, query_row):
|
||||
_m = f'{cls.__qualname__}.from_db_dog_command_link'
|
||||
level = cls()
|
||||
level.id_obedience_level = query_row[5]
|
||||
level.code = query_row[6]
|
||||
level.name = query_row[7]
|
||||
@@ -48,7 +49,7 @@ class Obedience_Level(SQLAlchemy_ABC, Base):
|
||||
"""
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = 'Obedience_Level.from_json'
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
obedience_level = cls()
|
||||
if json is None: return Obedience_Level
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
|
||||
@@ -39,6 +39,7 @@ class User(SQLAlchemy_ABC, Base):
|
||||
self.id_user = 0
|
||||
self.is_new = False
|
||||
self.can_admin_dog = False
|
||||
self.can_admin_user = False
|
||||
super().__init__()
|
||||
|
||||
def from_DB_user(query_row):
|
||||
@@ -50,10 +51,10 @@ class User(SQLAlchemy_ABC, Base):
|
||||
user.surname = query_row[3]
|
||||
user.email = query_row[4]
|
||||
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
|
||||
user.is_super_user = av.input_bool(query_row[6], 'is_super_user', _m)
|
||||
user.can_admin_dog = av.input_bool(query_row[7], 'can_admin_dog', _m)
|
||||
user.can_admin_user = av.input_bool(query_row[8], 'can_admin_user', _m)
|
||||
user.is_new = av.input_bool(query_row[9], 'is_new', _m)
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
@@ -133,9 +134,6 @@ class User_Temp(db.Model, Base):
|
||||
email = db.Column(db.String(250))
|
||||
is_email_verified = db.Column(db.Boolean)
|
||||
is_super_user = db.Column(db.Boolean)
|
||||
id_currency_default = db.Column(db.Integer)
|
||||
id_region_default = db.Column(db.Integer)
|
||||
is_included_VAT_default = db.Column(db.Boolean)
|
||||
# is_logged_in: bool
|
||||
|
||||
def __init__(self):
|
||||
@@ -150,36 +148,51 @@ class Parameters_User(Get_Many_Parameters_Base):
|
||||
get_inactive_user: bool
|
||||
ids_user: str
|
||||
ids_user_auth0: str
|
||||
names_user: str
|
||||
require_all_id_search_filters_met: bool
|
||||
require_any_id_search_filters_met: bool
|
||||
require_all_non_id_search_filters_met: bool
|
||||
require_any_non_id_search_filters_met: bool
|
||||
|
||||
@staticmethod
|
||||
def from_form(form):
|
||||
|
||||
@classmethod
|
||||
def from_form(cls, form):
|
||||
av.val_instance(form, 'form', 'Parameters_User.from_form', Form_Filters_User)
|
||||
get_inactive = av.input_bool(form.active.data, "active", "Parameters_User.from_form")
|
||||
id_user = '' if form.id_user.data is None else form.id_user.data
|
||||
return Parameters_User(
|
||||
get_all_user = (id_user == ''),
|
||||
get_inactive_user = get_inactive,
|
||||
ids_user = id_user,
|
||||
ids_user_auth0 = '',
|
||||
)
|
||||
filters = cls.get_default()
|
||||
filters.get_all_user = (id_user == '')
|
||||
filters.get_inactive_user = get_inactive
|
||||
filters.ids_user = id_user
|
||||
filters.ids_user_auth0 = ''
|
||||
filters.require_all_id_search_filters_met = True
|
||||
filters.require_any_id_search_filters_met = True
|
||||
filters.require_all_non_id_search_filters_met = False
|
||||
filters.require_any_non_id_search_filters_met = True
|
||||
return filters
|
||||
|
||||
@staticmethod
|
||||
def from_user(user):
|
||||
@classmethod
|
||||
def from_user(cls, user):
|
||||
av.val_instance(user, 'user', 'Parameters_User.from_user', User)
|
||||
return Parameters_User(
|
||||
get_all_user = ((user.id_user is None or user.id_user == 0) and user.id_user_auth0 is None),
|
||||
get_inactive_user = False,
|
||||
ids_user = '' if user.id_user is None else str(user.id_user),
|
||||
ids_user_auth0 = user.id_user_auth0,
|
||||
)
|
||||
filters = cls.get_default()
|
||||
filters.get_all_user = ((user.id_user is None or user.id_user == 0) and user.id_user_auth0 is None)
|
||||
filters.get_inactive_user = False
|
||||
filters.ids_user = '' if user.id_user is None else str(user.id_user)
|
||||
filters.ids_user_auth0 = user.id_user_auth0
|
||||
return filters
|
||||
|
||||
@staticmethod
|
||||
def get_default():
|
||||
return Parameters_User(
|
||||
get_all_user = False,
|
||||
get_inactive_user = False,
|
||||
ids_user = '',
|
||||
ids_user_auth0 = ''
|
||||
@classmethod
|
||||
def get_default(cls):
|
||||
return cls(
|
||||
get_all_user = False
|
||||
, get_inactive_user = False
|
||||
, ids_user = ''
|
||||
, ids_user_auth0 = ''
|
||||
, names_user = ''
|
||||
, require_all_id_search_filters_met = True
|
||||
, require_any_id_search_filters_met = True
|
||||
, require_all_non_id_search_filters_met = False
|
||||
, require_any_non_id_search_filters_met = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -191,6 +204,11 @@ class Parameters_User(Get_Many_Parameters_Base):
|
||||
, 'a_get_inactive_user': self.get_inactive_user
|
||||
, 'a_ids_user': self.ids_user
|
||||
, 'a_ids_user_auth0': self.ids_user_auth0
|
||||
, 'a_names_user': self.names_user
|
||||
, 'a_require_all_id_search_filters_met': self.require_all_id_search_filters_met
|
||||
, 'a_require_any_id_search_filters_met': self.require_any_id_search_filters_met
|
||||
, 'a_require_all_non_id_search_filters_met': self.require_all_non_id_search_filters_met
|
||||
, 'a_require_any_non_id_search_filters_met': self.require_any_non_id_search_filters_met
|
||||
}
|
||||
|
||||
class User_Permission_Evaluation(db.Model):
|
||||
|
||||
Reference in New Issue
Block a user