예제 #1
0
class ProfileForm(wtf.Form):

    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.EqualTo(
                                         'confirm',
                                         message='Passwords must match.')
                                 ])
    confirm = wtf.PasswordField('Repeat Password', validators=[wtf.Required()])
    name = wtf.TextField('Screen name',
                         validators=[wtf.Required(),
                                     wtf.Length(1, 45)])
    email = wtf.html5.EmailField('Email',
                                 validators=[wtf.Optional(),
                                             wtf.Email()])
    url = wtf.html5.URLField('Website', validators=[wtf.Optional(), wtf.URL()])
    submit = wtf.SubmitField('Save')
예제 #2
0
class SignUpForm(wtf.Form):

    login = wtf.TextField('Login name',
                          validators=[
                              wtf.Required(),
                              wtf.Length(2, 45),
                              wtf.Regexp(User.LOGIN_PATTERN)
                          ])
    password = wtf.PasswordField('Password',
                                 validators=[
                                     wtf.Required(),
                                     wtf.EqualTo(
                                         'confirm',
                                         message='Passwords must match.')
                                 ])
    confirm = wtf.PasswordField('Repeat Password', validators=[wtf.Required()])
    name = wtf.TextField('Screen name',
                         validators=[wtf.Required(),
                                     wtf.Length(1, 45)])
    email = wtf.html5.EmailField('Email',
                                 validators=[wtf.Optional(),
                                             wtf.Email()])
    url = wtf.html5.URLField('Website', validators=[wtf.Optional(), wtf.URL()])

    @classmethod
    def get_instance(cls, *args, **kwargs):
        if ('RECAPTCHA_PUBLIC_KEY' in current_app.config
                and 'RECAPTCHA_PRIVATE_KEY' in current_app.config):

            class SignUpForm_recaptcha(cls):
                recaptcha = wtf.RecaptchaField()
                submit = wtf.SubmitField('Sign up')

            return SignUpForm_recaptcha(*args, **kwargs)

        class SignUpForm_plain(cls):
            submit = wtf.SubmitField('Sign up')

        return SignUpForm_plain(*args, **kwargs)

    def validate_login(form, field):
        if g.session.query(User).filter_by(login=field.data).count():
            raise wtf.ValidationError('{0} is already taken.'.format(
                field.data))
예제 #3
0
class ProposalForm(wtf.Form):
    email = wtf.html5.EmailField('Your email address', validators=[wtf.Required()],
        description="An email address we can contact you at. "\
            "Not displayed anywhere")
    phone = wtf.TextField('Phone number', validators=[wtf.Required()],
        description="A phone number we can call you at to discuss your proposal, if required. "
            "Will not be displayed")
    speaking = wtf.RadioField("Are you speaking?", coerce=int,
        choices=[(1, u"I will be speaking"),
                 (0, u"I’m proposing a topic for someone to speak on")])
    title = wtf.TextField('Title', validators=[wtf.Required()],
        description="The title of your session")
    section = wtf.QuerySelectField('Section', get_label='title', validators=[wtf.Required()],
        widget=wtf.ListWidget(prefix_label=False), option_widget=wtf.RadioInput())
    objective = wtf.TextAreaField('Objective', validators=[wtf.Required()],
        description="What is the expected benefit for someone attending this?")
    session_type = wtf.RadioField('Session type', validators=[wtf.Required()], choices=[
        ('Lecture', 'Lecture'),
        ('Demo', 'Demo'),
        ('Tutorial', 'Tutorial'),
        ('Workshop', 'Workshop'),
        ('Discussion', 'Discussion'),
        ('Panel', 'Panel'),
        ])
    technical_level = wtf.RadioField('Technical level', validators=[wtf.Required()], choices=[
        ('Beginner', 'Beginner'),
        ('Intermediate', 'Intermediate'),
        ('Advanced', 'Advanced'),
        ])
    description = wtf.TextAreaField('Description', validators=[wtf.Required()],
        description="A detailed description of the session")
    requirements = wtf.TextAreaField('Requirements',
        description="For workshops, what must participants bring to the session?")
    slides = wtf.html5.URLField('Slides', validators=[wtf.Optional(), wtf.URL()],
        description="Link to your slides. These can be just an outline initially. "\
            "If you provide a Slideshare link, we'll embed slides in the page")
    links = wtf.TextAreaField('Links',
        description="Other links, one per line. Provide links to your profile and "\
            "slides and videos from your previous sessions; anything that'll help "\
            "folks decide if they want to attend your session")
    bio = wtf.TextAreaField('Speaker bio', validators=[wtf.Required()],
        description="Tell us why you are the best person to be taking this session")
예제 #4
0
파일: client.py 프로젝트: rugbash/lastuser
class RegisterClientForm(Form):
    """
    Register a new OAuth client application
    """
    title = wtf.TextField('Application title',
                          validators=[wtf.Required()],
                          description="The name of your application")
    description = wtf.TextAreaField(
        'Description',
        validators=[wtf.Required()],
        description="A description to help users recognize your application")
    client_owner = wtf.RadioField(
        'Owner',
        validators=[wtf.Required()],
        description=
        "User or organization that owns this application. Changing the owner "
        "will revoke all currently assigned permissions for this app")
    website = wtf.html5.URLField(
        'Application website',
        validators=[wtf.Required(), wtf.URL()],
        description="Website where users may access this application")
    redirect_uri = wtf.html5.URLField('Redirect URI',
                                      validators=[wtf.Optional(),
                                                  wtf.URL()],
                                      description="OAuth2 Redirect URI")
    notification_uri = wtf.html5.URLField(
        'Notification URI',
        validators=[wtf.Optional(), wtf.URL()],
        description=
        "Lastuser resource provider Notification URI. When another application requests access to "
        "resources provided by this app, Lastuser will post a notice to this URI with a copy of the access "
        "token that was provided to the other application. Other notices may be posted too "
        "(not yet implemented)")
    iframe_uri = wtf.html5.URLField(
        'IFrame URI',
        validators=[wtf.Optional(), wtf.URL()],
        description=
        "Front-end notifications URL. This is loaded in a hidden iframe to notify the app that the "
        "user updated their profile in some way (not yet implemented)")
    resource_uri = wtf.html5.URLField(
        'Resource URI',
        validators=[wtf.Optional(), wtf.URL()],
        description=
        "URI at which this application provides resources as per the Lastuser Resource API "
        "(not yet implemented)")
    allow_any_login = wtf.BooleanField(
        'Allow anyone to login',
        default=True,
        description=
        "If your application requires access to be restricted to specific users, uncheck this, "
        "and only users who have been assigned a permission to the app will be able to login"
    )
    team_access = wtf.BooleanField(
        'Requires access to teams',
        default=False,
        description=
        "If your application is capable of assigning access permissions to teams, check this. "
        "Organization owners will then able to grant access to teams in their organizations"
    )

    def validate_client_owner(self, field):
        if field.data == g.user.userid:
            self.user = g.user
            self.org = None
        else:
            orgs = [
                org for org in g.user.organizations_owned()
                if org.userid == field.data
            ]
            if len(orgs) != 1:
                raise wtf.ValidationError("Invalid owner")
            self.user = None
            self.org = orgs[0]
예제 #5
0
class EventForm(Form):
    title = wtf.TextField("Title",
                          description="Name of the Event",
                          validators=[
                              wtf.Required(),
                              wtf.NoneOf(values=["new"]),
                              wtf.validators.length(max=250)
                          ])
    name = wtf.TextField(
        "URL name",
        validators=[
            wtf.Optional(),
            ValidName(),
            AvailableName(u"There’s another event with the same name",
                          scoped=True),
            wtf.validators.length(max=250)
        ],
        description="URL identifier, leave blank to autogenerate")
    blurb = wtf.TextField(
        "Blurb",
        description="Single line blurb introducing the event",
        validators=[wtf.validators.length(max=250)])
    description = RichTextField(
        "Description",
        description="Detailed description of the event",
        content_css="/static/css/editor.css")
    apply_instructions = RichTextField(
        "Instructions for participants",
        description=
        "This will be shown to participants on the hacknight joining form",
        content_css="/static/css/editor.css")
    venue = wtf.QuerySelectField(
        "Venue",
        description=Markup(
            'Venue for this event (<a href="/venue/new">make new</a>)'),
        query_factory=lambda: Venue.query,
        get_label='title',
    )
    start_datetime = DateTimeField(
        "Start date/time",
        description="The date and time at which this event begins",
        validators=[wtf.Required()])
    end_datetime = DateTimeField(
        "End date/time",
        description="The date and time at which this event ends",
        validators=[wtf.Required()])
    ticket_price = wtf.TextField(
        "Ticket price",
        description="Entry fee, if any, to be paid at the venue",
        validators=[wtf.validators.length(max=250)])
    total_participants = wtf.IntegerField(
        "Venue capacity",
        description=
        "The number of people this venue can accommodate. Registrations will be closed after that. Use 0 to indicate unlimited capacity",
        default=50,
        validators=[wtf.Required()])
    website = wtf.html5.URLField(
        "Website",
        description="Related Website (Optional)",
        validators=[wtf.Optional(),
                    wtf.validators.length(max=250),
                    wtf.URL()])
    status = wtf.SelectField("Event status",
                             description="Current status of this hacknight",
                             coerce=int,
                             choices=STATUS_CHOICES)

    def validate_end_datetime(self, field):
        if field.data < self.start_datetime.data:
            raise wtf.ValidationError(
                u"Your event can’t end before it starts.")