How to use the wtforms.TextField 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 nutechsoftware / alarmdecoder-webapp / ad2web / notifications / forms.py View on Github external
settings['priority'] = self.populate_setting('priority', self.form_field.priority.data)
        settings['title'] = self.populate_setting('title', self.form_field.title.data)

    def populate_from_settings(self, id):
        EditNotificationForm.populate_from_settings(self, id)
        self.form_field.token.data = self.populate_from_setting(id, 'token')
        self.form_field.user_key.data = self.populate_from_setting(id, 'user_key')
        self.form_field.priority.data = self.populate_from_setting(id, 'priority')
        self.form_field.title.data = self.populate_from_setting(id, 'title')


class TwilioNotificationInternalForm(Form):
    account_sid = TextField(u'Account SID', [Required(), Length(max=50)], description=u'Your Twilio Account SID')
    auth_token = TextField(u'Auth Token', [Required(), Length(max=50)], description=u'Your Twilio User Auth Token')
    number_to = TextField(u'To', [Required(), Length(max=15)], description=u'Number to send SMS/call to')
    number_from = TextField(u'From', [Required(), Length(max=15)], description=u'Must Be A Valid Twilio Phone Number')

    def __init__(self, *args, **kwargs):
        kwargs['csrf_enabled'] = False
        super(TwilioNotificationInternalForm, self).__init__(*args, **kwargs)


class TwilioNotificationForm(EditNotificationForm):
    legend = (
        "<div style="\&quot;font-size:">"
        "</div>"
    )
    form_field = FormField(TwilioNotificationInternalForm)

    submit = SubmitField(u'Next')
    cancel = ButtonField(u'Cancel', onclick="location.href='/settings/notifications'")
github nutechsoftware / alarmdecoder-webapp / ad2web / notifications / forms.py View on Github external
return setting

    def populate_from_setting(self, id, name, default=None):
        ret = default

        setting = NotificationSetting.query.filter_by(notification_id=id, name=name).first()
        if setting is not None:
            ret = setting.value

        return ret


class MatrixNotificationInternalForm(Form):
    domain = TextField(u'Domain', [Required(), Length(max=255)], description=u'Domain or IP of matrix server ex. matrix.org')
    room_id = TextField(u'Room ID', [Required(), Length(max=300)], description=u'Room ID and domain ex. !DPNBnAVwxPMvNKTvvY:matrix.org')
    token = TextField(u'Token', [Required(), Length(max=300)], description=u'The long device authentication token. ex. D0gMQowMDI.....')
    custom_values = FieldList(FormField(CustomValueForm), validators=[Optional()], label=None)
    add_field = ButtonField(u'Add Field', onclick='addField();')

    def __init__(self, *args, **kwargs):
        kwargs['csrf_enabled'] = False
        super(MatrixNotificationInternalForm, self).__init__(*args, **kwargs)


class MatrixNotificationForm(Form):
    legend = (
        "<div style="\&quot;font-size:">"
        "Matrix.org is a free open source distributed network that supports end-to-end encryption.<br>"
        "TODO: Add ability to generate the <b>Room ID</b> and <b>Token</b> using a User ID and Pass<br>"
        "Notes: Create an account and a room on Riot.im that allows posts. You can get the room key from the Riot.im web client.<br>"
        "See: <a href="\&quot;https://gist.github.com/RickCogley/69f430d4418ae5498e8febab44d241c9\&quot;">https://gist.github.com/RickCogley/69f430d4418ae5498e8febab44d241c9</a> for curl commands to generate a <b>Token</b>.<br>"</div>
github opatut / mini / mini / forms.py View on Github external
text = TextAreaField("Comment", validators=[Required()])

class RepositorySettingsForm(Form):
    title = TextField("Title", validators=[Required()])
    slug = TextField("Path name", validators=[Required(),
        Regexp("^[a-z0-9A-Z_-]+$", message="Must only contain alphanumeric characters, dashes and underscores."),
        UniqueObject(Repository, "slug")])
    description = TextAreaField("Description")

    def set_repository(self, repository):
        for validator in self.slug.validators:
            if isinstance(validator, UniqueObject):
                validator.allowed_objects.append(repository)

class RepositoryCreateForm(RepositorySettingsForm):
    clone = TextField("Clone from URL", validators=[Optional(), URL()])

class TagForm(Form):
    tag = TextField("Tag", validators=[Required(), Regexp("^[\w\d_+ /-]+$", message="Invalid character.")])
    color = TextField("Color", validators=[Required(), Regexp("^([a-f0-9A-F]{3}){1,2}$", message="Invalid color code, format is #RGB or #RRGGBB.")])

class RegisterForm(Form):
    identifier = TextField("Username", validators=[Required(), UniqueObject(User, "identifier", message="This username is already in use.")])
    email = TextField("Email address", validators=[Required(), Email(), UniqueObject(mini.models.Email, "email", message="This email address is already in use.")])
    password1 = PasswordField("Password", validators=[])
    password2 = PasswordField("Password", validators=[EqualTo("password1")])
github domogik / domogik / src / domogik / admin / views / clients.py View on Github external
print dev
    print args
    detail = get_client_detail(client_id)
    (params, reason, status) = build_deviceType_from_packageJson(app.logger, app.zmq_context, device_type_id, client_id)

    # dynamically generate the wtfform
    class F(Form):
        try: default = args.get('Name')
        except: default = None
        name = TextField("Device name", [Required()], description=gettext("The display name for this device"), default=default)
        try: default = args.get('Description')
        except: default = None
        description = TextField("Description", description=gettext("A description for this device"), default=default)
        try: default = args.get('Reference')
        except: default = None
        reference = TextField("Reference", description=gettext("A reference for this device"), default=default)
        pass
    # Form for the Global part
    class F_global(Form):
        pass
    # Form for the xpl part
    class F_xpl(Form):
        pass
    # Form for the xpl command part
    class F_xpl_command(Form):
        pass
    # Form for the xpl stat part
    class F_xpl_stat(Form):
        pass

    # add the global params
    for item in params["global"]:
github Galts-Gulch / avarice / webconfigure.py View on Github external
default=ast.literal_eval(config['Indicators']['RSI']['Trader']['Single Trade']))
  tp8 = BooleanField('Trade Persist', description='Waits for a signal to persist two candles. Only used on an independent indicator.',
                     default=ast.literal_eval(config['Indicators']['RSI']['Trader']['Trade Persist']))
  td8 = TextField('Trade Delay', description='Number of candles with indicator info before trading. Must be greater than 0. Only used on an independent indicator.',
                  default=config['Indicators']['RSI']['Trader']['Trade Delay'])
  rsi_submit = SubmitField('Save')


class FastStochRSIK(Form):
  vi9 = BooleanField('Verbose', default=ast.literal_eval(
      config['Indicators']['Fast Stochastic RSI %K']['Verbose']))
  period3 = TextField(
      'Period', default=config['Indicators']['Fast Stochastic RSI %K']['Period'])
  bid3 = TextField('Bid', default=config['Indicators']['Fast Stochastic RSI %K']['Bid'],
                   description='Buy when Fast Stochastic RSI %K is &lt; Bid')
  ask3 = TextField('Ask', default=config['Indicators']['Fast Stochastic RSI %K']['Ask'],
                   description='Sell when Fast Stochastic RSI %K is &gt; Ask')
  tv9 = TextField('Trade Volume', description='Percentage of available asset and currency evaluated on each trade. 50 is 50%. Only used on an independent indicator. It is recommended to set this to a low value if SingleTrade is disabled.',
                  default=config['Indicators']['Fast Stochastic RSI %K']['Trader']['Trade Volume'])
  st9 = BooleanField('Single Trade', description='Should we only do a single consecutive sell or buy? Only used on an independent indicator. This still uses TradeVolume percent on each trade. This is useful for MA style strategies, whereas oscillator or diff style should be set to False (to often continue selling if above threshold, or buying below).',
                     default=ast.literal_eval(config['Indicators']['Fast Stochastic RSI %K']['Trader']['Single Trade']))
  tp9 = BooleanField('Trade Persist', description='Waits for a signal to persist two candles. Only used on an independent indicator.',
                     default=ast.literal_eval(config['Indicators']['Fast Stochastic RSI %K']['Trader']['Trade Persist']))
  td9 = TextField('Trade Delay', description='Number of candles with indicator info before trading. Must be greater than 0. Only used on an independent indicator.',
                  default=config['Indicators']['Fast Stochastic RSI %K']['Trader']['Trade Delay'])
  faststochrsik_submit = SubmitField('Save')


class FastStochRSID(Form):
  vi10 = BooleanField('Verbose', default=ast.literal_eval(
      config['Indicators']['Fast Stochastic RSI %D']['Verbose']))
  period4 = TextField(
github Galts-Gulch / avarice / webconfigure.py View on Github external
'MACD']['Candle Size Multiplier'],
                    description='Whole numbers only, used for aggregation. E.g. set to 3 if on 5 min candles and 15min indicator period is desired.')

  indstr6 = SelectField('Indicator Strategy',
                        default=config['Indicators'][
                            'MACD']['Indicator Strategy'],
                        choices=[
                            ('Convergence/Divergence', 'Convergence/Divergence'), ('Diff', 'Difference')],
                        description='Convergence/Divergence trades on MACD/signal convergence/divergence. Difference trades on the difference between MACD and signal.')
  sp6 = TextField(
      'Short Period', default=config['Indicators']['MACD']['Short Period'])
  lp6 = TextField(
      'Long Period', default=config['Indicators']['MACD']['Long Period'])
  sig1 = TextField(
      'Signal Period', default=config['Indicators']['MACD']['Signal Period'])
  dd6 = TextField('Diff Down', default=config['Indicators']['MACD']['Diff Down'],
                  description='Only used on "Diff" Indicator Strategy')
  du6 = TextField('Diff Up', default=config['Indicators']['MACD']['Diff Up'],
                  description='Only used on "Diff" Indicator Strategy')
  tv6 = TextField('Trade Volume', description='Percentage of available asset and currency evaluated on each trade. 50 is 50%. Only used on an independent indicator. It is recommended to set this to a low value if SingleTrade is disabled.',
                  default=config['Indicators']['MACD']['Trader']['Trade Volume'])
  st6 = BooleanField('Single Trade', description='Should we only do a single consecutive sell or buy? Only used on an independent indicator. This still uses TradeVolume percent on each trade. This is useful for MA style strategies, whereas oscillator or diff style should be set to False (to often continue selling if above threshold, or buying below).',
                     default=ast.literal_eval(config['Indicators']['MACD']['Trader']['Single Trade']))
  tp6 = BooleanField('Trade Persist', description='Waits for a signal to persist two candles. Only used on an independent indicator.',
                     default=ast.literal_eval(config['Indicators']['MACD']['Trader']['Trade Persist']))
  td6 = TextField('Trade Delay', description='Number of candles with indicator info before trading. Must be greater than 0. Only used on an independent indicator.',
                  default=config['Indicators']['MACD']['Trader']['Trade Delay'])
  macd_submit = SubmitField('Save')


class DMACD(Form):
  vi7 = BooleanField('Verbose', default=ast.literal_eval(
github kframework / kweb / app / forms.py View on Github external
confirm = PasswordField('Repeat Password')

class LoginForm(Form):
    email = TextField('Email Address', [validators.Length(min=6, max=35)])
    password = PasswordField('Password', [validators.Required()])

class ForgotForm(Form):
    email = TextField('Email Address', [validators.Length(min=6, max=35)])

class ResetForm(Form):
    password = PasswordField('New password', [validators.EqualTo('confirm', message='Passwords must match')])
    confirm = PasswordField('Repeat Password')

class EditCollectionForm(Form):
    id = TextField('Collection ID to edit', [validators.Required()])
    name = TextField('Change collection name', [validators.Length(max=100)])
    tool = TextField('Change tool', [validators.Length(max=35)])
    description = TextField('Change description', [validators.length(max=160)])

class SettingsForm(Form):
    email = TextField('Change login email', [validators.Length(min=6, max=35)])
    password = PasswordField('Change password', [validators.EqualTo('confirm', message='Passwords must match')])
    confirm = PasswordField('Repeat Password')
github ryankask / esther / esther / forms.py View on Github external
bcrypt.check_password_hash(user.password, self.password.data)):
            self.user = user
            return True

        self.auth_failed = True
        return False


class ChangePasswordField(PasswordField):
    def populate_obj(self, obj, name):
        if obj and self.data:
            obj.set_password(self.data)


class UserForm(Form):
    email = TextField(u'E-mail', [Required(), Email(), unique(User.email)])
    full_name = TextField(u'Full name')
    short_name = TextField(u'Short name', [Required()])
    password = ChangePasswordField(u'Password')
    is_admin = BooleanField(u'Is admin?')


class AddUserForm(UserForm):
    password = PasswordField(u'Password', [Required()])


### Blog


class StatusField(SelectField):
    def populate_obj(self, obj, name):
        setattr(obj, name, PostStatus.from_string(self.data))
github realpython / flask-boilerplate / forms.py View on Github external
from flask_wtf import Form
from wtforms import TextField, PasswordField
from wtforms.validators import DataRequired, EqualTo, Length

# Set your classes here.


class RegisterForm(Form):
    name = TextField(
        'Username', validators=[DataRequired(), Length(min=6, max=25)]
    )
    email = TextField(
        'Email', validators=[DataRequired(), Length(min=6, max=40)]
    )
    password = PasswordField(
        'Password', validators=[DataRequired(), Length(min=6, max=40)]
    )
    confirm = PasswordField(
        'Repeat Password',
        [DataRequired(),
        EqualTo('password', message='Passwords must match')]
    )


class LoginForm(Form):
github Runbook / runbook / src / web / reactionforms / linode-boot / __init__.py View on Github external
<p> 
        This reaction provides the ability to Boot a specified Linode Node Server. This reaction simply sends a Boot API request to Linode. A simple use case for this functionality is to boot a cold standby system during failover.
    </p>
    """
    placeholders = BaseReactForm.placeholders
    placeholders.update({
        'linode_id' : '12345',
        'api_key' : placeholders['apikey'],
    })
    descriptions=BaseReactForm.descriptions

    api_key = TextField(
        "API Key",
        description=descriptions['apikey'],
        validators=[DataRequired(message='API Key is a required field')])
    linode_id = TextField(
        "Linode ID#",
        description=descriptions['linode']['linodeID'],
        validators=[
            DataRequired(message='Linode ID# is a required field'),
            NumberRange(
                min=1, max=None,
                message="Linode ID should be a numeric ID number")
        ]
    )
    call_on = SelectField(
        "Call On",
        description=descriptions['callon'],
        choices=[('false', 'False Monitors'), ('true', 'True Monitors')],
        validators=[DataRequired(message='Call On is a required field')])