How to use the wtforms.SelectField function in WTForms

To help you get started, we’ve selected a few WTForms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github csm-aut / csm / csmserver / forms.py View on Github external
install_action = SelectMultipleField('Install Action', coerce=str, choices=[('', '')])

    scheduled_time = StringField('Scheduled Time', [required()])
    scheduled_time_UTC = HiddenField('Scheduled Time')
    software_packages = TextAreaField('Software Packages')
    custom_command_profile = SelectMultipleField('Custom Command Profile', coerce=int, choices=[('', '')])
    # Use str coercion as Batch Schedule Install displays the action Install Action.
    dependency = SelectField('Dependency', coerce=str, choices=[(-1, 'None')])
       
    install_history_dialog_host = SelectField('Host', coerce=str, choices=[('', '')])
    
    host_software_dialog_target_software = StringField('Target Software Release')
    host_software_dialog_host = SelectField('Host', coerce=str, choices=[('', '')])
    host_software_dialog_last_successful_inventory_elapsed_time = StringField('Last Successful Retrieval')

    cisco_dialog_server = SelectField('Server Repository', coerce=int, choices=[(-1, '')])
    cisco_dialog_server_directory = SelectField('Server Directory', coerce=str, choices=[('', '')])
    server_modal_dialog_server = SelectField('Server Repository', coerce=int, choices=[(-1, '')])

    # For SCP server repository support
    destination_path_on_device = StringField('Destination Path on Device (e.g. harddisk:/file)')

    hidden_selected_hosts = HiddenField('')
    hidden_server = HiddenField('')   
    hidden_server_name = HiddenField('')   
    hidden_server_directory = HiddenField('')
    
    hidden_pending_downloads = HiddenField('Pending Downloads')
    hidden_edit = HiddenField('Edit')


class ScheduleInstallForm(HostScheduleInstallForm):
github mjhea0 / flask-ajax-form / json-example / form.py View on Github external
from flask.ext.wtf import Form
from wtforms import SelectField


class TestForm(Form):
    department = SelectField(u'', choices=())
    employee = SelectField(u'', choices=())
github wylok / sparrow / module / MyForm.py View on Github external
domain = StringField('domain', id='domain')
        sidecar = StringField('sidecar', id='sidecar')
        request_cpu = IntegerField('request_cpu',id='request_cpu')
        request_mem = IntegerField('request_mem',id='request_mem')
        limit_cpu = IntegerField('limit_cpu',id='limit_cpu')
        limit_mem = IntegerField('limit_mem',id='limit_mem')
        submit = SubmitField('提交', id='btn1')
    except Exception as e:
        logging.error(e)

class FormK8sUpdate(Form):
    try:
        _, contexts, _ = tools.k8s_conf()
        choices = [(context, context) for context in contexts]
        contexts = SelectField(choices=choices, id='contexts')
        deployment = SelectField(choices=[],id='deployment')
        version = SelectField(choices=[], id='version')
        action = SelectField(choices=[('update', '更新'), ('rollback', '回滚')], id='action')
        submit = SubmitField('提交', id='btn1')
    except Exception as e:
        logging.error(e)
    finally:
        db_op.DB.session.remove()

class FormK8sHpa(Form):
    try:
        _, contexts, _ = tools.k8s_conf()
        contexts = SelectField(choices=[(context, context) for context in contexts], id='contexts')
        deployment = SelectField(choices=[],id='deployment')
        max_replica = IntegerField(validators=[DataRequired()], id='max_replica')
        min_replica = IntegerField(validators=[DataRequired()],id='min_replica')
        cpu_value = IntegerField(validators=[DataRequired()],id='cpu_value')
github DOAJ / doaj / portality / formcontext / oldforms.py View on Github external
class AuthorForm(Form):
    name = TextField("Name", [validators.Optional()])
    affiliation = TextField("Affiliation", [validators.Optional()])
    
class ArticleForm(Form):
    title = TextField("Article Title", [validators.Required()])
    doi = TextField("DOI", [validators.Optional(), validators.Regexp(regex=DOI_REGEX, message=DOI_ERROR)])
    authors = FieldList(FormField(AuthorForm), min_entries=3) # We have to do the validation for this at a higher level
    abstract = TextAreaField("Abstract", [validators.Optional()])
    keywords = TextField("Keywords", [validators.Optional()], description="Use a , to separate keywords") # enhanced with select2
    fulltext = TextField("Full-Text URL", [validators.Optional(), validators.URL()], description="(The URL for each article must be unique)")
    publication_year = SelectField("Year", [validators.Optional()], choices=YEAR_CHOICES, default=str(datetime.now().year))
    publication_month = SelectField("Month", [validators.Optional()], choices=MONTH_CHOICES, default=str(datetime.now().month) )
    pissn = SelectField("Journal ISSN (print version)", [ThisOrThat("eissn")], choices=[]) # choices set at construction
    eissn = SelectField("Journal ISSN (online version)", [ThisOrThat("pissn")], choices=[]) # choices set at construction
 
    volume = TextField("Volume Number", [validators.Optional()])
    number = TextField("Issue Number", [validators.Optional()])
    start = TextField("Start Page", [validators.Optional()])
    end = TextField("End Page", [validators.Optional()])

    def __init__(self, *args, **kwargs):
        super(ArticleForm, self).__init__(*args, **kwargs)
        try:
            if not current_user.is_anonymous():
                issns = models.Journal.issns_by_owner(current_user.id)
                ic = [("", "Select an ISSN")] + [(i,i) for i in issns]
                self.pissn.choices = ic
                self.eissn.choices = ic
        except:
            # not logged in, and current_user is broken
github afourmy / eNMS / eNMS / services / backup / log_backup_service.py View on Github external
destination = f"{self.destination_path}/logs_{now}.tgz"
        self.transfer_file(ssh_client, [(source, destination)])
        ssh_client.close()
        if self.delete_folder:
            rmtree(path_dir)
        if self.delete_archive:
            remove(source)
        return {
            "success": True,
            "result": f"logs stored in {destination} ({device.ip_address})",
        }


class LogBackupForm(ServiceForm, metaclass=metaform):
    form_type = HiddenField(default="LogBackupService")
    protocol = SelectField(choices=(("scp", "SCP"), ("sftp", "SFTP")))
    delete_folder = BooleanField()
    delete_archive = BooleanField()
    destination_path = StringField()
github marcus67 / little_brother / little_brother / entity_forms.py View on Github external
def create_rulesets_form(prefix, p_localized_context_details, p_context_choices, p_context_details_filters):
    class RulesetForm(custom_form.ModelForm):
        context_label = wtforms.StringField("ContextLabel")
        context = wtforms.SelectField("Context", choices=p_context_choices)
        context_details = custom_fields.LocalizedField("ContextDetails", p_values=p_localized_context_details,
                                                       filters=p_context_details_filters)
        min_time_of_day = custom_fields.TimeField("MinTimeOfDay")
        max_time_of_day = custom_fields.TimeField("MaxTimeOfDay")
        max_time_per_day = custom_fields.DurationField("MaxTimePerDay")
        min_break = custom_fields.DurationField("MinBreak")
        free_play = custom_fields.BooleanField("FreePlay")
        max_activity_duration = custom_fields.DurationField("MaxActivityDuration")

    return RulesetForm(prefix=prefix, meta={'csrf': False})
github Junctionzc / flask-blog / app / main / forms.py View on Github external
class EditProfileForm(Form):
    name = StringField(u'昵称', validators = [Length(0, 64)])
    location = StringField(u'地址', validators = [Length(0, 64)])
    about_me = TextAreaField(u'关于我')
    submit = SubmitField(u'确认')
    
class EditProfileAdminForm(Form):
    email = StringField(u'电子邮箱', validators = [Required(), Length(1, 64),
                                               Email()])
    username = StringField(u'用户名', validators = [
        Required(), Length(1, 64), Regexp('^[A-Za-z][A-Za-z0-9_.]*$', 0,
                                          'Usernames must have only letters, '
                                          'numbers, dots or underscores')])
    confirmed = BooleanField(u'确认')
    role = SelectField(u'角色', coerce = int)
    name = StringField(u'真实名字', validators = [Length(0, 64)])
    location = StringField(u'地址', validators = [Length(0, 64)])
    about_me = TextAreaField(u'关于我')
    submit = SubmitField(u'确认')
    
    def __init__(self, user, *args, **kwargs):
        super(EditProfileAdminForm, self).__init__(*args, **kwargs)
        self.role.choices = [(role.id, role.name)
                            for role in Role.query.order_by(Role.name).all()]
        self.user = user
    
    def validate_email(self, field):
        if field.data != self.user.email and \
                User.query.filter_by(email = field.data).first():
            raise ValidationError(u'电子邮箱已经被注册')
github apache / incubator-superset / superset / forms.py View on Github external
"missing. If false, a minimum width will be applied "
                    "to columns and the width may overflow into an "
                    "horizontal scroll."),
            }),
            'include_series': (BetterBooleanField, {
                "label": _("Include Series"),
                "default": False,
                "description": _("Include series name as an axis")
            }),
            'secondary_metric': (SelectField, {
                "label": _("Color Metric"),
                "choices": datasource.metrics_combo,
                "default": default_metric,
                "description": _("A metric to use for color")
            }),
            'country_fieldtype': (SelectField, {
                "label": _("Country Field Type"),
                "default": 'cca2',
                "choices": (
                    ('name', _('Full name')),
                    ('cioc', _('code International Olympic Committee (cioc)')),
                    ('cca2', _('code ISO 3166-1 alpha-2 (cca2)')),
                    ('cca3', _('code ISO 3166-1 alpha-3 (cca3)')),
                ),
                "description": _(
                    "The country code standard that Superset should expect "
                    "to find in the [country] column")
            }),
            'groupby': (SelectMultipleSortableField, {
                "label": _("Group by"),
                "choices": self.choicify(datasource.groupby_column_names),
                "description": _("One or many fields to group by")
github Polsaker / throat / app / forms / sub.py View on Github external
restricted = BooleanField(_l('Only mods can post'))
    usercanflair = BooleanField(_l('Allow users to flair their own posts'))
    polling = BooleanField(_l('Enable polls'))
    subsort = RadioField(_l('Default sub page post sorting'),
                         choices=[('v', 'Hot'), ('v_two', 'New'),
                                  ('v_three', 'Top')],
                         validators=[Optional()])
    sidebar = TextAreaField(_l('Sidebar text'), validators=[Length(max=8000)])
    sublogprivate = BooleanField(_l('Make the sub log private'))
    subbannedusersprivate = BooleanField(_l('Make the list of banned users on this sub private'))


class EditMod2Form(FlaskForm):
    """ Edit mod2 of sub (admin/owner) """
    user = StringField(_l('New mod username'), validators=[DataRequired(), Length(min=1, max=128)])
    level = SelectField(_l('Mod level'), choices=[('1', _l('Moderator')), ('2', _l('Janitor'))],
                        validators=[DataRequired()])


class CreateSubPostForm(FlaskForm):
    """ Sub content submission form """
    sub = StringField(_l('Sub'), validators=[DataRequired(), Length(min=2, max=32)])
    title = StringField(_l('Post title'), validators=[DataRequired(), Length(min=3, max=350)])
    content = TextAreaField(_l('Post content'), validators=[Length(max=16384)])
    link = StringField(_l('Post link'), validators=[Length(min=10, max=255), Optional(), URL(require_tld=True)])
    ptype = RadioField(_l('Post type'),
                       choices=[('text', _l('Text post')), ('link', _l('Link post'))],
                       validators=[DataRequired()])
    nsfw = BooleanField(_l('NSFW?'))
    # for polls.
    options = FieldList(StringField(_l('Option')), max_entries=6)
    hideresults = BooleanField(_l('Hide poll results until it closes'))
github pierre-chaville / automlk / web / app / form.py View on Github external
file_train = FileField()

    filename_test = StringField()
    file_test = FileField()

    filename_submit = StringField()
    file_submit = FileField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class UpdateDatasetForm(FlaskForm):
    # this is the form to update specific fields of a dataset
    name = StringField(validators=[DataRequired()])
    folder = SelectField('folder', coerce=int)
    description = TextAreaField()
    source = StringField()
    url = StringField()

    def set_choices(self, choices):
        self.folder.choices = [(f['id'], f['name']) for f in choices]


class StartDatasetForm(FlaskForm):
    # this is the form to start the search on a dataset
    problem_type = SelectField(choices=[('classification', 'classification'), ('regression', 'regression')])
    regression_metric = SelectField(choices=[])
    regression_other_metrics = SelectMultipleField(choices=[(m.name, m.name) for m in metric_list if m.problem_type == 'regression'])
    classification_metric = SelectField(choices=[])
    classification_other_metrics = SelectMultipleField(choices=[(m.name, m.name) for m in metric_list if m.problem_type == 'classification'])