コード例 #1
0
class LoginForm(wtforms.Form):
    username = wtforms.TextField(
        'Username',
        [wtforms.validators.Required(),
         wtforms.validators.Regexp(r'^\w+$')])
    password = wtforms.PasswordField(
        'Password',
        [wtforms.validators.Required()])
コード例 #2
0
class ProfileForm(Form):
    fullname = wtforms.TextField('Full name',
                                 validators=[wtforms.validators.Required()])
    email = wtforms.fields.html5.EmailField('Email address',
                                            validators=[
                                                wtforms.validators.Required(),
                                                wtforms.validators.Email(),
                                                ValidEmailDomain()
                                            ])
    username = wtforms.TextField('Username',
                                 validators=[wtforms.validators.Required()])
    description = wtforms.TextAreaField('Bio')
    timezone = wtforms.SelectField('Timezone',
                                   validators=[wtforms.validators.Required()],
                                   choices=timezones)

    def __init__(self, *args, **kwargs):
        super(ProfileForm, self).__init__(*args, **kwargs)
        self.existing_email = None

    def validate_username(self, field):
        ## Usernames are now mandatory. This should be commented out:
        # if not field.data:
        #     field.data = None
        #     return
        field.data = field.data.lower()  # Usernames can only be lowercase
        if not valid_username(field.data):
            raise wtforms.ValidationError(
                "Usernames can only have alphabets, numbers and dashes (except at the ends)"
            )
        if field.data in current_app.config['RESERVED_USERNAMES']:
            raise wtforms.ValidationError("This name is reserved")
        existing = User.query.filter_by(username=field.data).first()
        if existing is not None and existing.id != self.edit_id:
            raise wtforms.ValidationError("This username is taken")
        existing = Organization.query.filter_by(name=field.data).first()
        if existing is not None:
            raise wtforms.ValidationError("This username is taken")

    # TODO: Move to function and place before ValidEmailDomain()
    def validate_email(self, field):
        field.data = field.data.lower()  # Convert to lowercase
        existing = UserEmail.query.filter_by(email=field.data).first()
        if existing is not None and existing.user != self.edit_obj:
            raise wtforms.ValidationError(
                "This email address has been claimed by another user.")
コード例 #3
0
class MemoryForm(wtforms.Form):
    name = wtforms.TextField(label='Name',
                             validators=[wtforms.validators.Required()])
    city = wtforms.TextField(label='City',
                             validators=[wtforms.validators.Required()])
    state = wtforms.SelectField(label='State', choices=STATES)
    email = wtforms.TextField(label='Email (will not be displayed)',
                              validators=[wtforms.validators.Required()])
    can_share = wtforms.RadioField(
        label='Can we share your book memory to encourage others?',
        default='True',
        choices=[('True', 'Yes'), ('False', 'No')])
    words = wtforms.TextAreaField(label='Your Memory',
                                  validators=[
                                      wtforms.validators.Required(),
                                      wtforms.validators.Length(max=500)
                                  ])
コード例 #4
0
ファイル: app.py プロジェクト: chrome-extension/urlink
class SearchForm(wtforms.Form):
    """For live searching/filtering the bookmarks.

    Uses the /autocomplete endpoint (see: autocomplete()).

    """

    autocomp = wtforms.TextField('autocomp', id='autocomplete')
コード例 #5
0
ファイル: movie.py プロジェクト: nod/cinepy
class MovieSearchForm(wtforms.Form):
    title = wtforms.TextField(u'Title', [wtforms.validators.length(max=50)])

    adname = wtforms.TextField(u'Actor or Director Name',
                               [wtforms.validators.length(max=50)])

    genres = wtforms.SelectMultipleField(
        u'Genre',
        choices=MOVIE_GENRES,
    )

    rating = wtforms.SelectMultipleField(
        u'Ratings',
        choices=MOVIE_RATINGS[1:],
    )

    search = wtforms.HiddenField(u'search', )
コード例 #6
0
class RequestPullForm(wtf.Form):
    ''' Form to create a request pull. '''
    title = wtforms.TextField(
        'Title<span class="error">*</span>',
        [wtforms.validators.Required()]
    )
    initial_comment = wtforms.TextAreaField(
        'Initial Comment', [wtforms.validators.Optional()])
コード例 #7
0
class FakeForm(wtforms.Form):
    ''' Form to configure the mail hook. '''
    field1 = wtforms.TextField(
        'Title', [pagure.hooks.RequiredIf('active')]
    )
    field2 = wtforms.BooleanField(
        'Title2', [wtforms.validators.Optional()]
    )
コード例 #8
0
class ProjectForm(wtf.Form):
    """ Project form """
    name = wtf.TextField(_(u"Project name"),
                         validators=[validators.Required()])
    coordinator_id = wtf.SelectField(_(u"Coordinator"),
                                     validators=[],
                                     choices=UserChoices(empty=True))
    tracker_id = wtf.SelectField(_(u"Tracker"),
                                 validators=[validators.Required()],
                                 choices=EntityChoices(
                                     Tracker, lambda tracker: tracker.name))
    status = wtf.SelectField(_(u"Status"),
                             validators=[validators.Required()],
                             choices=STATUS)
    turn_off_selectors = wtf.BooleanField(_(u"Turn off selectors"),
                                          validators=[],
                                          default=True)
    project_selector = wtf.TextField(_(u"Project selector"), validators=[])
    component_selector = wtf.TextField(_(u"Component selector"), validators=[])
    version_selector = wtf.TextField(_(u"Version selector"), validators=[])
    ticket_id_selector = wtf.TextField(_(u"Ticket ID selector"), validators=[])
    active = wtf.BooleanField(_(u"Active"), validators=[], default=True)
    google_card = wtf.TextField(_(u"Link to project card in google docs"),
                                validators=[])
    google_wiki = wtf.TextField(_(u"Link to project wiki in google sites"),
                                validators=[])
    mailing_url = wtf.TextField(_(u"Link to mailing group"), validators=[])

    working_agreement = wtf.TextAreaField(_("Working agreement"))
    definition_of_done = wtf.TextAreaField(_("Definition of done"))
    definition_of_ready = wtf.TextAreaField(_("Definition of ready"))
    continuous_integration_url = wtf.StringField(
        _("Continuous integration link"))
    backlog_url = wtf.StringField(_("Backlog link"))
    sprint_tabs = wtf.TextAreaField(_("Custom sprint tabs"))

    def validate_component_selector(self, field):
        if field.data and not self.project_selector.data:
            raise validators.ValidationError(
                _(u"Cannot define component without a project"))

    def validate_ticket_id_selector(self, field):
        if field.data and (self.project_selector.data
                           or self.component_selector.data):
            raise validators.ValidationError(
                _(u"Ticket ID selector disables project and component selectors"
                  ))
        value = field.data
        if value:
            for v in value.split(','):
                try:
                    int(v)
                except ValueError:
                    raise validators.ValidationError(
                        _(u"Ticket IDs must be a comma-separated list of numbers"
                          ))
コード例 #9
0
 class _ExternalServiceForm(Form):
     title = wtforms.StringField(
         validators=[wtforms.validators.input_required(), check_unique])
     description = wtforms.TextField(
         validators=[wtforms.validators.optional()])
     url_template = wtforms.StringField(validators=[
         wtforms.validators.input_required(), check_renders_correctly
     ])
コード例 #10
0
ファイル: forms.py プロジェクト: hemanth/mediagoblin
class RegistrationForm(wtforms.Form):
    username = wtforms.TextField('Username', [
        wtforms.validators.Required(),
        wtforms.validators.Length(min=3, max=30),
        wtforms.validators.Regexp(r'^\w+$')
    ])
    password = wtforms.PasswordField('Password', [
        wtforms.validators.Required(),
        wtforms.validators.Length(min=6, max=30),
        wtforms.validators.EqualTo('confirm_password')
    ])
    confirm_password = wtforms.PasswordField('Confirm password',
                                             [wtforms.validators.Required()])
    email = wtforms.TextField(
        'Email address',
        [wtforms.validators.Required(),
         wtforms.validators.Email()])
コード例 #11
0
class SearchForm(Form):
    # TODO: Define form fields here
    class Meta:
        csrf = False
        csrf_secret = web.SECRET_KEY
        locales = ('en_GB', 'en')

    url = wtforms.TextField('url', [wtforms.validators.DataRequired()])
コード例 #12
0
class InstrumentList(wtf.Form):
    '''
    '''
    curve_date = wtffields.DateField('Curve date')
    curve_type = wtf.SelectField('Curve type', choices=conv.CURVE_TYPES)
    currency = wtf.TextField('Currency')
    instruments = wtf.FieldList(wtf.FormField(Instrument), min_entries=3)
    submit = wtf.SubmitField()
コード例 #13
0
class LoginForm(wtforms.Form):
    openid = wtforms.TextField(
        _('OpenID'),
        [
            wtforms.validators.Required(),
            # Can openid's only be urls?
            wtforms.validators.URL(message='Please enter a valid url.')
        ])
コード例 #14
0
class ChrootForm(wtf.Form):
    """
    Validator for editing chroots in project
    (adding packages to minimal chroot)
    """

    buildroot_pkgs = wtforms.TextField(
        "Additional packages to be always present in minimal buildroot")
コード例 #15
0
ファイル: forms.py プロジェクト: Gahlot/pagure
class UpdateIssueForm(wtf.Form):
    ''' Form to add a comment to an issue. '''
    tag = wtforms.TextField('tag', [
        wtforms.validators.Optional(),
        wtforms.validators.Regexp(TAGS_REGEX, flags=re.IGNORECASE),
        wtforms.validators.Length(max=255),
    ])
    depends = wtforms.TextField('dependency issue',
                                [wtforms.validators.Optional()])
    blocks = wtforms.TextField('blocked issue',
                               [wtforms.validators.Optional()])
    comment = wtforms.TextAreaField('Comment', [wtforms.validators.Optional()])
    assignee = wtforms.TextAreaField('Assigned to',
                                     [wtforms.validators.Optional()])
    status = wtforms.SelectField('Status', [wtforms.validators.Optional()],
                                 choices=[])
    priority = wtforms.SelectField('Priority', [wtforms.validators.Optional()],
                                   choices=[])
    milestone = wtforms.SelectField('Milestone',
                                    [wtforms.validators.Optional()],
                                    choices=[])
    private = wtforms.BooleanField(
        'Private',
        [wtforms.validators.optional()],
    )

    def __init__(self, *args, **kwargs):
        """ Calls the default constructor with the normal argument but
        uses the list of collection provided to fill the choices of the
        drop-down list.
        """
        super(UpdateIssueForm, self).__init__(*args, **kwargs)
        if 'status' in kwargs:
            self.status.choices = [(status, status)
                                   for status in kwargs['status']]

        self.priority.choices = []
        if 'priorities' in kwargs:
            for key in sorted(kwargs['priorities']):
                self.priority.choices.append((key, kwargs['priorities'][key]))

        self.milestone.choices = []
        if 'milestones' in kwargs:
            for key in sorted(kwargs['milestones']):
                self.milestone.choices.append((key, key))
            self.milestone.choices.insert(0, ('', ''))
コード例 #16
0
ファイル: forms.py プロジェクト: ralphbean/packagedb2
class PackageStatusForm(wtf.Form):
    pkg_name = wtforms.TextField('Package name',
                                 [wtforms.validators.Required()])
    collection_name = wtforms.TextField('Collection name',
                                        [wtforms.validators.Required()])
    pkg_status = wtforms.SelectField('Status', [wtforms.validators.Required()],
                                     choices=[(item, item) for item in []])

    def __init__(self, *args, **kwargs):
        """ Calls the default constructor with the normal argument but
        uses the list of collection provided to fill the choices of the
        drop-down list.
        """
        super(PackageStatusForm, self).__init__(*args, **kwargs)
        if 'pkg_status' in kwargs:
            self.pkg_status.choices = [(status, status)
                                       for status in kwargs['pkg_status']]
コード例 #17
0
ファイル: event.py プロジェクト: rudimk/peopleflow
class EventSyncForm(Form):
    lastuser_username = wtforms.TextField('LastUser Username')
    lastuser_password = wtforms.PasswordField('LastUser Password')

    def validate_funnel_password(self, field):
        if self.funnel_username.data != "" and field.data == "":
            raise wtforms.ValidationError(
                "If you enter the username, you have to enter the password")
コード例 #18
0
ファイル: event.py プロジェクト: rudimk/peopleflow
class EventLogoForm(Form):
    event_logo = wtforms.TextField(
        'Event Logo',
        description="Provide the URL for the image for the event logo.",
        validators=[
            wtforms.validators.Optional(),
            wtforms.validators.URL(message="Please provide a valid URL")
        ])
コード例 #19
0
class LoginForm(wtforms.Form):
    username = wtforms.TextField(
        _('Username or Email'),
        [wtforms.validators.Required(),
         normalize_user_or_email_field()])
    password = wtforms.PasswordField(_('Password'))
    stay_logged_in = wtforms.BooleanField(label='',
                                          description=_('Stay logged in'))
コード例 #20
0
class StoryForm(FlaskForm):
    title = f.TextField(
        'text',
        validators=[
            DataRequired(),
            Length(-1,
                   MAX_CHAR_STORY_TITLE,
                   message="Reach max number of characters for the title!")
        ])
    text = f.TextField('text',
                       validators=[
                           DataRequired(),
                           Length(-1,
                                  MAX_CHAR_STORY,
                                  message="Reach max number of characters!")
                       ])
    display = ['text']
コード例 #21
0
ファイル: forms.py プロジェクト: sherlockliu/mediagoblin
class ChangeEmailForm(wtforms.Form):
    new_email = wtforms.TextField(_('New email address'), [
        wtforms.validators.InputRequired(),
        normalize_user_or_email_field(allow_user=False)
    ])
    password = wtforms.PasswordField(
        _('Password'), [wtforms.validators.InputRequired()],
        description=_("Enter your password to prove you own this account."))
コード例 #22
0
ファイル: instances.py プロジェクト: garthmbooth/eucaconsole
class InstancesFiltersForm(BaseSecureForm):
    """Form class for filters on landing page"""
    state = wtforms.SelectMultipleField(label=_(u'Status'))
    availability_zone = wtforms.SelectMultipleField(
        label=_(u'Availability zone'))
    instance_type = wtforms.SelectMultipleField(label=_(u'Instance type'))
    root_device_type = wtforms.SelectMultipleField(
        label=_(u'Root device type'))
    security_group = wtforms.SelectMultipleField(label=_(u'Security group'))
    scaling_group = wtforms.SelectMultipleField(label=_(u'Scaling group'))
    tags = wtforms.TextField(label=_(u'Tags'))

    def __init__(self,
                 request,
                 ec2_conn=None,
                 autoscale_conn=None,
                 cloud_type='euca',
                 **kwargs):
        super(InstancesFiltersForm, self).__init__(request, **kwargs)
        self.request = request
        self.ec2_conn = ec2_conn
        self.autoscale_conn = autoscale_conn
        self.cloud_type = cloud_type
        self.ec2_choices_manager = ChoicesManager(conn=ec2_conn)
        self.autoscale_choices_manager = ChoicesManager(conn=autoscale_conn)
        region = request.session.get('region')
        self.availability_zone.choices = self.get_availability_zone_choices(
            region)
        self.state.choices = self.get_status_choices()
        self.instance_type.choices = self.get_instance_type_choices()
        self.root_device_type.choices = self.get_root_device_type_choices()
        self.security_group.choices = self.ec2_choices_manager.security_groups(
            add_blank=False)
        self.scaling_group.choices = self.autoscale_choices_manager.scaling_groups(
            add_blank=False)

    def get_availability_zone_choices(self, region):
        return self.ec2_choices_manager.availability_zones(region,
                                                           add_blank=False)

    def get_instance_type_choices(self):
        return self.ec2_choices_manager.instance_types(
            cloud_type=self.cloud_type, add_blank=False, add_description=False)

    @staticmethod
    def get_status_choices():
        return (
            ('running', 'Running'),
            ('pending', 'Pending'),
            ('stopping', 'Stopping'),
            ('stopped', 'Stopped'),
            ('shutting-down', 'Terminating'),
            ('terminated', 'Terminated'),
        )

    @staticmethod
    def get_root_device_type_choices():
        return (('ebs', 'EBS'), ('instance-store', 'Instance-store'))
コード例 #23
0
ファイル: forms.py プロジェクト: tedwardia/copr
class CoprDeleteForm(wtf.Form):
    verify = wtforms.TextField(
        "Confirm deleting by typing 'yes'",
        validators=[
            wtforms.validators.Required(),
            wtforms.validators.Regexp(
                r"^yes$",
                message="Type 'yes' - without the quotes, lowercase.")
        ])
コード例 #24
0
ファイル: event.py プロジェクト: rudimk/peopleflow
class WelcomeLogoForm(Form):
    welcome_logo = wtforms.TextField(
        'Welcome Screen Sponsor Logo',
        description=
        "Provide the URL for the image for the logo of the welcome screen sponsor.",
        validators=[
            wtforms.validators.Optional(),
            wtforms.validators.URL(message="Please provide a valid URL")
        ])
コード例 #25
0
class ProjectForm(ProjectFormSimplified):
    ''' Form to create or edit project. '''
    name = wtforms.TextField(
        'Project name <span class="error">*</span>',
        [
            wtforms.validators.Required(),
            wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE)
        ]
    )
コード例 #26
0
ファイル: forms.py プロジェクト: lybwb/mirrormanager2
class AddHostCountryForm(wtf.Form):
    """ Form to add or edit a host_country. """
    country = wtforms.TextField(
        'Country  <span class="error">*</span>',
        [
            wtforms.validators.Required(),
            wtforms.validators.Regexp(COUNTRY_REGEX, flags=re.IGNORECASE),
        ]
    )
コード例 #27
0
class ChrootForm(wtf.Form):
    """
    Validator for editing chroots in project
    (adding packages to minimal chroot)
    """

    buildroot_pkgs = wtforms.TextField("Packages")

    comps = FileField("comps_xml")
コード例 #28
0
class Login(flask.ext.wtf.Form):
    """
    User login form.
    """
    email = wtforms.TextField(
        validators=[wtforms.validators.Required(), wtforms.validators.Email()],
        description='Email address')
    password = wtforms.PasswordField(
        validators=[wtforms.validators.Required()], description='Password')
コード例 #29
0
class AddCollectionForm(wtforms.Form):
    title = wtforms.TextField(
        _('Title'),
        [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required()])
    description = wtforms.TextAreaField(
        _('Description of this collection'),
        description=_("""You can use
                      <a href="http://daringfireball.net/projects/markdown/basics">
                      Markdown</a> for formatting."""))
コード例 #30
0
class AddGroupForm(wtf.Form):
    ''' Form to add a group to a project. '''
    group = wtforms.TextField(
        'Group <span class="error">*</span>',
        [
            wtforms.validators.Required(),
            wtforms.validators.Regexp(STRICT_REGEX, flags=re.IGNORECASE)
        ]
    )