class Cliente(FlaskForm): lista_genero = [('', 'seleccionar genero'), ('M', 'MASCULINO'), ('F', 'FEMENINO')] genero = SelectField('Genero', choices=lista_genero, validators=[DataRequired()]) edad = IntegerField('Edad', widget=NumberInput(min=23, max=93)) lista_estado_civil = [('', 'seleccionar estado civil'), ('C', 'CASADO'), ('D', 'DIVORCIADO'), ('S', 'SOLTERO'), ('U', 'UNION LIBRE'), ('V', 'VIUDO')] estado_civil = SelectField('Estado civil', choices=lista_estado_civil, validators=[DataRequired()]) lista_nivel_estudios = [('', 'seleccionar nivel'), ('G', 'POSTGRADO'), ('N', 'SIN ESTUDIOS'), ('P', 'PRIMARIA'), ('S', 'SECUNDARIA'), ('U', 'UNIVERSITARIA')] nivel_estudios = SelectField('Nivel estudios', choices=lista_nivel_estudios, validators=[DataRequired()]) ingresos = IntegerField('Ingresos', widget=NumberInput(min=0, max=40000)) gastos = IntegerField('Gastos', widget=NumberInput(min=0, max=7410.45)) provincia = StringField('Provincia', validators=[DataRequired()]) ciudad = StringField('Ciudad', validators=[DataRequired()]) lista_tipo_residencia = [('', 'seleccionar nivel'), ('A', 'ARRENDADA'), ('F', 'VIVE CON FAMILIARES'), ('N', 'PROPIA NO HIPOTECADA'), ('P', 'PROPIA HIPOTECADA'), ('S', 'PRESTADA')] tipo_residencia = SelectField('Tipo residencia', choices=lista_tipo_residencia, validators=[DataRequired()])
def _prepare_form(self): self.input_fields = [] for i, item in enumerate(self.order.vendorparts): field_name = self._field_name(item) field = IntegerField(field_name, widget=NumberInput(min=0), validators=[NumberRange(min=0)], default=item.number_ordered, render_kw={'readonly': self.order.archived, 'disabled': self.order.archived, 'class': 'text-right order_count'} ) setattr(self.F, field_name, field) self.input_fields.append((field_name, item.id)) self.f = self.F()
class TextPageForm(FlaskForm): duration = IntegerField("Duration", default=10, validators=[NumberRange(1, 60)], widget=NumberInput(min=1, max=60), render_kw={'class': 'text-page-duration rounded mb-3'}) text = StringField("Text", widget=TextArea(), render_kw={'class': 'text-page-content fullwidth page-contents rounded', 'rows': NUM_LINES}) align = SelectField("Align", choices=ALIGN_CHOICES, render_kw={'class': 'text-page-align rounded mb-3'}) font = SelectField("Font", choices=FONT_CHOICES, render_kw={'class': 'text-page-font rounded mb-3'}) inverted = BooleanField("Inverted", render_kw={'class': 'text-page-inverted rounded mb-3'})
class SettingsGeneral(FlaskForm): landing_page = StringField(lazy_gettext('Landing Page')) language = StringField(lazy_gettext('Language')) rpyc_timeout = StringField(lazy_gettext('Pyro Timeout')) daemon_debug_mode = BooleanField( lazy_gettext('Enable Daemon Debug Logging')) force_https = BooleanField(lazy_gettext('Force HTTPS')) hide_success = BooleanField(lazy_gettext('Hide success messages')) hide_info = BooleanField(lazy_gettext('Hide info messages')) hide_warning = BooleanField(lazy_gettext('Hide warning messages')) hide_tooltips = BooleanField(lazy_gettext('Hide Form Tooltips')) max_amps = DecimalField(lazy_gettext('Max Amps'), widget=NumberInput(step='any')) output_stats_volts = IntegerField(lazy_gettext('Voltage'), widget=NumberInput()) output_stats_cost = DecimalField(lazy_gettext('Cost per kWh'), widget=NumberInput(step='any')) output_stats_currency = StringField(lazy_gettext('Currency Unit')) output_stats_day_month = StringField(lazy_gettext('Day of Month')) output_usage_report_gen = BooleanField( lazy_gettext('Generate Usage/Cost Report')) output_usage_report_span = StringField( lazy_gettext('Time Span to Generate')) output_usage_report_day = IntegerField( lazy_gettext('Day of Week/Month to Generate'), widget=NumberInput()) output_usage_report_hour = IntegerField( lazy_gettext('Hour of Day to Generate'), validators=[ validators.NumberRange(min=0, max=23, message=lazy_gettext("Hour Options: 0-23")) ], widget=NumberInput()) stats_opt_out = BooleanField(lazy_gettext('Opt-out of statistics')) enable_upgrade_check = BooleanField(lazy_gettext('Check for Updates')) Submit = SubmitField(TRANSLATIONS['save']['title'])
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')) log_level_debug = BooleanField(TRANSLATIONS['log_level_debug']['title']) 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 InputMeasurementMod(FlaskForm): input_id = StringField('Input ID', widget=widgets.HiddenInput()) input_measurement_id = StringField(widget=widgets.HiddenInput()) input_type = StringField(widget=widgets.HiddenInput()) name = StringField(TRANSLATIONS['name']['title']) select_measurement_unit = StringField( TRANSLATIONS['select_measurement_unit']['title']) scale_from_min = DecimalField(TRANSLATIONS['scale_from_min']['title'], widget=NumberInput(step='any')) scale_from_max = DecimalField(TRANSLATIONS['scale_from_max']['title'], widget=NumberInput(step='any')) scale_to_min = DecimalField(TRANSLATIONS['scale_to_min']['title'], widget=NumberInput(step='any')) scale_to_max = DecimalField(TRANSLATIONS['scale_to_max']['title'], widget=NumberInput(step='any')) invert_scale = BooleanField(TRANSLATIONS['invert_scale']['title']) rescaled_measurement_unit = StringField( lazy_gettext('Rescaled Measurement')) convert_to_measurement_unit = StringField( TRANSLATIONS['convert_to_measurement_unit']['title']) input_measurement_mod = SubmitField(TRANSLATIONS['save']['title'])
class CustomController(FlaskForm): function_id = StringField('Function ID', widget=widgets.HiddenInput()) function_type = StringField('Function Type', widget=widgets.HiddenInput()) name = StringField(TRANSLATIONS['name']['title']) num_channels = IntegerField(lazy_gettext('Number of Measurements'), widget=NumberInput()) measurements_enabled = SelectMultipleField( TRANSLATIONS['measurements_enabled']['title']) log_level_debug = BooleanField(TRANSLATIONS['log_level_debug']['title']) activate_controller = SubmitField(TRANSLATIONS['activate']['title']) deactivate_controller = SubmitField(TRANSLATIONS['deactivate']['title']) delete_controller = SubmitField(TRANSLATIONS['delete']['title']) save_controller = SubmitField(TRANSLATIONS['save']['title']) order_up = SubmitField(TRANSLATIONS['up']['title']) order_down = SubmitField(TRANSLATIONS['down']['title'])
class SearchForm(Form): form_control = dict_base({ 'class': 'form-control', 'aria-describedby': 'basic-addon2', }) search_kw = form_control({ 'type': 'text', 'placeholder': 'Search', 'aria-label': 'Search', }) mode_kw = form_control({ 'placeholder': 'Mode', 'aria-label': 'Mode', 'form': 'searchForm', }) limit_kw = form_control({ 'placeholder': 'Limit', 'aria-label': 'Limit', 'form': 'searchForm', }) corpus = SelectField('corpus', choices=[], render_kw=mode_kw) search = StringField('search', validators=[validators.Optional()], widget=TextInput(), render_kw=search_kw) mode = StringField('mode', widget=HiddenInput(), render_kw=mode_kw) limit = IntegerField('limit', widget=NumberInput(), render_kw=limit_kw, default=get_default_args(search_)['limit']) page = IntegerField('page', widget=HiddenInput(), default=get_default_args(paginate_)['page']) def __init__(self, *args, **kwargs): super(SearchForm, self).__init__(*args, **kwargs) self.corpus.choices = [ (str(corpus.id), corpus.name) for corpus in get_corpora() ] + [('--all--', '--All--')] def values(self): return { 'query': self.search.data, 'limit': self.limit.data, 'page': self.page.data, 'corpus': self.corpus.data, }
def _prepare_form(self, items): self.inputs = [] for i, item in enumerate(items): field_names = self._field_names(item) self.inputs.append((item.id, field_names['selector'], field_names['count'])) selector = BooleanField(field_names['selector'], default=False) setattr(self.F, field_names['selector'], selector) count = IntegerField(field_names['count'], widget=NumberInput(min=1), validators=[NumberRange(min=0)], default=1) setattr(self.F, field_names['count'], count)
class LogView(FlaskForm): lines = IntegerField( lazy_gettext('Number of Lines'), validators=[validators.NumberRange( min=1, message=lazy_gettext('Number of lines should be greater than 0') )], widget=NumberInput() ) loglogin = SubmitField(lazy_gettext('Login Log')) loghttp = SubmitField(lazy_gettext('HTTP Log')) logdaemon = SubmitField(lazy_gettext('Daemon Log')) logbackup = SubmitField(lazy_gettext('Backup Log')) logkeepup = SubmitField(lazy_gettext('KeepUp Log')) logupgrade = SubmitField(lazy_gettext('Upgrade Log')) logrestore = SubmitField(lazy_gettext('Restore Log'))
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')) trigger = SelectField(TRANSLATIONS['trigger']['title'], choices=[("1", lazy_gettext('High')), ("0", lazy_gettext('Low'))], validators=[Optional()]) on_at_start = SelectField(TRANSLATIONS['on_at_start']['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['trigger_functions_at_start']['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 HousesForm(Form): timestamp = DateField('Timestamp', default=datetime.today, format='%Y-%m-%d') full_sq = IntegerField('Full area', widget=NumberInput(), default=50) life_sq = IntegerField('Life area', widget=NumberInput(), default=50) num_room = IntegerField('Number of rooms', widget=NumberInput(), default=1) floor = IntegerField('Floor', widget=NumberInput(), default=1) max_floor = IntegerField('Max Floor', widget=NumberInput(), default=1) build_year = IntegerField('Build year', widget=NumberInput(), default=1950) sub_area = SelectField('Sub area')
class OutputMod(FlaskForm): output_id = StringField('Output ID', widget=widgets.HiddenInput()) output_pin = HiddenField('Output Pin') name = StringField(TRANSLATIONS['name']['title'], validators=[DataRequired()]) log_level_debug = BooleanField(TRANSLATIONS['log_level_debug']['title']) location = StringField(lazy_gettext('Location')) ftdi_location = StringField(TRANSLATIONS['ftdi_location']['title']) uart_location = StringField(TRANSLATIONS['uart_location']['title']) baud_rate = IntegerField(TRANSLATIONS['baud_rate']['title']) gpio_location = IntegerField(TRANSLATIONS['gpio_location']['title'], widget=NumberInput()) i2c_location = StringField(TRANSLATIONS['i2c_location']['title']) i2c_bus = IntegerField(TRANSLATIONS['i2c_bus']['title']) output_mod = SubmitField(TRANSLATIONS['save']['title']) output_delete = SubmitField(TRANSLATIONS['delete']['title']) on_submit = SubmitField(lazy_gettext('Turn On'))
class TimetablePDFExportForm(IndicoForm): _pdf_options_fields = {'pagesize', 'firstPageNumber'} advanced = BooleanField(_("Advanced timetable"), widget=SwitchWidget(), description=_("Advanced customization options")) document_settings = IndicoSelectMultipleCheckboxBooleanField( _('Document settings'), [HiddenUnless('advanced')], choices=_DOCUMENT_SETTINGS_CHOICES) contribution_info = IndicoSelectMultipleCheckboxBooleanField( _('Contributions related info'), [HiddenUnless('advanced')], choices=_CONTRIBUTION_CHOICES) session_info = IndicoSelectMultipleCheckboxBooleanField( _('Sessions related info'), [HiddenUnless('advanced')], choices=_SESSION_CHOICES) visible_entries = IndicoSelectMultipleCheckboxBooleanField( _('Breaks and contributions'), [HiddenUnless('advanced')], choices=_VISIBLE_ENTRIES_CHOICES) other = IndicoSelectMultipleCheckboxBooleanField(_('Miscellaneous'), choices=_OTHER_CHOICES) pagesize = SelectField(_('Page size'), choices=[('A0', 'A0'), ('A1', 'A1'), ('A2', 'A2'), ('A3', 'A3'), ('A4', 'A4'), ('A5', 'A5'), ('Letter', 'Letter')], default='A4') firstPageNumber = IntegerField(_('Number for the first page'), [NumberRange(min=1)], default=1, widget=NumberInput(step=1)) submitted = HiddenField() def is_submitted(self): return 'submitted' in request.args @property def data_for_format(self): if not self.advanced.data: fields = ('visible_entries', ) else: fields = set( get_form_field_names(TimetablePDFExportForm) ) - self._pdf_options_fields - {'csrf_token', 'advanced'} data = {} for fieldname in fields: data.update(getattr(self, fieldname).data) return data
class GameForm(FlaskForm): '''A form for adding a new game or editing an existing one.''' id = HiddenField() name = StringField('Pelin nimi', widget=TextInput(), validators=[DataRequired(message="Nimi on pakollinen")]) start_date = StringField( 'Pelin alkupäivämäärä', widget=TextInput(), validators=[ Regexp('^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(20)\d\d$', message='Anna kelvollinen päivämäärä') ]) end_date = StringField( 'Pelin loppupäivämäärä', widget=TextInput(), validators=[ Regexp('^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(20)\d\d$', message='Anna kelvollinen päivämäärä'), check_end_later_than_start ]) location = StringField('Pelin sijainti', widget=TextInput()) price = IntegerField('Pelin hinta', widget=NumberInput(), validators=[ NumberRange(min=0, max=9999, message='Hinnan on oltava 0-9999') ]) description = TextAreaField( 'Pelin kuvaus', widget=TextArea(), validators=[ DataRequired(message="Kuvaus on pakollinen"), Length(min=10, max=1000, message="Kuvauksen on oltava 10-1000 merkkiä pitkä") ]) create_form = SubmitField('Luo ilmoittautumislomake', widget=SubmitInput()) edit_form = SubmitField('Muokkaa ilmoittautumislomaketta', widget=SubmitInput()) publish_form = SubmitField('Avaa ilmoittautuminen', widget=SubmitInput()) unpublish_form = SubmitField('Sulje ilmoittautuminen', widget=SubmitInput()) submit = SubmitField('Tallenna pelin tiedot', widget=SubmitInput())
class LCDModDisplay(FlaskForm): lcd_id = StringField('LCD ID', widget=widgets.HiddenInput()) lcd_data_id = StringField('LCD Data ID', widget=widgets.HiddenInput()) line_1_display = StringField(lazy_gettext('Line 1')) line_1_max_age = IntegerField( lazy_gettext('Max Age (seconds)'), validators=[validators.NumberRange(min=1, max=999999999)], widget=NumberInput()) line_1_decimal_places = IntegerField( lazy_gettext('Decimal Places'), validators=[validators.NumberRange(min=0)], widget=NumberInput()) line_2_display = StringField(lazy_gettext('Line 2')) line_2_max_age = IntegerField( lazy_gettext('Max Age (seconds)'), validators=[validators.NumberRange(min=1, max=999999999)], widget=NumberInput()) line_2_decimal_places = IntegerField( lazy_gettext('Decimal Places'), validators=[validators.NumberRange(min=0)], widget=NumberInput()) line_3_display = StringField(lazy_gettext('Line 3')) line_3_max_age = IntegerField( lazy_gettext('Max Age (seconds)'), validators=[validators.NumberRange(min=1, max=999999999)], widget=NumberInput()) line_3_decimal_places = IntegerField( lazy_gettext('Decimal Places'), validators=[validators.NumberRange(min=0)], widget=NumberInput()) line_4_display = StringField(lazy_gettext('Line 4')) line_4_max_age = IntegerField( lazy_gettext('Max Age (seconds)'), validators=[validators.NumberRange(min=1, max=999999999)], widget=NumberInput()) line_4_decimal_places = IntegerField( lazy_gettext('Decimal Places'), validators=[validators.NumberRange(min=0)], widget=NumberInput()) save_display = SubmitField(lazy_gettext('Save')) delete_display = SubmitField(lazy_gettext('Delete'))
class FeatureRequestForm(FlaskForm): id = IntegerField(validators=[Optional()], widget=HiddenInput()) title = StringField('Title', validators=[DataRequired(), Length(max=60)]) user = QuerySelectField( 'User', validators=[DataRequired()], query_factory=user_choices, get_label='full_name' ) client = QuerySelectField( 'Client', validators=[DataRequired()], query_factory=client_choices, get_label='name' ) priority = IntegerField( 'Priority', default=1, validators=[Optional()], widget=NumberInput(step=1, min=1) ) target_date = DateTimeField( 'Target Date', validators=[DataRequired()], description='Please enter the target date using a 24-hour time.', render_kw={'placeholder': '2030-08-20 19:56:20'} ) description = TextAreaField( 'Description', validators=[Optional()], render_kw={'rows': 10} ) product_areas = QuerySelectMultipleField( 'Product Areas', query_factory=product_areas_choices, get_label='name', description='Hold down control (command on mac) to select or ' 'deselect multiple options.' ) # TODO: Make description required (update tests, model, form). IMPORTANT recaptcha = RecaptchaField()
class CreateRequestForm(FlaskForm): title = StringField('Title', validators=[DataRequired(), Length(min=8, max=50)]) description = TextAreaField('Description', validators=[DataRequired()]) client = NoValidationSelectField('Client', choices=[]) product = NoValidationSelectField('Product', choices=[]) product_area = NoValidationSelectField('Product Area', choices=[]) created_at = DateField('Created At', validators=[DataRequired()], default=date.today()) target_date = DateField('Target Date', validators=[DataRequired()]) priority = IntegerField('Priority', widget=NumberInput(min=1), validators=[DataRequired()]) submit = SubmitField('Create')
class AccountSettingsForm(BaseForm): domain_whitelist = StringField( "Account Email Whitelist", description= "Comma-seperated email domains which users can register under (e.g. ctfd.io, gmail.com, yahoo.com)", ) team_creation = SelectField( "Team Creation", description= "Control whether users can create their own teams (Teams mode only)", choices=[("true", "Enabled"), ("false", "Disabled")], default="true", ) team_size = IntegerField( widget=NumberInput(min=0), description="Amount of users per team (Teams mode only)", ) verify_emails = SelectField( "Verify Emails", description= "Control whether users must confirm their email addresses before playing", choices=[("true", "Enabled"), ("false", "Disabled")], default="false", ) team_disbanding = SelectField( "Team Disbanding", description= "Control whether team capatins are allowed to disband their own teams", choices=[ ("inactive_only", "Enabled for Inactive Teams"), ("disabled", "Disabled"), ], default="inactive_only", ) name_changes = SelectField( "Name Changes", description="Control whether users and teams can change their names", choices=[("true", "Enabled"), ("false", "Disabled")], default="true", ) submit = SubmitField("Update")
class StatForm(Form): player_id = SelectField('Player_id', default=0) event_id = SelectField('event_id', default=0) min = TimeField('min', format='%M:%S') fg = IntegerField('2P', [validators.NumberRange(min=0, max=200)], widget=NumberInput(step=1), default=0) fg_a = IntegerField('2PA', default=0) ft = IntegerField('1P', default=0) ft_a = IntegerField('1PA', default=0) three = IntegerField('3P', default=0) three_a = IntegerField('3PA', default=0) dreb = IntegerField('PL', default=0) oreb = IntegerField('HL', default=0) foul = IntegerField('V', default=0) ass = IntegerField('S', default=0) tover = IntegerField('M', default=0) steal = IntegerField('R', default=0) block = IntegerField('T', default=0) submit = SubmitField('LÄHETÄ') cancel = SubmitField('PERUUTA') csrf_token = HiddenField('csrf_token')
class DashboardBase(FlaskForm): dashboard_id = StringField('Dashboard ID', widget=widgets.HiddenInput()) widget_id = StringField('Widget ID', widget=widgets.HiddenInput()) widget_type = SelectField('Dashboard Widget Type', choices=DASHBOARD_WIDGETS, validators=[DataRequired()]) name = StringField(TRANSLATIONS['name']['title'], validators=[DataRequired()]) font_em_name = DecimalField(TRANSLATIONS['font_em_name']['title']) refresh_duration = IntegerField( TRANSLATIONS['refresh_duration']['title'], validators=[ validators.NumberRange( min=1, message=TRANSLATIONS['refresh_duration']['title']) ], widget=NumberInput()) enable_drag_handle = BooleanField(lazy_gettext('Enable Drag Handle')) create = SubmitField(TRANSLATIONS['create']['title']) modify = SubmitField(TRANSLATIONS['save']['title']) delete = SubmitField(TRANSLATIONS['delete']['title'])
class LogView(FlaskForm): lines = IntegerField( 'Number of Lines', render_kw={'placeholder': lazy_gettext('Lines')}, validators=[ validators.NumberRange( min=1, message=lazy_gettext( 'Number of lines should be greater than 0')) ], widget=NumberInput()) loglogin = SubmitField(lazy_gettext(TRANSLATIONS['login']['title'])) loghttp_access = SubmitField(lazy_gettext('Web Access')) loghttp_error = SubmitField(lazy_gettext('Web Error')) logdaemon = SubmitField(lazy_gettext('Daemon')) logdependency = SubmitField(lazy_gettext('Dependency')) logbackup = SubmitField(lazy_gettext('Backup')) logkeepup = SubmitField(lazy_gettext('KeepUp')) logupgrade = SubmitField(lazy_gettext('Upgrade')) logrestore = SubmitField(lazy_gettext('Restore'))
class InductionForm(FlaskForm): invoice_num = IntegerField('Invoice Number', validators=[DataRequired()], widget=NumberInput()) correct_to_invoice = RadioField('Correct to Invoice?', choices=[('y', 'Yes'), ('n', 'No')], validators=[Optional()]) replacement_available = RadioField('Do we have a replacement available?', choices=[('y', 'Yes'), ('n', 'No')], validators=[Optional()]) induction_employee_code = StringField( 'Induction Employee Code', description='Employee Code', validators=[DataRequired(), is_valid_employee]) replacement_comments = StringField('Replacement Comments') light_noted = RadioField('Noted Correctly?', choices=[('y', 'Yes'), ('n', 'No')], validators=[Optional()]) light_type = RadioField('Light Type', choices=[('HID', 'HID'), ('LED', 'LED'), ('Halogen', 'Halogen')], validators=[Optional()]) light_type_comments = StringField('Replacement Comments') side = RadioField('Side', choices=[('LH', 'LH'), ('RH', 'RH')], validators=[Optional()]) def validate(self): validated = False if FlaskForm.validate(self): validated = True if self.light_type.data == 'HID' or self.light_type.data == 'LED': print("HID") if self.light_type_comments.data is None or self.light_type_comments.data == '': print("Comments blank") self.light_type_comments.errors.append( 'Please add comments about light type.') validated = False return validated
class SettingsMqtt(FlaskForm): enable_mqtt = SubmitField(lazy_gettext('Enable MQTT')) disable_mqtt = SubmitField(lazy_gettext('Disable MQTT')) mqtt_hostname = StringField( lazy_gettext('MQTT Broker IP'), render_kw={"placeholder": lazy_gettext('MQTT Broker IP')}, validators=[DataRequired()]) mqtt_port = IntegerField(lazy_gettext('MQTT Broker Port'), validators=[Optional()]) mqtt_user = StringField( lazy_gettext('MQTT Broker User'), render_kw={"placeholder": lazy_gettext('MQTT Broker User')}, validators=[DataRequired()]) mqtt_password = PasswordField( lazy_gettext('MQTT Broker Password'), render_kw={"placeholder": TRANSLATIONS['password']['title']}) mqtt_clientid = StringField( lazy_gettext('MQTT Client Name'), render_kw={"placeholder": lazy_gettext('MQTT Client Name')}, validators=[DataRequired()]) mqtt_topic_prefix = StringField( lazy_gettext('MQTT Topic Prefix'), render_kw={"placeholder": lazy_gettext('MQTT Topic Prefix')}, validators=[DataRequired()]) mqtt_keep_alive = IntegerField( lazy_gettext('Keep Alive frequency (seconds)'), render_kw={"placeholder": lazy_gettext('frequency (seconds)')}, validators=[ validators.NumberRange( min=1, message=lazy_gettext( 'Cannot send more frequently than one message ' ' per second.')) ], widget=NumberInput()) send_test_mqtt = SubmitField(lazy_gettext('Send Test MQTT message')) send_test_mqtt_topic = StringField( lazy_gettext('Topic to post test to.'), render_kw={"placeholder": lazy_gettext('MQTT Topic')}, validators=[Optional()]) save = SubmitField(TRANSLATIONS['save']['title'])
class IncomeForm(FlaskForm): amount = DecimalField( 'Amount', validators=[ DataRequired(message="Amount entered is not valid."), NumberRange(min=0, message="Amount cannot be negative.") ], widget=NumberInput(min=0, step=1), places=2) category = RadioField('Categories', validators=[DataRequired()], choices=income_choices) notes = TextAreaField('Notes', validators=[optional(), Length(max=60)], filters=[lambda v: 'None' if v == '' else v], render_kw={ "rows": 5, "cols": 6 }) date = DateField('Date', validators=[DataRequired()]) submit = smt_field('Save Income')
class UrlForm(FlaskForm): url = StringField(lazy_gettext('Feed address'), validators=[DataRequired()]) frequency = SelectField(lazy_gettext('Frequency'), choices=[('daily', lazy_gettext('Daily')), ('weekly', lazy_gettext('Weekly')), ('monthly', lazy_gettext('Monthly')), ('custom_days', lazy_gettext('Select week days:'))], default = 'weekly') custom_day_mon = BooleanField(lazy_gettext('Monday')) custom_day_tue = BooleanField(lazy_gettext('Tuesday')) custom_day_wed = BooleanField(lazy_gettext('Wednesday')) custom_day_thu = BooleanField(lazy_gettext('Thursday')) custom_day_fri = BooleanField(lazy_gettext('Friday')) custom_day_sat = BooleanField(lazy_gettext('Saturday')) custom_day_sun = BooleanField(lazy_gettext('Sunday')) start_date = DateField(lazy_gettext('Start date'), widget = DateInput(), default = datetime.date.today) start_date_timezone = SelectField(lazy_gettext('Timezone'), choices=generate_timezone_list()) option_start_at = IntegerField(lazy_gettext('Start from episode #'), validators = [DataRequired()], widget = NumberInput(min=1), default = 1) option_format = RadioField(lazy_gettext('Feed Format'), default = 'feed_rss', choices=[ ('feed_rss',lazy_gettext('RSS')), ('feed_atom',lazy_gettext('Atom')), ('feed_json',lazy_gettext('JSON Feed'))]) option_order = RadioField(lazy_gettext('Order'), default = 'asc', choices=[ ('asc',lazy_gettext('Oldest first')), ('desc',lazy_gettext('Newest first'))]) option_keepdates = BooleanField(lazy_gettext('Keep original publication dates'))
class ApprovalForm(FlaskForm): invoice_num = IntegerField('Invoice Number', validators=[DataRequired()], widget=NumberInput()) tracking_number = StringField('Tracking Number', validators=[DataRequired()]) approval_employee_code = StringField( 'Approval Employee Code', description='Employee Code', validators=[DataRequired(), is_valid_employee]) #have_repair = RadioField('Have Repair?', choices=[('y','Yes'),('n','No')]) interchange = StringField('Interchange') #stickered_engraved = RadioField('Stickered and Engraved?', choices=[('y','Yes'),('n','No')],validators=[DataRequired()]) repair_comments = StringField('Repair Comments') light_type = RadioField('Light Type', choices=[('HID', 'HID'), ('LED', 'LED'), ('Halogen', 'Halogen')], validators=[Optional()]) light_approved = RadioField('Final Approved', choices=[('Yes', 'Yes'), ('No', 'No'), ('Other', 'Other')], validators=[DataRequired()]) tested_bare = RadioField('Final Approved', choices=[('Tested', 'Tested'), ('Bare', 'Bare'), ('Cant Be Tested', 'Cant Be Tested')], validators=[Optional()]) approval_comments = StringField('Approval Comments') notes = TextAreaField('Notes') approval_type = RadioField('Final Approved', choices=[('Recon', 'Recon Light'), ('PO Recon', 'PO Recon'), ('New', 'New Light')], default='Recon', validators=[DataRequired()]) image_list = TextAreaField('Image List') light_noted = BooleanField('Noted') swap_out = BooleanField('Swap Out') bake_wash = BooleanField('Bake Wash') have_repair = BooleanField('Repair') """
class OutputMod(FlaskForm): output_id = StringField('Relay ID', widget=widgets.HiddenInput()) output_pin = HiddenField('Relay Pin') name = StringField(lazy_gettext('Name'), validators=[DataRequired()]) pin = IntegerField(lazy_gettext('Pin'), widget=NumberInput()) protocol = IntegerField(lazy_gettext('Protocol'), widget=NumberInput()) pulse_length = IntegerField(lazy_gettext('Pulse Length'), widget=NumberInput()) on_command = StringField(lazy_gettext('On Command')) off_command = StringField(lazy_gettext('Off Command')) pwm_command = StringField(lazy_gettext('PWM Command')) pwm_invert_signal = BooleanField(lazy_gettext('Invert Signal')) amps = DecimalField(lazy_gettext('Current Draw (amps)'), 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')) trigger = SelectField(lazy_gettext('On Trigger'), choices=[("1", lazy_gettext('High')), ("0", lazy_gettext('Low'))], validators=[Optional()]) on_at_start = SelectField(lazy_gettext('Start State'), choices=[("-1", lazy_gettext('Neither')), ("1", lazy_gettext('On')), ("0", lazy_gettext('Off'))], validators=[DataRequired()]) pwm_hertz = IntegerField(lazy_gettext('Frequency (Hertz)'), widget=NumberInput()) pwm_library = SelectField( lazy_gettext('Library'), choices=[("pigpio_any", lazy_gettext('Any Pin, <= 40 kHz')), ("pigpio_hardware", lazy_gettext('Hardware Pin, <= 30 MHz'))], validators=[DataRequired()]) save = SubmitField(lazy_gettext('Save')) delete = SubmitField(lazy_gettext('Delete')) order_up = SubmitField(lazy_gettext('Up')) order_down = SubmitField(lazy_gettext('Down')) pwm_duty_cycle_on = DecimalField('{} (%)'.format( lazy_gettext('Duty Cycle')), validators=[Optional()], widget=NumberInput(step='any')) on_submit = SubmitField(lazy_gettext('Turn On'))
class AssetsCreateForm(FlaskForm): platform = SelectField('Account', [DataRequired('Account is required')], choices=[('coinbase', 'Coinbase'), ('coinbase-pro', 'Coinbase Pro'), ('kraken', 'Kraken')]) asset = StringField('Asset', [DataRequired('Asset is required'), AssetExists()]) strategy = SelectField('Strategy', [ DataRequired('Strategy is required'), ], choices=[('cost-average', 'Cost Average'), ('dynamic-cost-average', 'Dynamic Cost Average'), ('value-average', 'Value Average'), ('dynamic-value-average', 'Dynamic Value Average')]) principle = IntegerField('Principle Amount', [DataRequired('Principle Amount is required')], widget=NumberInput(step=5, min=5)) period = SelectField('Period', [ DataRequired('Period is required'), ], choices=[ ('daily', 'Daily'), ('weekly', 'Weekly'), ('monthly', 'Monthly'), ]) apy = SelectField('Annual Percentage Yield', choices=[('0.05', '5%'), ('0.075', '7.5%'), ('0.10', '10%'), ('0.125', '12.5%'), ('0.15', '15%')]) submit = SubmitField('Add Asset')
class SettingsEmail(FlaskForm): smtp_host = StringField( lazy_gettext('SMTP Host'), render_kw={"placeholder": lazy_gettext('SMTP Host')}, validators=[DataRequired()]) smtp_port = IntegerField(lazy_gettext('SMTP Port'), validators=[Optional()]) smtp_protocol = StringField(lazy_gettext('SMTP Protocol'), validators=[DataRequired()]) smtp_ssl = BooleanField('Enable SSL') smtp_user = StringField( lazy_gettext('SMTP User'), render_kw={"placeholder": lazy_gettext('SMTP User')}, validators=[DataRequired()]) smtp_password = PasswordField( lazy_gettext('SMTP Password'), render_kw={"placeholder": TRANSLATIONS['password']['title']}) smtp_from_email = EmailField( lazy_gettext('From Email'), render_kw={"placeholder": TRANSLATIONS['email']['title']}, validators=[DataRequired(), validators.Email()]) smtp_hourly_max = IntegerField( lazy_gettext('Max emails (per hour)'), render_kw={"placeholder": lazy_gettext('Max emails (per hour)')}, validators=[ validators.NumberRange( min=1, message=lazy_gettext( 'Must have at least one message able to be ' 'sent per hour.')) ], widget=NumberInput()) send_test = SubmitField(lazy_gettext('Send Test Email')) send_test_to_email = EmailField( lazy_gettext('Test Email To'), render_kw={"placeholder": lazy_gettext('To Email Address')}, validators=[validators.Email(), validators.Optional()]) save = SubmitField(TRANSLATIONS['save']['title'])