Feat(SQL, UI): Button Icons page, Command Button Links page created with get and set functionality.
This commit is contained in:
54
forms/dog/button_icon.py
Normal file
54
forms/dog/button_icon.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Button_Icon Form
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF form for handling user input on Button_Icons page.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from business_objects.base import Base
|
||||
# from business_objects.dog.button_icon import Button_Icon # Circular
|
||||
from helpers.helper_app import Helper_App
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from models.model_view_base import Model_View_Base
|
||||
from forms.base import Form_Base
|
||||
import 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, StringField, 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_Button_Icon(Form_Base):
|
||||
search = StringField(
|
||||
'Search'
|
||||
)
|
||||
active_only = BooleanField(
|
||||
'Active'
|
||||
, default = True
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
filters = cls()
|
||||
filters.search.data = json[Base.FLAG_SEARCH]
|
||||
filters.active_only.data = av.input_bool(json[Base.FLAG_ACTIVE_ONLY], Base.FLAG_ACTIVE_ONLY, f'{cls.__name__}.from_json')
|
||||
return filters
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
Base.FLAG_SEARCH: self.search.data
|
||||
, Base.FLAG_ACTIVE_ONLY: self.active_only.data
|
||||
}
|
||||
103
forms/dog/command_button_link.py
Normal file
103
forms/dog/command_button_link.py
Normal file
@@ -0,0 +1,103 @@
|
||||
"""
|
||||
Project: PARTS Website
|
||||
Author: Edward Middleton-Smith
|
||||
Precision And Research Technology Systems Limited
|
||||
|
||||
Technology: Backend
|
||||
Feature: Dog Command Link Form
|
||||
|
||||
Description:
|
||||
Defines Flask-WTF form for handling user input on Dog Command Links page.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
# internal
|
||||
from business_objects.base import Base
|
||||
from business_objects.dog.button_icon import Button_Icon
|
||||
from business_objects.dog.button_shape import Button_Shape
|
||||
from business_objects.dog.colour import Colour
|
||||
from business_objects.dog.command_category import Command_Category
|
||||
from business_objects.dog.command import Command
|
||||
from business_objects.dog.dog import Dog
|
||||
from business_objects.dog.location import Location
|
||||
from business_objects.dog.obedience_level import Obedience_Level
|
||||
from helpers.helper_app import Helper_App
|
||||
# from models.model_view_store import Model_View_Store # circular
|
||||
# from models.model_view_base import Model_View_Base
|
||||
from forms.base import Form_Base
|
||||
import 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, StringField, 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_Command_Button_Link(Form_Base):
|
||||
search = StringField(
|
||||
'Search'
|
||||
)
|
||||
id_command_category = SelectField(
|
||||
'Command Category'
|
||||
, 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()
|
||||
)
|
||||
id_button_shape = SelectField(
|
||||
'Shape'
|
||||
, choices = [Form_Base.get_select_option_all()]
|
||||
, default = Form_Base.get_select_option_default_value()
|
||||
)
|
||||
id_colour = SelectField(
|
||||
'Colour'
|
||||
, choices = [Form_Base.get_select_option_all()]
|
||||
, default = Form_Base.get_select_option_default_value()
|
||||
)
|
||||
id_button_icon = SelectField(
|
||||
'Icon'
|
||||
, choices = [Form_Base.get_select_option_all()]
|
||||
, default = Form_Base.get_select_option_default_value()
|
||||
)
|
||||
id_location = SelectField(
|
||||
'Location'
|
||||
, 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):
|
||||
_m = f'{cls.__qualname__}.from_json'
|
||||
Helper_App.console_log(f'{_m}\njson: {json}')
|
||||
filters = cls()
|
||||
filters.search.data = json[Base.FLAG_SEARCH]
|
||||
filters.id_command_category.data = json[Command_Category.ATTR_ID_COMMAND_CATEGORY]
|
||||
filters.id_command.data = json[Command.ATTR_ID_COMMAND]
|
||||
filters.id_button_shape.data = json[Button_Shape.ATTR_ID_BUTTON_SHAPE]
|
||||
filters.id_colour.data = json[Colour.ATTR_ID_COLOUR]
|
||||
filters.id_button_icon.data = json[Button_Icon.ATTR_ID_BUTTON_ICON]
|
||||
filters.id_location.data = json[Location.ATTR_ID_LOCATION]
|
||||
filters.active_only.data = av.input_bool(json[Base.FLAG_ACTIVE_ONLY], Base.FLAG_ACTIVE_ONLY, f'{cls.__name__}.from_json')
|
||||
return filters
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
Base.FLAG_SEARCH: self.search.data
|
||||
, Command_Category.ATTR_ID_COMMAND_CATEGORY: self.id_command_category.data
|
||||
, Command.ATTR_ID_COMMAND: self.id_command.data
|
||||
, Button_Shape.ATTR_ID_BUTTON_SHAPE: self.id_button_shape.data
|
||||
, Colour.ATTR_ID_COLOUR: self.id_colour.data
|
||||
, Button_Icon.ATTR_ID_BUTTON_ICON: self.id_button_icon.data
|
||||
, Location.ATTR_ID_LOCATION: self.id_location.data
|
||||
, Base.FLAG_ACTIVE_ONLY: self.active_only.data
|
||||
}
|
||||
Reference in New Issue
Block a user