Feat(SQL, UI): Redesign database with much more detailed command response quality analysis and created successfully loading Dog Command Links page
This commit is contained in:
0
forms/dog/__init__.py
Normal file
0
forms/dog/__init__.py
Normal file
64
forms/dog/dog_command_link.py
Normal file
64
forms/dog/dog_command_link.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Contact Us Form
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF form for handling user input on Contact Us page.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from dog_training.business_objects.base import Base
|
||||
from dog_training.business_objects.dog.command import Command
|
||||
from dog_training.business_objects.dog.dog import Dog
|
||||
from dog_training.business_objects.dog.obedience_level import Obedience_Level
|
||||
# from dog_training.models.model_view_store import Model_View_Store # circular
|
||||
# from dog_training.models.model_view_base import Model_View_Base
|
||||
from dog_training.forms.base import Form_Base
|
||||
import dog_training.lib.argument_validation as av
|
||||
# external
|
||||
from flask import Flask, render_template, request, flash, redirect, url_for, current_app
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SelectField, BooleanField, SubmitField
|
||||
from wtforms.validators import DataRequired, Email, ValidationError
|
||||
import markupsafe
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
import json
|
||||
|
||||
class Filters_Dog_Command_Link(Form_Base):
|
||||
id_dog = SelectField(
|
||||
'Dog'
|
||||
, choices = [Form_Base.get_select_option_all()]
|
||||
, default = Form_Base.get_select_option_default_value()
|
||||
)
|
||||
id_command = SelectField(
|
||||
'Command'
|
||||
, choices = [Form_Base.get_select_option_all()]
|
||||
, default = Form_Base.get_select_option_default_value()
|
||||
)
|
||||
active_only = BooleanField(
|
||||
'Active'
|
||||
, default = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
filters = cls()
|
||||
filters.id_dog.choices = [(json[Dog.ATTR_ID_DOG], json[Dog.ATTR_ID_DOG])]
|
||||
filters.id_dog.data = json[Dog.ATTR_ID_DOG]
|
||||
filters.id_command.choices = [(json[Command.ATTR_ID_COMMAND], json[Command.ATTR_ID_COMMAND])]
|
||||
filters.id_command.data = json[Command.ATTR_ID_COMMAND]
|
||||
filters.active_only.data = av.input_bool(json[Base.FLAG_ACTIVE], Base.FLAG_ACTIVE, f'{cls.__name__}.from_json')
|
||||
return filters
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
Dog.FLAG_DOG: self.id_dog.data
|
||||
, Command.FLAG_COMMAND: self.id_command.data
|
||||
, Base.FLAG_ACTIVE: self.active_only.data
|
||||
}
|
||||
Reference in New Issue
Block a user