52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
"""
|
|
Project: PARTS Website
|
|
Author: Edward Middleton-Smith
|
|
Precision And Research Technology Systems Limited
|
|
|
|
Technology: View Models
|
|
Feature: Dog Command View Model
|
|
|
|
Description:
|
|
Data model for dog commands view
|
|
"""
|
|
|
|
# internal
|
|
from business_objects.dog.command import Command, Parameters_Command
|
|
from datastores.datastore_dog import DataStore_Dog
|
|
from models.model_view_dog_base import Model_View_Dog_Base
|
|
from forms.dog.command import Filters_Command
|
|
# 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_Command(Model_View_Dog_Base):
|
|
FLAG_CAN_HAVE_BUTTON: ClassVar[str] = Command.FLAG_CAN_HAVE_BUTTON
|
|
FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION: ClassVar[str] = Command.FLAG_HAND_SIGNAL_DEFAULT_DESCRIPTION
|
|
filter_command_categories: list = None
|
|
commands: list = None
|
|
form_filters: Filters_Command = None
|
|
form_filters_old: Filters_Command
|
|
|
|
def __init__(self, form_filters_old, hash_page_current=Model_View_Dog_Base.HASH_PAGE_DOG_COMMANDS):
|
|
_m = 'Model_View_Dog_Command.__init__'
|
|
Helper_App.console_log(f'{_m}\nstarting...')
|
|
super().__init__(hash_page_current=hash_page_current, form_filters_old=form_filters_old)
|
|
self._title = 'Command'
|
|
self.form_filters = form_filters_old
|
|
datastore = DataStore_Dog()
|
|
|
|
user_session = datastore.get_user_session()
|
|
|
|
parameters_filter_command = Parameters_Command.get_default(user_session.id_user)
|
|
self.filter_command_categories, filter_commands, errors = datastore.get_many_command(parameters_filter_command)
|
|
self.form_filters.id_command_category.choices += [(str(command_category.id_command_category), command_category.name) for command_category in self.filter_command_categories]
|
|
|
|
Helper_App.console_log(f'Form filters: {self.form_filters}')
|
|
parameters_filter_command = Parameters_Command.from_form_filters_command(self.form_filters, user_session.id_user)
|
|
Helper_App.console_log(f'Query args: {parameters_filter_command}')
|
|
command_categories, self.commands, errors = datastore.get_many_command(parameters_filter_command)
|