Feat(SQL): Location Get Many and Calc Stored Procedures created with logic using Location Link table.

This commit is contained in:
2025-07-15 15:07:40 +01:00
parent 7573f329e9
commit a3fd8b12fe
44 changed files with 2590 additions and 873 deletions

View File

@@ -23,6 +23,7 @@ from business_objects.dog.command import Command
from business_objects.dog.command_category import Command_Category
from business_objects.dog.dog import Dog
from business_objects.dog.dog_command_link import Dog_Command_Link
from business_objects.dog.location import Location
from datastores.datastore_base import DataStore_Base
from datastores.datastore_dog import DataStore_Dog
from datastores.datastore_user import DataStore_User
@@ -41,6 +42,7 @@ class Model_View_Base(BaseModel, ABC):
ATTR_ID_COMMAND_CATEGORY: ClassVar[str] = Command_Category.ATTR_ID_COMMAND_CATEGORY
ATTR_ID_DOG: ClassVar[str] = Dog.ATTR_ID_DOG
ATTR_ID_DOG_COMMAND_LINK: ClassVar[str] = Dog_Command_Link.ATTR_ID_DOG_COMMAND_LINK
ATTR_ID_LOCATION: ClassVar[str] = Location.ATTR_ID_LOCATION
ATTR_TEXT_COLLAPSED: ClassVar[str] = 'textCollapsed'
ATTR_TEXT_EXPANDED: ClassVar[str] = 'textExpanded'
ATTR_VALUE_CURRENT: ClassVar[str] = 'current-value'
@@ -121,6 +123,8 @@ class Model_View_Base(BaseModel, ABC):
FLAG_IS_CHECKED: ClassVar[str] = 'is_checked'
FLAG_IS_COLLAPSED: ClassVar[str] = 'is_collapsed'
FLAG_LEFT_HAND_STUB: ClassVar[str] = 'lhs'
FLAG_LOCATION: ClassVar[str] = Location.FLAG_LOCATION
FLAG_LOCATION_PARENT: ClassVar[str] = Location.FLAG_LOCATION_PARENT
FLAG_LOGO: ClassVar[str] = 'logo'
FLAG_MESSAGE: ClassVar[str] = Command.FLAG_MESSAGE
FLAG_MODAL: ClassVar[str] = 'modal'
@@ -171,6 +175,7 @@ class Model_View_Base(BaseModel, ABC):
HASH_PAGE_DOG_DOG_COMMAND_LINKS: ClassVar[str] = '/dog/dog-command-links'
HASH_PAGE_DOG_DOGS: ClassVar[str] = '/dog/dogs'
HASH_PAGE_DOG_HOME: ClassVar[str] = '/dog/home'
HASH_PAGE_DOG_LOCATIONS: ClassVar[str] = '/dog/locations'
HASH_PAGE_ERROR_NO_PERMISSION: ClassVar[str] = '/error'
HASH_PAGE_HOME: ClassVar[str] = '/'
HASH_PAGE_LICENSE: ClassVar[str] = '/license'
@@ -181,6 +186,7 @@ class Model_View_Base(BaseModel, ABC):
HASH_SAVE_DOG_COMMAND: ClassVar[str] = '/dog/save-command'
HASH_SAVE_DOG_COMMAND_CATEGORY: ClassVar[str] = '/dog/save-command-category'
HASH_SAVE_DOG_DOG_COMMAND_LINK: ClassVar[str] = '/dog/save-dog-command-link'
HASH_SAVE_DOG_LOCATION: ClassVar[str] = '/dog/save-location'
ID_BUTTON_ADD: ClassVar[str] = 'buttonAdd'
ID_BUTTON_APPLY_FILTERS: ClassVar[str] = 'buttonApplyFilters'
ID_BUTTON_CANCEL: ClassVar[str] = 'buttonCancel'

View File

@@ -4,10 +4,10 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Parent View Model
Feature: Dog Parent View Model
Description:
Parent data model for store views
Parent data model for dog views
"""

View File

@@ -4,10 +4,10 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Feature: Dog Command View Model
Description:
Data model for store permutations view
Data model for dog commands view
"""
# internal

View File

@@ -4,10 +4,10 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Feature: Dog Command Category View Model
Description:
Data model for store permutations view
Data model for dog command categories view
"""
# internal

View File

@@ -4,10 +4,10 @@ Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Feature: Dog Dog Command Link View Model
Description:
Data model for store permutations view
Data model for dog dog command links view
"""
# internal

View File

@@ -0,0 +1,60 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Dog Locations View Model
Description:
Data model for dog locations view
"""
# internal
from business_objects.dog.location import Location, Parameters_Location
from datastores.datastore_dog import DataStore_Dog
from models.model_view_dog_base import Model_View_Dog_Base
from forms.dog.location import Filters_Location
# from routes import bp_home
from helpers.helper_app import Helper_App
import lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Dog_Location(Model_View_Dog_Base):
FLAG_CAN_HAVE_BUTTON: ClassVar[str] = Location.FLAG_CAN_HAVE_BUTTON
FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: ClassVar[str] = Location.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION
filter_location_categories: list = None
locations: list = None
form_filters: Filters_Location = None
form_filters_old: Filters_Location
@property
def title(self):
return 'Location'
def __init__(self, form_filters_old, hash_page_current=Model_View_Dog_Base.HASH_PAGE_DOG_LOCATIONS):
_m = 'Model_View_Dog_Location.__init__'
Helper_App.console_log(f'{_m}\nstarting...')
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old)
self.form_filters = form_filters_old
datastore = DataStore_Dog()
parameters_filter_location = Parameters_Location.get_default()
self.filter_location_categories, filter_locations, errors = datastore.get_many_location(parameters_filter_location)
self.form_filters.id_location_category.choices += [(str(location_category.id_location_category), location_category.name) for location_category in self.filter_location_categories]
Helper_App.console_log(f'Form filters: {self.form_filters}')
parameters_filter_location = Parameters_Location.from_form_filters_location(self.form_filters)
Helper_App.console_log(f'Query args: {parameters_filter_location}')
location_categories, self.locations, errors = datastore.get_many_location(parameters_filter_location)
"""
@classmethod
def save_categories(cls, comment, list_categories):
_m = f'{cls.__name__}.save_categories'
return DataStore_Store_Product_Category().save_categories(comment, list_categories)
"""