Exemple #1
0
class UserRegisterForm(wtf.Form):
    username = wtf.TextField(
        'Username',
        validators=[
            wtf.Required(),
            wtf.Length(min=2, max=50),
            wtf.Regexp(
                '^[a-zA-Z0-9_]*$',
                message=
                ('Username must only contain a to z, 0 to 9, and underscores.'
                 ))
        ],
        description=(
            'Your username is public and used as part of your project name.'))
    email = wtf.TextField('Email',
                          validators=[wtf.Required(),
                                      wtf.validators.Email()])
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')

    def validate_username(form, field):
        from notifico.views.account import _reserved

        username = field.data.strip().lower()
        if username in _reserved or User.username_exists(username):
            raise wtf.ValidationError('Sorry, but that username is taken.')
Exemple #2
0
class UserLoginForm(wtf.Form):
    username = wtf.TextField('Username', validators=[wtf.Required()])
    password = wtf.PasswordField('Password', validators=[wtf.Required()])

    def validate_password(form, field):
        if not User.login(form.username.data, field.data):
            raise wtf.ValidationError('Incorrect username and/or password.')
Exemple #3
0
class UserPasswordForm(wtf.Form):
    old = wtf.PasswordField('Old Password', validators=[wtf.Required()])
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')

    def validate_old(form, field):
        if not User.login(g.user.username, field.data):
            raise wtf.ValidationError('Old Password is incorrect.')
Exemple #4
0
class ChannelDetailsForm(wtf.Form):
    channel = wtf.TextField(
        'Channel', validators=[wtf.Required(),
                               wtf.Length(min=1, max=80)])
    host = wtf.TextField(
        'Host',
        validators=[wtf.Required(), wtf.Length(min=1, max=255)],
        default='chat.freenode.net')
    port = wtf.IntegerField('Port',
                            validators=[wtf.NumberRange(1024, 66552)],
                            default=6667)
    ssl = wtf.BooleanField('Use SSL', default=False)
    public = wtf.BooleanField(
        'Public',
        default=True,
        description=('Allow others to see that this channel exists.'))
Exemple #5
0
class UserPasswordForm(wtf.Form):
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.Length(5),
                                     wtf.EqualTo('confirm',
                                                 'Passwords do not match.'),
                                 ])
    confirm = wtf.PasswordField('Confirm Password')
Exemple #6
0
class UserForgotForm(wtf.Form):
    username = wtf.TextField('Username', validators=[wtf.Required()])

    def validate_username(form, field):
        user = User.by_username(field.data)
        if not user:
            raise wtf.ValidationError('No such user exists.')

        if reset.count_tokens(user) >= 5:
            raise wtf.ValidationError(
                'You may not reset your password more than 5 times'
                ' in one day.')
Exemple #7
0
class TravisConfigForm(wtf.Form):
    gh_user = wtf.TextField(
        'GitHub username',
        validators=[wtf.Required(), wtf.Length(max=40)],
        description=('Case-sensitive GitHub username of repository owner.'))
    repo_name = wtf.TextField(
        'Repo name',
        validators=[wtf.Required(), wtf.Length(max=100)],
        description=('Case-sensitive name of repository.'))
    token = wtf.TextField(
        'Travis Token',
        validators=[wtf.Required(), wtf.Length(max=1024)],
        description=
        ('Used to authenticate incoming webhooks.<br>'
         'Can be found on your '
         '<a href="https://travis-ci.org/profile/">Travis CI profile page</a>.'
         ))
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include minor mIRC coloring.'))
Exemple #8
0
class PostForm(Form):
    title = wtf.TextField(u"Title",
                          validators=[wtf.Required(),
                                      wtf.Length(max=250)])
    url = wtf.html5.URLField(
        u"URL", validators=[wtf.Optional(),
                            wtf.url(),
                            wtf.Length(max=2048)])
    description = wtf.TextAreaField(
        u"Description", description=u"Accepts Markdown formatting.")

    def validate_description(self, field):
        if not field.data:
            if not self.url.data:
                raise wtf.ValidationError(
                    "Either a URL or a description must be provided.")
Exemple #9
0
class ProjectDetailsForm(wtf.Form):
    name = wtf.TextField(
        'Project Name',
        validators=[
            wtf.Required(),
            wtf.Length(1, 50),
            wtf.Regexp(
                r'^[a-zA-Z0-9_\-\.]*$',
                message=(
                    'Project name must only contain a to z, 0 to 9, dashes'
                    ' and underscores.'))
        ])
    public = wtf.BooleanField('Public', validators=[], default=True)
    website = wtf.TextField('Project URL',
                            validators=[
                                wtf.Optional(),
                                wtf.Length(max=1024),
                                wtf.validators.URL()
                            ])
Exemple #10
0
class PasswordConfirmForm(wtf.Form):
    password = wtf.PasswordField('Password', validators=[wtf.Required()])

    def validate_password(form, field):
        if not User.login(g.user.username, field.data):
            raise wtf.ValidationError('Your password is incorrect.')
Exemple #11
0
class HookDetailsForm(wtf.Form):
    service_id = wtf.SelectField('Service',
                                 validators=[wtf.Required()],
                                 coerce=int)