152 lines
5.6 KiB
Python
152 lines
5.6 KiB
Python
"""
|
|
Project: PARTS Website
|
|
Author: Edward Middleton-Smith
|
|
Precision And Research Technology Systems Limited
|
|
|
|
Technology: Backend
|
|
Feature: Assessment Form
|
|
|
|
Description:
|
|
Defines Flask-WTF form for handling user input on Assessments page.
|
|
"""
|
|
|
|
# IMPORTS
|
|
# internal
|
|
from business_objects.base import Base
|
|
"""
|
|
from business_objects.dog.distraction_intensity_level import Distraction_Intensity_Level
|
|
from business_objects.dog.distraction_type import Distraction_Type
|
|
from business_objects.dog.command import Lighting_Level
|
|
from business_objects.dog.command_category import Lighting_Level
|
|
from business_objects.dog.lighting_level import Lighting_Level
|
|
from business_objects.dog.lighting_level import Lighting_Level
|
|
"""
|
|
from business_objects.dog.lighting_level import Lighting_Level
|
|
from business_objects.dog.location import Location
|
|
from business_objects.dog.weather import Weather
|
|
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
|
|
from typing import ClassVar
|
|
|
|
class Filters_Assessment(Form_Base):
|
|
ATTR_ID_ASSESSMENT: ClassVar[str] = 'id_assessment'
|
|
FLAG_USER_HANDLER: ClassVar[str] = 'id_user_handler'
|
|
|
|
search = StringField(
|
|
'Search'
|
|
)
|
|
id_assessment = SelectField(
|
|
'Assessment'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_weather = SelectField(
|
|
'Weather'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_lighting_level = SelectField(
|
|
'Lighting Level'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_location = SelectField(
|
|
'Location'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_user_handler = SelectField(
|
|
'Handler'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
"""
|
|
id_distraction_type = SelectField(
|
|
'Distraction Type'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_intensity_level_emotional = SelectField(
|
|
'Intensity Level Emotional'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_intensity_level_scent = SelectField(
|
|
'Intensity Level Scent'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_intensity_level_sight = SelectField(
|
|
'Intensity Level Sight'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_intensity_level_sound = SelectField(
|
|
'Intensity Level Sound'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_intensity_level_touch = SelectField(
|
|
'Intensity Level Touch'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_command_category = SelectField(
|
|
'Command Category'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_command = SelectField(
|
|
'Command'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_command_modality = SelectField(
|
|
'Command Modality'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_option_default_value()
|
|
)
|
|
id_bribe = SelectField(
|
|
'Bribe'
|
|
, choices = [Form_Base.get_select_option_all()]
|
|
, default = Form_Base.get_select_valid_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_assessment.data = json[cls.ATTR_ID_ASSESSMENT]
|
|
filters.id_weather.data = json[Weather.ATTR_ID_WEATHER]
|
|
filters.id_lighting_level.data = json[Lighting_Level.ATTR_ID_LIGHTING_LEVEL]
|
|
filters.id_location.data = json[Location.ATTR_ID_LOCATION]
|
|
filters.id_user_handler.data = json[cls.FLAG_USER_HANDLER]
|
|
# filters.id_distraction_type = json[Distraction_Type.ATTR_ID_DISTRACTION_TYPE]
|
|
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
|
|
}
|