class MethodAdd(FlaskForm): method_id = StringField('Method ID', widget=widgets.HiddenInput()) method_type = HiddenField('Method Type') daily_time_start = StringField(lazy_gettext('Start HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) daily_time_end = StringField(lazy_gettext('End HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) time_start = StringField(lazy_gettext('Start YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) time_end = StringField(lazy_gettext('End YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) setpoint_start = DecimalField(lazy_gettext('Start Setpoint'), widget=NumberInput(step='any')) setpoint_end = DecimalField(lazy_gettext('End Setpoint (optional)'), widget=NumberInput(step='any')) duration = DecimalField(lazy_gettext('Duration (seconds)'), widget=NumberInput(step='any')) duration_end = DecimalField(lazy_gettext('Duration to End (seconds)'), widget=NumberInput(step='any')) amplitude = DecimalField(lazy_gettext('Amplitude'), widget=NumberInput(step='any')) frequency = DecimalField(lazy_gettext('Frequency'), widget=NumberInput(step='any')) shift_angle = DecimalField(lazy_gettext('Angle Shift (0 to 360)'), widget=NumberInput(step='any')) shiftY = DecimalField(lazy_gettext('Y-Axis Shift'), widget=NumberInput(step='any')) x0 = DecimalField('X0', widget=NumberInput(step='any')) y0 = DecimalField('Y0', widget=NumberInput(step='any')) x1 = DecimalField('X1', widget=NumberInput(step='any')) y1 = DecimalField('Y1', widget=NumberInput(step='any')) x2 = DecimalField('X2', widget=NumberInput(step='any')) y2 = DecimalField('Y2', widget=NumberInput(step='any')) x3 = DecimalField('X3', widget=NumberInput(step='any')) y3 = DecimalField('Y3', widget=NumberInput(step='any')) output_daily_time = StringField(lazy_gettext('Time HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) output_time = StringField(lazy_gettext('Time YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) save = SubmitField(lazy_gettext('Add to Method')) restart = SubmitField(lazy_gettext('Set Repeat Option'))
class SettingsPi(FlaskForm): pigpiod_state = StringField('pigpiod state', widget=widgets.HiddenInput()) enable_i2c = SubmitField(lazy_gettext('Enable I2C')) disable_i2c = SubmitField(lazy_gettext('Disable I2C')) enable_one_wire = SubmitField(lazy_gettext('Enable 1-Wire')) disable_one_wire = SubmitField(lazy_gettext('Disable 1-Wire')) enable_serial = SubmitField(lazy_gettext('Enable Serial')) disable_serial = SubmitField(lazy_gettext('Disable Serial')) enable_spi = SubmitField(lazy_gettext('Enable SPI')) disable_spi = SubmitField(lazy_gettext('Disable SPI')) enable_ssh = SubmitField(lazy_gettext('Enable SSH')) disable_ssh = SubmitField(lazy_gettext('Disable SSH')) enable_pi_camera = SubmitField(lazy_gettext('Enable Pi Camera')) disable_pi_camera = SubmitField(lazy_gettext('Disable Pi Camera')) hostname = StringField(lazy_gettext('Hostname')) change_hostname = SubmitField(lazy_gettext('Change Hostname')) pigpiod_sample_rate = StringField(lazy_gettext('Configure pigpiod')) change_pigpiod_sample_rate = SubmitField(lazy_gettext('Reconfigure')) sample_rate_controller_conditional = DecimalField( lazy_gettext('Conditional Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_function = DecimalField( lazy_gettext('Function Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_input = DecimalField( lazy_gettext('Input Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_math = DecimalField( lazy_gettext('Math Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_output = DecimalField( lazy_gettext('Output Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_pid = DecimalField( lazy_gettext('PID Sample Rate (seconds)'), widget=NumberInput(step='any')) sample_rate_controller_widget = DecimalField( lazy_gettext('Widget Sample Rate (seconds)'), widget=NumberInput(step='any')) save_sample_rates = SubmitField(lazy_gettext('Save Sample Rates'))
class TimerBase(FlaskForm): timer_id = IntegerField('Timer ID', widget=widgets.HiddenInput()) timer_type = SelectField(lazy_gettext('Timer Type'), choices=[ ('', lazy_gettext('Select a Timer Type')), ('time', lazy_gettext('Daily Time Point')), ('timespan', lazy_gettext('Daily Time Span')), ('duration', lazy_gettext('Duration')), ('pwm_method', lazy_gettext('PWM Method (Duty Cycle)')) ], validators=[DataRequired()]) name = StringField(lazy_gettext('Name'), validators=[DataRequired()]) relay_id = StringField(lazy_gettext('Output')) create = SubmitField(lazy_gettext('Add')) modify = SubmitField(lazy_gettext('Save')) delete = SubmitField(lazy_gettext('Delete')) activate = SubmitField(lazy_gettext('Activate')) deactivate = SubmitField(lazy_gettext('Deactivate')) order_up = SubmitField(lazy_gettext('Up')) order_down = SubmitField(lazy_gettext('Down'))
class Timer(FlaskForm): timer_id = IntegerField('Timer ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Name'), validators=[DataRequired()]) relayID = StringField(lazy_gettext(u'Relay ID')) state = SelectField(lazy_gettext(u'State'), choices=[('on', 'On'), ('off', 'Off')], validators=[DataRequired()]) timeStart = StringField(lazy_gettext(u'Start Time')) timeEnd = StringField(lazy_gettext(u'End Time')) timeOnDurationOn = DecimalField( lazy_gettext(u'On (sec)'), validators=[validators.NumberRange(min=0, max=86400)]) durationOn = DecimalField(lazy_gettext(u'On (sec)')) durationOff = DecimalField(lazy_gettext(u'Off (sec)')) timerCreate = SubmitField(lazy_gettext(u'Save')) timerMod = SubmitField(lazy_gettext(u'Save')) timerDel = SubmitField(lazy_gettext(u'Delete')) activate = SubmitField(lazy_gettext(u'Activate')) deactivate = SubmitField(lazy_gettext(u'Deactivate')) orderTimerUp = SubmitField(lazy_gettext(u'Up')) orderTimerDown = SubmitField(lazy_gettext(u'Down'))
class MethodAdd(FlaskForm): method_id = IntegerField('Method ID', widget=widgets.HiddenInput()) method_type = HiddenField('Method Type') method_select = HiddenField('Method Select') daily_time_start = StringField(lazy_gettext('Start HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) daily_time_end = StringField(lazy_gettext('End HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) time_start = StringField(lazy_gettext('Start YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) time_end = StringField(lazy_gettext('End YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) setpoint_start = DecimalField(lazy_gettext('Start Setpoint')) setpoint_end = DecimalField(lazy_gettext('End Setpoint (optional)')) duration = DecimalField(lazy_gettext('Duration (seconds)')) duration_end = DecimalField(lazy_gettext('End After (seconds)')) amplitude = DecimalField(lazy_gettext('Amplitude')) frequency = DecimalField(lazy_gettext('Frequency')) shift_angle = DecimalField(lazy_gettext('Angle Shift (0 to 360)')) shiftY = DecimalField(lazy_gettext('Y-Axis Shift')) x0 = DecimalField('X0') y0 = DecimalField('Y0') x1 = DecimalField('X1') y1 = DecimalField('Y1') x2 = DecimalField('X2') y2 = DecimalField('Y2') x3 = DecimalField('X3') y3 = DecimalField('Y3') relay_daily_time = StringField(lazy_gettext('Time HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) relay_time = StringField(lazy_gettext('Time YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) relay_duration = IntegerField(lazy_gettext('Duration On (seconds)')) relay_id = StringField(lazy_gettext('Output'), ) relay_state = SelectField(lazy_gettext('Relay State'), choices=[('', ''), ('On', lazy_gettext('Turn On')), ('Off', lazy_gettext('Turn Off'))]) save = SubmitField(lazy_gettext('Add to Method')) restart = SubmitField(lazy_gettext('Restart at Beginning'))
class DashboardBase(FlaskForm): dashboard_id = StringField('Dash Object ID', widget=widgets.HiddenInput()) dashboard_type = SelectField( 'Dashboard Element Type', choices=[ ('', lazy_gettext('Add Dashboard Element')), ('graph', lazy_gettext('Graph')), ('gauge', lazy_gettext('Gauge')), ('measurement', lazy_gettext('Measurement')), ('output', lazy_gettext('Output')), ('pid_control', lazy_gettext('PID Control')), ('camera', lazy_gettext('Camera')), ], validators=[DataRequired()]) name = StringField(lazy_gettext('Name'), validators=[DataRequired()]) width = IntegerField(lazy_gettext('Width'), validators=[validators.NumberRange(min=1, max=12)], widget=NumberInput()) height = IntegerField( lazy_gettext('Height (pixels)'), validators=[validators.NumberRange(min=100, max=10000)], widget=NumberInput()) refresh_duration = IntegerField( lazy_gettext('Refresh (seconds)'), validators=[ validators.NumberRange( min=1, message=lazy_gettext( "Number of seconds to wait between acquiring" " any new measurements.")) ], widget=NumberInput()) list_visible_elements = SelectMultipleField( lazy_gettext('Visible Elements')) reorder = SubmitField(lazy_gettext('Save Order')) create = SubmitField(lazy_gettext('Create')) modify = SubmitField(lazy_gettext('Save')) delete = SubmitField(lazy_gettext('Delete')) order_up = SubmitField(lazy_gettext('Up')) order_down = SubmitField(lazy_gettext('Down'))
class LCDMod(FlaskForm): lcd_id = StringField('LCD ID', widget=widgets.HiddenInput()) name = StringField( TRANSLATIONS['name']['title'], validators=[DataRequired()] ) location = StringField( "{op} ({unit})".format(op=lazy_gettext('Address'), unit=lazy_gettext('I<sup>2</sup>C')) ) i2c_bus = IntegerField( "{op} ({unit})".format(op=lazy_gettext('Bus'), unit=lazy_gettext('I<sup>2</sup>C')), validators=[DataRequired()], widget=NumberInput() ) pin_reset = IntegerField( "{pin}: {reset}".format(pin=TRANSLATIONS['pin']['title'], reset=TRANSLATIONS['reset']['title']), validators=[Optional()] ) period = DecimalField( lazy_gettext('Period (seconds)'), validators=[validators.NumberRange( min=5, max=86400, message=lazy_gettext("Duration between calculating LCD output " "and applying to regulation must be between " "5 and 86400 seconds.") )], widget=NumberInput(step='any') ) add_display = SubmitField(lazy_gettext('Add Display Set')) save = SubmitField(TRANSLATIONS['save']['title']) delete = SubmitField(TRANSLATIONS['delete']['title']) activate = SubmitField(TRANSLATIONS['activate']['title']) deactivate = SubmitField(TRANSLATIONS['deactivate']['title']) reorder_up = SubmitField(TRANSLATIONS['up']['title']) reorder_down = SubmitField(TRANSLATIONS['down']['title']) reset_flashing = SubmitField(lazy_gettext('Reset LCD'))
class GaugeAdd(FlaskForm): graph_type = StringField('Type', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Name'), validators=[DataRequired()]) sensor_ids = SelectMultipleField(lazy_gettext(u'Measurement')) width = IntegerField(lazy_gettext(u'Width'), validators=[validators.NumberRange(min=1, max=12)]) height = IntegerField( lazy_gettext(u'Height (pixels)'), validators=[validators.NumberRange(min=100, max=10000)]) y_axis_min = DecimalField(lazy_gettext(u'Gauge Min')) y_axis_max = DecimalField(lazy_gettext(u'Gauge Max')) max_measure_age = DecimalField(lazy_gettext(u'Max Age (seconds)')) refresh_duration = IntegerField( lazy_gettext(u'Refresh (seconds)'), validators=[ validators.NumberRange( min=1, message=lazy_gettext( u"Number of seconds to wait between acquiring" u" any new measurements.")) ]) gauge_add = SubmitField(lazy_gettext(u'Create'))
class RelayMod(FlaskForm): relay_id = IntegerField('Relay ID', widget=widgets.HiddenInput()) relay_pin = HiddenField('Relay Pin') name = StringField(lazy_gettext(u'Name'), validators=[DataRequired()]) gpio = IntegerField( lazy_gettext(u'GPIO Pin'), validators=[ validators.NumberRange( min=0, max=27, message=lazy_gettext( u"GPIO pin, using BCM numbering, between 1 and 27 " "(0 to disable)")) ]) amps = DecimalField( lazy_gettext(u'Current Draw (amps)'), validators=[ validators.NumberRange( min=0, max=50, message=lazy_gettext( u"The current draw of the device connected " "to this relay, in amps.")) ]) trigger = SelectField(lazy_gettext(u'On Trigger'), choices=[("1", 'High'), ("0", 'Low')], validators=[DataRequired()]) on_at_start = SelectField(lazy_gettext(u'Start State'), choices=[("1", 'On'), ("0", 'Off')], validators=[DataRequired()]) save = SubmitField(lazy_gettext(u'Save')) delete = SubmitField(lazy_gettext(u'Delete')) order_up = SubmitField(lazy_gettext(u'Up')) order_down = SubmitField(lazy_gettext(u'Down')) turn_on = SubmitField(lazy_gettext(u'On')) turn_off = SubmitField(lazy_gettext(u'Off')) sec_on = DecimalField(lazy_gettext(u'Seconds to turn on'), validators=[Optional()]) sec_on_submit = SubmitField(lazy_gettext(u'Turn On'))
class GraphMod(FlaskForm): graph_id = IntegerField('Graph ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Graph Name'), render_kw={"placeholder": lazy_gettext(u"Graph Name")}, validators=[DataRequired()]) pidIDs = SelectMultipleField(lazy_gettext(u'PID IDs (Setpoint)')) relayIDs = SelectMultipleField(lazy_gettext(u'Relay IDs')) sensorIDs = SelectMultipleField(lazy_gettext(u'Sensor IDs')) width = IntegerField(lazy_gettext(u'Width'), validators=[validators.NumberRange(min=1, max=12)]) height = IntegerField( lazy_gettext(u'Height (pixels)'), render_kw={"placeholder": lazy_gettext(u"Percent Height")}, validators=[validators.NumberRange(min=100, max=10000)]) xAxisDuration = IntegerField( lazy_gettext(u'x-Axis (min)'), render_kw={"placeholder": lazy_gettext(u"X-Axis Duration")}, validators=[ validators.NumberRange(min=1, message=lazy_gettext( u"Number of minutes to display of past " "measurements.")) ]) refreshDuration = IntegerField( lazy_gettext(u'Refresh (seconds)'), render_kw={"placeholder": lazy_gettext(u"Refresh duration")}, validators=[ validators.NumberRange( min=1, message=lazy_gettext( u"Number of seconds to wait between acquiring" " any new measurements.")) ]) enableNavbar = BooleanField(lazy_gettext(u'Enable Navbar')) enableExport = BooleanField(lazy_gettext(u'Enable Export')) enableRangeSelect = BooleanField(lazy_gettext(u'Enable Range Selector')) use_custom_colors = BooleanField(lazy_gettext(u'Enable Custom Colors')) Submit = SubmitField(lazy_gettext(u'Save Graph'))
class MathMod(FlaskForm): math_id = StringField('Math ID', widget=widgets.HiddenInput()) name = StringField(TRANSLATIONS['name']['title'], validators=[DataRequired()]) period = DecimalField(lazy_gettext('Period (seconds)'), validators=[DataRequired()], widget=NumberInput(step='any')) max_measure_age = IntegerField(TRANSLATIONS['max_age']['title'], validators=[DataRequired()], widget=NumberInput()) start_offset = DecimalField(lazy_gettext('Start Offset (seconds)'), widget=NumberInput(step='any')) inputs = SelectMultipleField(lazy_gettext('Inputs')) select_measurement_unit = StringField( TRANSLATIONS['select_measurement_unit']['title']) measurements_enabled = SelectMultipleField( TRANSLATIONS['measurements_enabled']['title']) math_mod = SubmitField(TRANSLATIONS['save']['title']) math_delete = SubmitField(TRANSLATIONS['delete']['title']) math_activate = SubmitField(TRANSLATIONS['activate']['title']) math_deactivate = SubmitField(TRANSLATIONS['deactivate']['title']) math_order_up = SubmitField(TRANSLATIONS['up']['title']) math_order_down = SubmitField(TRANSLATIONS['down']['title'])
class Camera(FlaskForm): camera_id = StringField('Camera ID', widget=widgets.HiddenInput()) capture_still = SubmitField(lazy_gettext('Capture Still')) start_timelapse = SubmitField(lazy_gettext('Start Timelapse')) pause_timelapse = SubmitField(lazy_gettext('Pause Timelapse')) resume_timelapse = SubmitField(lazy_gettext('Resume Timelapse')) stop_timelapse = SubmitField(lazy_gettext('Stop Timelapse')) timelapse_interval = DecimalField( lazy_gettext('Interval (seconds)'), validators=[validators.NumberRange( min=0, message=lazy_gettext('Photo Interval must be a positive value') )] ) timelapse_runtime_sec = DecimalField( lazy_gettext('Run Time (seconds)'), validators=[validators.NumberRange( min=0, message=lazy_gettext('Total Run Time must be a positive value') )] ) start_stream = SubmitField(lazy_gettext('Start Stream')) stop_stream = SubmitField(lazy_gettext('Stop Stream'))
class LCDMod(FlaskForm): lcd_id = IntegerField('LCD ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Name'), validators=[DataRequired()]) location = StringField("{op} ({unit})".format( op=lazy_gettext(u'Address'), unit=lazy_gettext(u'I<sup>2</sup>C')), validators=[DataRequired()]) i2c_bus = IntegerField("{op} ({unit})".format( op=lazy_gettext(u'Bus'), unit=lazy_gettext(u'I<sup>2</sup>C')), validators=[DataRequired()]) multiplexer_address = StringField("{op} ({unit})".format( op=lazy_gettext(u'Multiplexer Address'), unit=lazy_gettext(u'I<sup>2</sup>C'))) multiplexer_channel = IntegerField( lazy_gettext(u'Multiplexer Channel'), validators=[validators.NumberRange(min=0, max=8)]) period = DecimalField( lazy_gettext(u'Period (seconds)'), validators=[ validators.NumberRange( min=5, max=86400, message=lazy_gettext( u"Duration between calculating LCD output " u"and applying to regulation must be between " u"5 and 86400 seconds.")) ]) lcd_type = SelectField(lazy_gettext(u'LCD Type'), choices=[('16x2', '16x2'), ('20x4', '20x4')], validators=[DataRequired()]) add_display = SubmitField(lazy_gettext(u'Add Display Set')) save = SubmitField(lazy_gettext(u'Save')) delete = SubmitField(lazy_gettext(u'Delete')) activate = SubmitField(lazy_gettext(u'Activate')) deactivate = SubmitField(lazy_gettext(u'Deactivate')) reorder_up = SubmitField(lazy_gettext(u'Up')) reorder_down = SubmitField(lazy_gettext(u'Down')) reset_flashing = SubmitField(lazy_gettext(u'Reset Flashing'))
class CourseForm(FlaskForm): def __init__(self, formdata=_Auto, **kwargs): super().__init__(formdata, **kwargs) self.update_dynamic_choices() id = IntegerField(widget=widgets.HiddenInput()) #parent = SelectField(gettext('Parent Course'), choices=get_top_courses(), validators=(validators.Optional(),)) parent = SelectField(gettext('Parent Course'), choices=get_all_courses(), validators=(validators.Optional(), )) code = StringField( gettext('Code'), validators=[validators.DataRequired(), unique_code_check], render_kw={"placeholder": gettext('Course code')}) description = StringField( gettext('Description'), validators=[validators.DataRequired()], render_kw={"placeholder": gettext('Course description')}) start = DateField('Start', format='%Y-%m-%d', validators=(validators.Optional(), )) end = DateField('End', format='%Y-%m-%d', validators=(validators.Optional(), )) vle_id = SelectField(gettext('VLE to connect'), choices=get_vles(), validators=(validators.Optional(), )) vle_course_id = StringField(gettext('Course to connect')) submit = SubmitField(gettext('Save')) synchronize_vle = SubmitField(gettext('Synchronize with VLE'), default=None) delete = SubmitField(gettext('Delete'), default=None) def update_dynamic_choices(self): #self.parent.choices=get_top_courses() self.parent.choices = get_all_courses() self.vle_id.choices = get_vles()
class MethodAdd(FlaskForm): method_id = IntegerField('Method ID', widget=widgets.HiddenInput()) method_type = HiddenField('Method Type') method_select = HiddenField('Method Select') startDailyTime = StringField(lazy_gettext(u'Start HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) endDailyTime = StringField(lazy_gettext(u'End HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) startTime = StringField(lazy_gettext(u'Start YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) endTime = StringField(lazy_gettext(u'End YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) startSetpoint = DecimalField(lazy_gettext(u'Start Setpoint')) endSetpoint = DecimalField(lazy_gettext(u'End Setpoint (optional)')) DurationSec = IntegerField(lazy_gettext(u'Duration (seconds)')) amplitude = DecimalField(lazy_gettext(u'Amplitude')) frequency = DecimalField(lazy_gettext(u'Frequency')) shiftAngle = DecimalField(lazy_gettext(u'Angle Shift (0 to 360)')) shiftY = DecimalField(lazy_gettext(u'Y-Axis Shift')) x0 = DecimalField('X0') y0 = DecimalField('Y0') x1 = DecimalField('X1') y1 = DecimalField('Y1') x2 = DecimalField('X2') y2 = DecimalField('Y2') x3 = DecimalField('X3') y3 = DecimalField('Y3') relayDailyTime = StringField(lazy_gettext(u'Time HH:MM:SS'), render_kw={"placeholder": "HH:MM:SS"}) relayTime = StringField(lazy_gettext(u'Time YYYY-MM-DD HH:MM:SS'), render_kw={"placeholder": "YYYY-MM-DD HH:MM:SS"}) relayDurationSec = IntegerField(lazy_gettext(u'Duration On (sec)')) relayID = StringField(lazy_gettext(u'Relay ID'), ) relayState = SelectField(lazy_gettext(u'Relay State'), choices=[('', ''), ('On', 'Turn On'), ('Off', 'Turn Off')]) save = SubmitField(lazy_gettext(u'Add to Method'))
class SettingsCamera(FlaskForm): camera_id = StringField('Camera ID', widget=widgets.HiddenInput()) name = StringField(TRANSLATIONS['name']['title']) library = StringField(lazy_gettext('Library')) device = StringField(lazy_gettext('Device')) opencv_device = IntegerField(lazy_gettext('OpenCV Device'), widget=NumberInput()) hflip = BooleanField(lazy_gettext('Flip image horizontally')) vflip = BooleanField(lazy_gettext('Flip image vertically')) rotation = IntegerField(lazy_gettext('Rotate Image'), widget=NumberInput()) height = IntegerField(lazy_gettext('Image Height'), widget=NumberInput()) width = IntegerField(lazy_gettext('Image Width'), widget=NumberInput()) brightness = DecimalField(lazy_gettext('Brightness'), widget=NumberInput(step='any')) contrast = DecimalField(lazy_gettext('Contrast'), widget=NumberInput(step='any')) exposure = DecimalField(lazy_gettext('Exposure'), widget=NumberInput(step='any')) gain = DecimalField(lazy_gettext('Gain'), widget=NumberInput(step='any')) hue = DecimalField(lazy_gettext('Hue'), widget=NumberInput(step='any')) saturation = DecimalField(lazy_gettext('Saturation'), widget=NumberInput(step='any')) white_balance = DecimalField(lazy_gettext('White Balance'), widget=NumberInput(step='any')) custom_options = StringField(lazy_gettext('Custom Options')) output_id = StringField(TRANSLATIONS['output']['title']) output_duration = DecimalField('{} ({})'.format( TRANSLATIONS['duration']['title'], TRANSLATIONS['output']['title']), widget=NumberInput(step='any')) cmd_pre_camera = StringField(lazy_gettext('Pre Command')) cmd_post_camera = StringField(lazy_gettext('Post Command')) path_still = StringField(lazy_gettext('Still Image Path')) path_timelapse = StringField(lazy_gettext('Timelapse Path')) path_video = StringField(lazy_gettext('Video Path')) camera_add = SubmitField(TRANSLATIONS['add']['title']) camera_mod = SubmitField(TRANSLATIONS['save']['title']) camera_del = SubmitField(TRANSLATIONS['delete']['title'])
def UpdateAnimeForm(utoa): """Represents an Update Anime form with the given anime for validation requirements""" class M(Form): pass M.result = utoa M.malId = IntegerField('Anime ID', widget=widgets.HiddenInput(), default=utoa.malId, validators=[DataRequired()]) M.myScore = SelectField('My Score', choices=list(MAL_SCORE.items()), coerce=int, default=utoa.myScore, validators=[Optional()]) M.myStatus = SelectField('Watch status', choices=list(MAL_STATUS.items()), coerce=int, default=utoa.myStatus, validators=[Optional()]) M.myEpisodes = IntegerField( 'Episodes Watched', default=utoa.myEpisodes, validators=[Optional(), NumberRange(0, utoa.episodes)]) M.myStartDate = DateField('Date Started', default=utoa.myStartDate, format='%m/%d/%Y', validators=[Optional()]) M.myEndDate = DateField('Date Completed', default=utoa.myEndDate, format='%m/%d/%Y', validators=[Optional()]) M.myRewatchEps = IntegerField('Rewatched Episodes', default=utoa.myRewatchEps, validators=[Optional()]) return M
class UserMod(FlaskForm): user_id = IntegerField('User ID', widget=widgets.HiddenInput()) modEmail = EmailField(lazy_gettext(u'Email'), render_kw={"placeholder": lazy_gettext(u"Email")}, validators=[DataRequired(), validators.Email()]) modPassword = PasswordField( lazy_gettext(u'Password'), render_kw={"placeholder": lazy_gettext(u"New Password")}, validators=[ validators.Optional(), validators.EqualTo('modPassword_repeat', message=lazy_gettext(u'Passwords must match')), validators.Length( min=6, message=lazy_gettext(u'Password must be 6 or more characters')) ]) modPassword_repeat = PasswordField( lazy_gettext(u'Repeat Password'), render_kw={"placeholder": lazy_gettext(u"Repeat Password")}) modRole = StringField(lazy_gettext(u'Role'), validators=[DataRequired()]) modTheme = StringField(lazy_gettext(u'Theme')) save_user = SubmitField(lazy_gettext(u'Save')) delete_user = SubmitField(lazy_gettext(u'Delete'))
class GraphAdd(FlaskForm): graph_type = StringField('Type', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Name'), validators=[DataRequired()]) math_ids = SelectMultipleField(lazy_gettext(u'Maths')) pid_ids = SelectMultipleField(lazy_gettext(u'PIDs')) relay_ids = SelectMultipleField(lazy_gettext(u'Outputs')) sensor_ids = SelectMultipleField(lazy_gettext(u'Inputs')) width = IntegerField(lazy_gettext(u'Width'), validators=[validators.NumberRange(min=1, max=12)]) height = IntegerField( lazy_gettext(u'Height (pixels)'), validators=[validators.NumberRange(min=100, max=10000)]) xaxis_duration = DecimalField( lazy_gettext(u'X-Axis (minutes)'), validators=[ validators.NumberRange(min=0.1, message=lazy_gettext( u"Number of minutes to display of past " u"measurements.")) ]) refresh_duration = DecimalField( lazy_gettext(u'Period (seconds)'), validators=[ validators.NumberRange( min=0.2, message=lazy_gettext( u"Number of seconds to wait between acquiring" u" any new measurements.")) ]) enable_auto_refresh = BooleanField(lazy_gettext(u'Enable Auto Refresh')) enable_xaxis_reset = BooleanField(lazy_gettext(u'Enable X-Axis Reset')) enable_title = BooleanField(lazy_gettext(u'Enable Title')) enable_navbar = BooleanField(lazy_gettext(u'Enable Navbar')) enable_export = BooleanField(lazy_gettext(u'Enable Export')) enable_range = BooleanField(lazy_gettext(u'Enable Range Selector')) graph_add = SubmitField(lazy_gettext(u'Create'))
class UserMod(FlaskForm): user_id = StringField('User ID', widget=widgets.HiddenInput()) email = EmailField( TRANSLATIONS['email']['title'], render_kw={"placeholder": TRANSLATIONS['email']['title']}, validators=[ DataRequired(), validators.Email()]) password_new = PasswordField( TRANSLATIONS['password']['title'], render_kw={"placeholder": lazy_gettext("New Password")}, validators=[ validators.Optional(), validators.EqualTo( 'password_repeat', message=lazy_gettext('Passwords must match') ), validators.Length( min=6, message=lazy_gettext('Password must be 6 or more characters') ) ] ) password_repeat = PasswordField( lazy_gettext('Repeat Password'), render_kw={"placeholder": lazy_gettext("Repeat Password")}) api_key = StringField('API Key', render_kw={"placeholder": "API Key (Base64)"}) role_id = IntegerField( lazy_gettext('Role ID'), validators=[DataRequired()], widget=NumberInput() ) theme = StringField(lazy_gettext('Theme')) generate_api_key = SubmitField("Generate API Key") save = SubmitField(TRANSLATIONS['save']['title']) delete = SubmitField(TRANSLATIONS['delete']['title'])
class SettingsCamera(FlaskForm): camera_id = IntegerField('Camera ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext(u'Name')) camera_type = StringField(lazy_gettext(u'Type')) library = StringField(lazy_gettext(u'Library')) opencv_device = IntegerField(lazy_gettext(u'OpenCV Device')) hflip = BooleanField(lazy_gettext(u'Flip image horizontally')) vflip = BooleanField(lazy_gettext(u'Flip image vertically')) rotation = IntegerField(lazy_gettext(u'Rotate Image')) height = IntegerField(lazy_gettext(u'Image Height')) width = IntegerField(lazy_gettext(u'Image Width')) brightness = DecimalField(lazy_gettext(u'Brightness')) contrast = DecimalField(lazy_gettext(u'Contrast')) exposure = DecimalField(lazy_gettext(u'Exposure')) gain = DecimalField(lazy_gettext(u'Gain')) hue = DecimalField(lazy_gettext(u'Hue')) saturation = DecimalField(lazy_gettext(u'Saturation')) white_balance = DecimalField(lazy_gettext(u'White Balance')) relay_id = IntegerField(lazy_gettext(u'Relay ID')) cmd_pre_camera = StringField(lazy_gettext(u'Pre Command')) cmd_post_camera = StringField(lazy_gettext(u'Post Command')) camera_add = SubmitField(lazy_gettext(u'Add Camera')) camera_mod = SubmitField(lazy_gettext(u'Save')) camera_del = SubmitField(lazy_gettext(u'Delete'))
class Show(db.Model): __tablename__ = 'shows' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String, nullable=False, info={ 'widget': widgets.HiddenInput()}) rating = db.Column(db.Float, info={'widget': widgets.HiddenInput()}) summary = db.Column(db.String, info={'widget': widgets.HiddenInput()}) url = db.Column(db.String, nullable=False, info={ 'widget': widgets.HiddenInput()}) img_url = db.Column(db.String, info={ 'widget': widgets.HiddenInput()}) api_id = db.Column(db.Integer, nullable=False, unique=True, info={'widget': widgets.HiddenInput()}) episodes = db.relationship('Episode', backref='shows') seasons = db.relationship('Season', backref='shows') watch_status = db.relationship('Watched_show', backref='shows') def __repr__(self): s = self return f'<Show={s.name}>'
class InputMod(FlaskForm): input_id = StringField('Input ID', widget=widgets.HiddenInput()) input_measurement_id = StringField(widget=widgets.HiddenInput()) name = StringField( TRANSLATIONS['name']['title'], validators=[DataRequired()] ) period = DecimalField( TRANSLATIONS['period']['title'], validators=[DataRequired(), validators.NumberRange( min=5, max=86400 )], widget=NumberInput(step='any') ) start_offset = DecimalField( TRANSLATIONS['start_offset']['title'], validators=[DataRequired(), validators.NumberRange( min=0, max=86400 )], widget=NumberInput(step='any') ) log_level_debug = BooleanField(TRANSLATIONS['log_level_debug']['title']) num_channels = IntegerField(lazy_gettext('Number of Measurements'), widget=NumberInput()) location = StringField(lazy_gettext('Location')) ftdi_location = StringField(TRANSLATIONS['ftdi_location']['title']) uart_location = StringField(TRANSLATIONS['uart_location']['title']) gpio_location = IntegerField(TRANSLATIONS['gpio_location']['title']) i2c_location = StringField(TRANSLATIONS['i2c_location']['title']) i2c_bus = IntegerField(TRANSLATIONS['i2c_bus']['title'], widget=NumberInput()) baud_rate = IntegerField(TRANSLATIONS['baud_rate']['title'], widget=NumberInput()) power_output_id = StringField(lazy_gettext('Power Output')) # For powering input calibrate_sensor_measure = StringField(lazy_gettext('Calibration Measurement')) resolution = IntegerField(TRANSLATIONS['resolution']['title'], widget=NumberInput()) resolution_2 = IntegerField(TRANSLATIONS['resolution']['title'], widget=NumberInput()) sensitivity = IntegerField( TRANSLATIONS['sensitivity']['title'], widget=NumberInput()) measurements_enabled = SelectMultipleField(TRANSLATIONS['measurements_enabled']['title']) # Server options host = StringField(TRANSLATIONS['host']['title']) port = IntegerField( TRANSLATIONS['port']['title'], widget=NumberInput()) times_check = IntegerField( TRANSLATIONS['times_check']['title'], widget=NumberInput()) deadline = IntegerField( TRANSLATIONS['deadline']['title'], widget=NumberInput()) # Linux Command cmd_command = StringField(TRANSLATIONS['cmd_command']['title']) # MAX chip options thermocouple_type = StringField(TRANSLATIONS['thermocouple_type']['title']) ref_ohm = IntegerField( TRANSLATIONS['ref_ohm']['title'], widget=NumberInput()) # SPI Communication pin_clock = IntegerField( TRANSLATIONS['pin_clock']['title'], widget=NumberInput()) pin_cs = IntegerField( TRANSLATIONS['pin_cs']['title'], widget=NumberInput()) pin_mosi = IntegerField( TRANSLATIONS['pin_mosi']['title'], widget=NumberInput()) pin_miso = IntegerField( TRANSLATIONS['pin_miso']['title'], widget=NumberInput()) # Bluetooth Communication bt_adapter = StringField(TRANSLATIONS['bt_adapter']['title']) # ADC adc_gain = IntegerField( TRANSLATIONS['adc_gain']['title'], widget=NumberInput()) adc_resolution = IntegerField( TRANSLATIONS['adc_resolution']['title'], widget=NumberInput()) adc_sample_speed = StringField(TRANSLATIONS['adc_sample_speed']['title']) switch_edge = StringField(lazy_gettext('Edge')) switch_bouncetime = IntegerField( lazy_gettext('Bounce Time (ms)'), widget=NumberInput()) switch_reset_period = IntegerField( lazy_gettext('Reset Period'), widget=NumberInput()) # Pre-Output pre_output_id = StringField(TRANSLATIONS['pre_output_id']['title']) pre_output_duration = DecimalField( TRANSLATIONS['pre_output_duration']['title'], validators=[validators.NumberRange( min=0, max=86400 )], widget=NumberInput(step='any') ) pre_output_during_measure = BooleanField( TRANSLATIONS['pre_output_during_measure']['title']) # RPM/Signal weighting = DecimalField( TRANSLATIONS['weighting']['title'], widget=NumberInput(step='any')) rpm_pulses_per_rev = DecimalField( TRANSLATIONS['rpm_pulses_per_rev']['title'], widget=NumberInput(step='any')) sample_time = DecimalField( TRANSLATIONS['sample_time']['title'], widget=NumberInput(step='any')) # SHT options sht_voltage = StringField(TRANSLATIONS['sht_voltage']['title']) input_mod = SubmitField(TRANSLATIONS['save']['title']) input_delete = SubmitField(TRANSLATIONS['delete']['title']) input_acquire_measurements = SubmitField(lazy_gettext('Acquire Measurements Now')) input_activate = SubmitField(TRANSLATIONS['activate']['title']) input_deactivate = SubmitField(TRANSLATIONS['deactivate']['title']) input_order_up = SubmitField(TRANSLATIONS['up']['title']) input_order_down = SubmitField(TRANSLATIONS['down']['title'])
class DataBase(FlaskForm): reorder_type = StringField('Reorder Type', widget=widgets.HiddenInput()) list_visible_elements = SelectMultipleField('New Order') reorder = SubmitField(TRANSLATIONS['save_order']['title'])
class OutputMod(FlaskForm): output_id = StringField('Output ID', widget=widgets.HiddenInput()) output_pin = HiddenField('Output Pin') name = StringField( TRANSLATIONS['name']['title'], validators=[DataRequired()]) location = StringField(lazy_gettext('Location')) i2c_bus = IntegerField(TRANSLATIONS['i2c_bus']['title']) baud_rate = IntegerField(TRANSLATIONS['baud_rate']['title']) gpio_location = IntegerField(TRANSLATIONS['gpio_location']['title'], widget=NumberInput()) protocol = IntegerField(TRANSLATIONS['protocol']['title'], widget=NumberInput()) pulse_length = IntegerField(TRANSLATIONS['pulse_length']['title'], widget=NumberInput()) on_command = StringField(TRANSLATIONS['on_command']['title']) off_command = StringField(TRANSLATIONS['off_command']['title']) pwm_command = StringField(TRANSLATIONS['pwm_command']['title']) pwm_invert_signal = BooleanField(lazy_gettext('Invert Signal')) amps = DecimalField( TRANSLATIONS['amps']['title'], validators=[validators.NumberRange( min=0, max=50, message=lazy_gettext("The current draw of the device connected " "to this output, in amps.") )], widget=NumberInput(step='any') ) on_state = SelectField( TRANSLATIONS['on_state']['title'], choices=[ ("1", lazy_gettext('High')), ("0", lazy_gettext('Low')) ], validators=[Optional()] ) state_at_startup = SelectField( TRANSLATIONS['state_at_startup']['title'], choices=[ ("-1", lazy_gettext('Neither')), ("1", TRANSLATIONS['on']['title']), ("0", TRANSLATIONS['off']['title']) ], validators=[DataRequired()] ) state_at_shutdown = SelectField( TRANSLATIONS['state_at_shutdown']['title'], choices=[ ("-1", lazy_gettext('Neither')), ("1", TRANSLATIONS['on']['title']), ("0", TRANSLATIONS['off']['title']) ], validators=[DataRequired()] ) trigger_functions_at_start = BooleanField( TRANSLATIONS['trigger_functions_at_start']['title']) pwm_hertz = IntegerField( TRANSLATIONS['pwm_hertz']['title'], widget=NumberInput()) pwm_library = SelectField( TRANSLATIONS['pwm_library']['title'], choices=[ ("pigpio_any", lazy_gettext('Any Pin, <= 40 kHz')), ("pigpio_hardware", lazy_gettext('Hardware Pin, <= 30 MHz')) ], validators=[DataRequired()] ) flow_rate = DecimalField( TRANSLATIONS['flow_rate']['title'], widget=NumberInput(step='any')) save = SubmitField(TRANSLATIONS['save']['title']) delete = SubmitField(TRANSLATIONS['delete']['title']) order_up = SubmitField(TRANSLATIONS['up']['title']) order_down = SubmitField(TRANSLATIONS['down']['title']) on_submit = SubmitField(lazy_gettext('Turn On'))
class MeasurementMod(FlaskForm): measurement_id = StringField('Measurement ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext('Measurement Name')) units = SelectMultipleField(lazy_gettext('Measurement Units')) save_measurement = SubmitField(TRANSLATIONS['save']['title']) delete_measurement = SubmitField(TRANSLATIONS['delete']['title'])
class CollectionDelete(Form): item_id = fields.IntegerField( 'Collection ID', widget=widgets.HiddenInput(), validators=[validators.required(), validators.NumberRange(min=0)])
class InputMod(FlaskForm): input_id = StringField('Input ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext('Name'), validators=[DataRequired()]) period = DecimalField(lazy_gettext('Period (seconds)'), validators=[ DataRequired(), validators.NumberRange(min=5.0, max=86400.0) ]) location = StringField( lazy_gettext('Location')) # Access input (GPIO, I2C address, etc.) device_loc = StringField( lazy_gettext('Device Location')) # Second device location type i2c_bus = IntegerField(lazy_gettext('I<sup>2</sup>C Bus')) baud_rate = IntegerField(lazy_gettext('Baud Rate')) power_output_id = StringField( lazy_gettext('Power Output')) # For powering input calibrate_sensor_measure = StringField( lazy_gettext('Calibration Measurement')) resolution = IntegerField(lazy_gettext('Resolution')) sensitivity = IntegerField(lazy_gettext('Sensitivity')) convert_to_unit = StringField(lazy_gettext('Unit')) # Server options host = StringField(lazy_gettext('Host')) port = IntegerField(lazy_gettext('Port')) times_check = IntegerField(lazy_gettext('Times to Check')) deadline = IntegerField(lazy_gettext('Deadline (seconds)')) # Linux Command cmd_command = StringField(lazy_gettext('Command')) cmd_measurement = StringField(lazy_gettext('Measurement')) cmd_measurement_units = StringField(lazy_gettext('Unit')) # MAX chip options thermocouple_type = StringField(lazy_gettext('RTD Probe Type')) ref_ohm = IntegerField(lazy_gettext('Reference Resistance (Ohm)')) # SPI Communication pin_clock = IntegerField(lazy_gettext('Clock Pin')) pin_cs = IntegerField(lazy_gettext('CS Pin')) pin_mosi = IntegerField(lazy_gettext('MOSI Pin')) pin_miso = IntegerField(lazy_gettext('MISO Pin')) # ADC adc_channel = IntegerField(lazy_gettext('Channel')) adc_gain = IntegerField(lazy_gettext('Gain')) adc_resolution = IntegerField(lazy_gettext('Resolution')) adc_measurement = StringField(lazy_gettext('Measurement')) adc_measurement_units = StringField(lazy_gettext('Measurement Units')) adc_volts_min = DecimalField(lazy_gettext('Volts Min')) adc_volts_max = DecimalField(lazy_gettext('Volts Max')) adc_units_min = DecimalField(lazy_gettext('Units Min')) adc_units_max = DecimalField(lazy_gettext('Units Max')) adc_inverse_unit_scale = BooleanField(lazy_gettext('Inverse Unit Scale')) switch_edge = StringField(lazy_gettext('Edge')) switch_bounce_time = IntegerField(lazy_gettext('Bounce Time (ms)')) switch_reset_period = IntegerField(lazy_gettext('Reset Period')) # Pre-Output pre_output_id = StringField(lazy_gettext('Pre Output')) pre_output_duration = DecimalField( lazy_gettext('Pre Out Duration'), validators=[validators.NumberRange(min=0, max=86400)]) pre_output_during_measure = BooleanField( lazy_gettext('Pre During Measure')) # RPM/Signal weighting = DecimalField(lazy_gettext('Weighting')) rpm_pulses_per_rev = DecimalField(lazy_gettext('Pulses Per Rev')) sample_time = DecimalField(lazy_gettext('Sample Time (seconds)')) # SHT options sht_voltage = StringField(lazy_gettext('Voltage')) input_mod = SubmitField(lazy_gettext('Save')) input_delete = SubmitField(lazy_gettext('Delete')) input_activate = SubmitField(lazy_gettext('Activate')) input_deactivate = SubmitField(lazy_gettext('Deactivate')) input_order_up = SubmitField(lazy_gettext('Up')) input_order_down = SubmitField(lazy_gettext('Down'))
class CalibrationAtlasFlow(FlaskForm): hidden_input_id = StringField('Input ID', widget=widgets.HiddenInput()) selected_input_id = StringField(lazy_gettext('Atlas RGB Sensor')) clear_calibration = SubmitField(lazy_gettext('Clear Calibration'))
class UnitMod(FlaskForm): unit_id = StringField('Unit ID', widget=widgets.HiddenInput()) name = StringField(lazy_gettext('Unit Name')) unit = StringField(lazy_gettext('Unit Abbreviation')) save_unit = SubmitField(TRANSLATIONS['save']['title']) delete_unit = SubmitField(TRANSLATIONS['delete']['title'])