コード例 #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.')
コード例 #2
0
ファイル: __init__.py プロジェクト: whitequark/notifico
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.'))
コード例 #3
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.')
コード例 #4
0
class BitbucketConfigForm(wtf.Form):
    branches = wtf.TextField(
        'Branches',
        validators=[wtf.Optional(), wtf.Length(max=1024)],
        description=(
            'A comma-seperated list of branches to forward, or blank for all.'
            ' Ex: "master, dev"'))
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include minor mIRC coloring.'))
    show_branch = wtf.BooleanField(
        'Show Branch Names',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, show the branch for a commit.'))
    show_raw_author = wtf.BooleanField(
        'Show Raw Author',
        validators=[wtf.Optional()],
        default=False,
        description=(
            'If checked, shows the raw author for a commit. For example,'
            ' <code>Tyler Kennedy &lt;[email protected]&gt;</code> instead of'
            ' <code>TkTech</code>.'))
コード例 #5
0
ファイル: __init__.py プロジェクト: whitequark/notifico
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()
                            ])
コード例 #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.')
コード例 #7
0
ファイル: travisci.py プロジェクト: whitequark/notifico
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.'))
コード例 #8
0
ファイル: fileadmin.py プロジェクト: tbikeev/Flask-SuperAdmin
class NameForm(form.BaseForm):
    """
        Form with a filename input field.

        Validates if provided name is valid for *nix and Windows systems.
    """
    name = wtf.TextField()

    regexp = re.compile(r'^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)'
                        r'(\..+)?$)[^\x00-\x1f\\?*:\";|/]+$')

    def validate_name(self, field):
        if not self.regexp.match(field.data):
            raise wtf.ValidationError(gettext('Invalid directory name'))
コード例 #9
0
ファイル: post.py プロジェクト: hasgeek/hasnew
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.")
コード例 #10
0
class GitlabConfigForm(wtf.Form):
    branches = wtf.TextField(
        'Branches',
        validators=[wtf.Optional(), wtf.Length(max=1024)],
        description=(
            'A comma-separated of branches to forward, or blank for all.'
            ' Ex: "master, dev"'))
    events = EventSelectField(
        'Events',
        choices=[('commit_comment', 'Commit comment'),
                 ('snippet_comment', 'Snippet comment'),
                 ('pipeline_created', 'Pipeline status: created'),
                 ('pipeline_pending', 'Pipeline status: pending'),
                 ('pipeline_running', 'Pipeline status: running'),
                 ('pipeline_failed', 'Pipeline status: failed'),
                 ('pipeline_success', 'Pipeline status: success'),
                 ('pipeline_canceled', 'Pipeline status: canceled'),
                 ('pipeline_skipped', 'Pipeline status: skipped'),
                 ('build_created', 'Build status: created'),
                 ('build_pending', 'Build status: pending'),
                 ('build_running', 'Build status: running'),
                 ('build_failed', 'Build status: failed'),
                 ('build_success', 'Build status: success'),
                 ('build_canceled', 'Build status: canceled'),
                 ('build_skipped', 'Build status: skipped'),
                 ('create_branch', 'Create branch'),
                 ('create_tag', 'Create tag'),
                 ('delete_branch', 'Delete branch'),
                 ('delete_tag', 'Delete tag'),
                 ('issue_comment', 'Issue comment'),
                 ('issue_close', 'Issue: closed'),
                 ('issue_update', 'Issue: updated'),
                 ('issue_open', 'Issue: opened'),
                 ('issue_reopen', 'Issue: reopened'),
                 ('mr_comment', 'Merge request comment'),
                 ('mr_close', 'Merge request: closed'),
                 ('mr_update', 'Merge request: updated'),
                 ('mr_open', 'Merge request: opened'),
                 ('mr_reopen', 'Merge request: reopened'),
                 ('mr_merge', 'Merge request: merged'), ('push', 'Push'),
                 ('wiki_create', 'Wiki: created page'),
                 ('wiki_edit', 'Wiki: edited page')])
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include minor mIRC coloring.'))
    show_branch = wtf.BooleanField(
        'Show Branch Name',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include the branch name.'))
    show_tags = wtf.BooleanField(
        'Show Tags',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, changes to tags will be shown.'))
    full_project_name = wtf.BooleanField(
        'Full Project Name',
        validators=[wtf.Optional()],
        default=False,
        description=
        ('If checked, show the full gitlab project name (ex: tktech/notifico)'
         ' instead of the Notifico project name (ex: notifico)'))
    title_only = wtf.BooleanField(
        'Title Only',
        validators=[wtf.Optional()],
        default=False,
        description=(
            'If checked, only the commits title (the commit message up to'
            ' the first new line) will be emitted.'))
コード例 #11
0
class GithubConfigForm(wtf.Form):
    branches = wtf.TextField(
        'Branches',
        validators=[wtf.Optional(), wtf.Length(max=1024)],
        description=(
            'A comma-separated list of branches to forward, or blank for all.'
            ' Ex: "master, dev"'))
    events = EventSelectField(
        'Events',
        choices=[
            ('commit_comment_created', 'Commit comment'),
            ('status_error', 'Commit status: error'),
            ('status_failure', 'Commit status: failure'),
            ('status_pending', 'Commit status: pending'),
            ('status_success', 'Commit status: success'),
            ('create_branch', 'Create branch'),
            ('create_tag', 'Create tag'),
            ('delete_branch', 'Delete branch'),
            ('delete_tag', 'Delete tag'),
            ('issue_comment_created', 'Issue comment'),
            ('issue_comment_deleted', 'Issue comment: deleted'),
            ('issue_comment_edited', 'Issue comment: edited'),
            ('issue_assigned', 'Issue: assigned'),
            ('issue_closed', 'Issue: closed'),
            ('issue_edited', 'Issue: edited'),
            ('issue_labeled', 'Issue: labeled'),
            ('issue_opened', 'Issue: opened'),
            ('issue_reopened', 'Issue: reopened'),
            ('issue_unassigned', 'Issue: unassigned'),
            ('issue_unlabeled', 'Issue: unlabeled'),
            ('pr_review_created', 'Pull request review comment'),
            ('pr_review_deleted', 'Pull request review comment: deleted'),
            ('pr_review_edited', 'Pull request review comment: edited'),
            ('pr_assigned', 'Pull request: assigned'),
            ('pr_closed', 'Pull request: closed'),
            ('pr_edited', 'Pull request: edited'),
            ('pr_labeled', 'Pull request: labeled'),
            ('pr_opened', 'Pull request: opened'),
            ('pr_reopened', 'Pull request: reopened'),
            ('pr_synchronize', 'Pull request: synchronize'),
            ('pr_unassigned', 'Pull request: unassigned'),
            ('pr_unlabeled', 'Pull request: unlabeled'),
            ('push', 'Push'),
            ('release_published', 'Release published'),
            ('member_added', 'Repo: added collaborator'),
            ('team_add', 'Repo: added to a team'),
            ('fork', 'Repo: forked'),
            ('public', 'Repo: made public'),
            ('watch_started', 'Repo: starred'),
            ('gollum_created', 'Wiki: created page'),
            ('gollum_edited', 'Wiki: edited page'),
        ])
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include minor mIRC coloring.'))
    show_branch = wtf.BooleanField(
        'Show Branch Name',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include the branch name.'))
    show_tags = wtf.BooleanField(
        'Show Tags',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, changes to tags will be shown.'))
    prefer_username = wtf.BooleanField(
        'Prefer Usernames',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, show github usernames instead of commiter name when'
            ' possible.'))
    full_project_name = wtf.BooleanField(
        'Full Project Name',
        validators=[wtf.Optional()],
        default=False,
        description=
        ('If checked, show the full GitHub project name (ex: notifico/notifico)'
         ' instead of the Notifico project name (ex: notifico)'))
    title_only = wtf.BooleanField(
        'Title Only',
        validators=[wtf.Optional()],
        default=False,
        description=(
            'If checked, only the commits title (the commit message up to'
            ' the first new line) will be emitted.'))
    distinct_only = wtf.BooleanField(
        'Distinct Commits Only',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'Commits will only be announced the first time they are seen.'))
コード例 #12
0
class Form(wtf.Form):
    col1 = wtf.TextField()
    col2 = wtf.TextField()
    col3 = wtf.TextField()