Files
dog_training/models/model_view_dog_dog_command_link.py

72 lines
3.4 KiB
Python

"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: View Models
Feature: Store Permutations View Model
Description:
Data model for store permutations view
"""
# internal
from dog_training.business_objects.dog.command import Command, Parameters_Command
from dog_training.business_objects.dog.dog import Dog, Parameters_Dog
from dog_training.business_objects.dog.dog_command_link import Dog_Command_Link, Parameters_Dog_Command_Link
from dog_training.business_objects.dog.obedience_level import Obedience_Level
from dog_training.datastores.datastore_dog import DataStore_Dog
from dog_training.models.model_view_dog_base import Model_View_Dog_Base
from dog_training.forms.dog.dog_command_link import Filters_Dog_Command_Link
# from routes import bp_home
from dog_training.helpers.helper_app import Helper_App
import dog_training.lib.argument_validation as av
# external
from pydantic import BaseModel
from typing import ClassVar
class Model_View_Dog_Dog_Command_Link(Model_View_Dog_Base):
FLAG_HAND_SIGNAL_DESCRIPTION: ClassVar[str] = Dog_Command_Link.FLAG_HAND_SIGNAL_DESCRIPTION
filter_dogs: list = None
filter_command_categories: list = None
filter_commands: list = None
dog_command_links: list = None
form_filters: Filters_Dog_Command_Link = None
form_filters_old: Filters_Dog_Command_Link
@property
def title(self):
return 'Dog Command Link'
def __init__(self, form_filters_old, hash_page_current=Model_View_Dog_Base.HASH_PAGE_DOG_DOG_COMMAND_LINKS):
_m = 'Model_View_Dog_Dog_Command_Link.__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_dog = Parameters_Dog.get_default()
self.filter_dogs, errors = datastore.get_many_dog(parameters_filter_dog)
parameters_filter_command = Parameters_Command.get_default()
self.filter_command_categories, self.filter_commands, errors = datastore.get_many_command(parameters_filter_command)
Helper_App.console_log(f'Form filters: {self.form_filters}')
parameters_filter_dog_command_link = Parameters_Dog_Command_Link.from_form_filters_dog_command_link(self.form_filters)
Helper_App.console_log(f'Query args: {parameters_filter_dog_command_link}')
self.dog_command_links, errors = datastore.get_many_dog_command_link(parameters_filter_dog_command_link)
# Helper_App.console_log(f'dogs: {self.filter_dogs}')
# Helper_App.console_log(f'commands: {self.filter_commands}')
# Helper_App.console_log(f'links: {self.dog_command_links}')
self.form_filters.id_dog.choices += [(str(dog.id_dog), dog.name) for dog in self.filter_dogs]
self.form_filters.id_command_category.choices += [(str(command_category.id_command_category), command_category.name) for command_category in self.filter_command_categories]
self.form_filters.id_command.choices += [(str(command.id_command), command.name) for command in self.filter_commands]
"""
@classmethod
def save_categories(cls, comment, list_categories):
_m = f'{cls.__name__}.save_categories'
return DataStore_Store_Product_Category().save_categories(comment, list_categories)
"""