Exemple #1
0
class ParticipantForm(Form):
    skill_levels = [('Beginner', 'Beginner'), ('Intermediate', 'Intermediate'),
                    ('Advanced', 'Advanced')]

    reason_to_join = RichTextField(
        "Reason To Join",
        description="Why would you love to join Hacknight",
        validators=[wtf.Required()],
        content_css="/static/css/editor.css")
    phone_no = wtf.TextField(
        "Telephone No",
        description="Telephone No",
        validators=[wtf.Required(),
                    wtf.validators.length(max=15)])
    email = wtf.html5.EmailField(
        "Email",
        description="Email Address, We will never spam you .",
        validators=[wtf.Required(),
                    wtf.validators.length(max=80)])
    job_title = wtf.TextField(
        "Job Title",
        description="What is your job title? E.G: Senior Software "
        "Engineer at Awesome company",
        validators=[wtf.Optional(),
                    wtf.validators.length(max=120)])
    company = wtf.TextField(
        "Company",
        description="Company Name",
        validators=[wtf.Optional(),
                    wtf.validators.length(max=1200)])
    skill_level = wtf.RadioField("Skill Level",
                                 description="What is your skill level?",
                                 choices=skill_levels)
Exemple #2
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>.'))
Exemple #3
0
class VenueForm(Form):
    title = wtf.TextField("Name",
                          description="Name of the venue",
                          validators=[wtf.Required()])
    description = RichTextField("Notes",
                                description="Notes about the venue",
                                content_css="/static/css/editor.css")
    address1 = wtf.TextField("Address (line 1)", validators=[wtf.Required()])
    address2 = wtf.TextField("Address (line 2)", validators=[wtf.Optional()])
    city = wtf.TextField("City", validators=[wtf.Required()])
    state = wtf.TextField("State", validators=[wtf.Optional()])
    postcode = wtf.TextField("Post code", validators=[wtf.Optional()])
    country = wtf.SelectField("Country",
                              validators=[wtf.Required()],
                              choices=country_codes,
                              default="IN")
    latitude = wtf.DecimalField(
        "Latitude",
        places=None,
        validators=[wtf.Optional(), wtf.NumberRange(-90, 90)])
    longitude = wtf.DecimalField(
        "Longitude",
        places=None,
        validators=[wtf.Optional(), wtf.NumberRange(-180, 180)])
    profile_id = wtf.SelectField("Owner",
                                 description="The owner of this listing",
                                 coerce=int,
                                 validators=[wtf.Required()])
Exemple #4
0
class JenkinsConfigForm(wtf.Form):
    print_started = wtf.BooleanField(
        'Print Started',
        validators=[wtf.Optional()],
        default=False,
        description=('If checked, sends a message for every started job.'))

    print_completed = wtf.BooleanField(
        'Print Completed',
        validators=[wtf.Optional()],
        default=False,
        description=('If checked, sends a message for every completed job.'))

    print_finished = wtf.BooleanField(
        'Print Finished',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, sends a message for every finished job.'))

    omit_phase = wtf.BooleanField(
        'Omit Phase',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, does not add the job\'s current phase to the message. '
            'Recommended if only one of the above is checked.'))

    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, commit messages will include minor mIRC coloring.'))
Exemple #5
0
class JIRAConfigForm(wtf.Form):
    use_colors = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=True,
        description=('If checked, messages will include minor mIRC coloring.'))
    prefer_username = wtf.BooleanField(
        'Prefer Usernames',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'If checked, prefer displaying JIRA account names instead of'
            ' full names.'))
Exemple #6
0
class EventForm(Form):
    title = wtf.TextField(
        "Title",
        description="Name of the Event",
        validators=[wtf.Required(), wtf.NoneOf(values=["new"])])
    name = wtf.TextField(
        "URL name",
        validators=[
            wtf.Optional(),
            ValidName(),
            AvailableName(u"There’s another event with the same name")
        ],
        description="URL identifier, leave blank to autogenerate")
    blurb = wtf.TextField(
        "Blurb", description="Single line blurb introducing the event")
    description = RichTextField(
        "Description",
        description="Detailed description of the event",
        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")
    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.TextField("Website",
                            description="Related Website (Optional)",
                            validators=[wtf.Optional()])

    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.")
Exemple #7
0
class JenkinsConfigForm(wtf.Form):
    phase = wtf.SelectMultipleField('Phase',
        default=['finalized'],
        choices=[
            ('started', 'Started'),
            ('completed', 'Completed'),
            ('finalized', 'Finalized')
        ],
        description=(
            'Print messages for selected fields.'
    ))

    status = wtf.SelectMultipleField('Status',
        default=['success', 'unstable', 'failure'],
        choices=[
            ('success', 'Success'),
            ('unstable', 'Unstable'),
            ('failure', 'Failure')
        ],
        description=(
            'Print messages for selected fields.'
    ))

    use_colors = wtf.BooleanField('Use Colors', validators=[
        wtf.Optional()
    ], default=True, description=(
        'If checked, messages will include minor mIRC coloring.'
    ))
Exemple #8
0
class RegisterForm(Form):
    fullname = wtf.TextField('Full name', validators=[wtf.Required()])
    email = wtf.html5.EmailField('Email address',
                                 validators=[wtf.Required(),
                                             wtf.Email()])
    username = wtf.TextField('Username (optional)',
                             validators=[wtf.Optional()])
    password = wtf.PasswordField('Password', validators=[wtf.Required()])
    confirm_password = wtf.PasswordField(
        'Confirm password',
        validators=[wtf.Required(), wtf.EqualTo('password')])
    recaptcha = wtf.RecaptchaField(
        'Are you human?', description="Type both words into the text box")

    def validate_username(self, field):
        if field.data in RESERVED_USERNAMES:
            raise wtf.ValidationError, "That name is reserved"
        if not valid_username(field.data):
            raise wtf.ValidationError(
                u"Invalid characters in name. Names must be made of ‘a-z’, ‘0-9’ and ‘-’, without trailing dashes"
            )
        existing = User.query.filter_by(username=field.data).first()
        if existing is not None:
            raise wtf.ValidationError("That username is taken")

    def validate_email(self, field):
        existing = UserEmail.query.filter_by(email=field.data).first()
        if existing is not None:
            raise wtf.ValidationError(
                Markup(
                    'This email address is already registered. Do you want to <a href="%s">login</a> instead?'
                    % url_for('login')))
Exemple #9
0
class ContentForm(Form):
    previous_id = wtf.HiddenField(u"Previous revision")
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    name = wtf.TextField(u"URL name", validators=[wtf.Optional(), valid_name])
    description = wtf.TextAreaField(u"Summary",
                                    description=u"Summary of this page")
    content = RichTextField(u"Page content",
                            linkify=False,
                            buttons1=richtext_buttons1,
                            valid_elements=richtext_valid_elements,
                            sanitize_tags=richtext_sanitize_tags,
                            sanitize_attributes=richtext_sanitize_attributes)
    template = wtf.TextField(
        "Template",
        validators=[wtf.Required()],
        default='page.html',
        description=u"Template with which this page will be rendered.")
    properties = DictField(u"Properties")

    def validate_previous_id(self, field):
        if not field.data:
            field.data = None
        else:
            try:
                field.data = int(field.data)
            except ValueError:
                raise wtf.ValidationError("Unknown previous revision")

    def validate_name(self, field):
        # TODO
        pass
Exemple #10
0
class ExpenseForm(Form):
    """
    Create or edit an expense line item.
    """
    id = wtf.IntegerField(u"Id", validators=[wtf.Optional()])
    date = wtf.DateField(u"Date", validators=[wtf.Required()])
    category = wtf.QuerySelectField(u"Category",
                                    validators=[wtf.Required()],
                                    query_factory=sorted_categories,
                                    get_label='title',
                                    allow_blank=True)
    description = wtf.TextField(u"Description", validators=[wtf.Required()])
    amount = wtf.DecimalField(
        u"Amount", validators=[wtf.Required(),
                               wtf.NumberRange(min=0)])

    def validate_id(self, field):
        # Check if user is authorized to edit this expense.
        if field.data:
            expense = Expense.query.get(field.data)
            if not expense:
                raise wtf.ValidationError("Unknown expense")
            if expense.report.user != g.user:
                raise wtf.ValidationError(
                    "You are not authorized to edit this expense")

    def validate_amount(self, field):
        if field.data < Decimal('0.01'):
            raise wtf.ValidationError("Amount should be non-zero")
Exemple #11
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')
Exemple #12
0
class RedirectForm(Form):
    name = wtf.TextField(u"URL name", validators=[wtf.Optional(), valid_name])
    title = wtf.TextField(u"Title", validators=[wtf.Required()])
    redirect_url = wtf.TextField(u"Redirect URL", validators=[wtf.Required()])
    properties = DictField(u"Properties")

    def validate_name(self, field):
        # TODO
        pass
Exemple #13
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))
Exemple #14
0
class SponsorForm(Form):
    title = wtf.TextField("Title", description="Title of the project",
        validators=[wtf.Required("A title is required")])
    description = RichTextField(u"Description",
        description="Detailed description of your project", width="50%",
        content_css="/static/css/editor.css")
    website = wtf.html5.URLField("Home Page",
        description="URL to the home page", validators=[wtf.Optional()])
    image_url = wtf.html5.URLField("Image URL", description="URL to the image",
        validators=[wtf.Required("An image is required.")])
Exemple #15
0
class NewPaste(wtf.Form):
    text = wtf.TextField('uid') # honeypot field
    paste = wtf.TextAreaField('text', validators=[wtf.Required()])
    title = wtf.TextField('title', validators=[wtf.Optional()])
    password = wtf.PasswordField('password', validators=[wtf.Optional()])
    unlisted = wtf.BooleanField('Unlisted')
    submit = wtf.SubmitField('Paste')
    language = wtf.SelectField(
        'language',
        choices=[
            ('', ''),
            ('text', 'Text'),
            ('c', 'C'),
            ('csharp', 'C#'),
            ('cpp', 'C++'),
            ('css', 'CSS'),
            ('erlang', 'Erlang'),
            ('go', 'GO'),
            ('html', 'HTML'),
            ('java', 'Java'),
            ('javascript', 'Javascript'),
            ('json', 'JSON'),
            ('objectivec', 'Objective-C'),
            ('perl', 'Perl'),
            ('python', 'Python (2.X)'),
            ('python3', 'Python (3.X)'),
            ('pycon', 'Python Console'),
            ('pytb', 'Python 2 Traceback'),
            ('py3tb', 'Python 3 Traceback'),
            ('ruby', 'Ruby'),
            ('sql', 'SQL'),
            ('vbnet', 'VB.NET'),
        ]
    )

    def validate_uid(form, field):
        """
        This ensures the hidden honeypot field is left blank,
        only automated spambots should attempt to fill it in
        """
        if field.data != '':
            raise wtf.validators.ValidationError()
Exemple #16
0
class GithubConfigForm(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 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: 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.'))
    distinct_only = wtf.BooleanField(
        'Distinct Commits Only',
        validators=[wtf.Optional()],
        default=True,
        description=(
            'Commits will only be announced the first time they are seen.'))
Exemple #17
0
class EmailEventParticipantsForm(Form):
    pending_message = RichTextField(
        "Pending Message",
        description=
        "Message to be sent for pending participants. '*|FULLNAME|*' will be replaced with user's fullname.",
        validators=[wtf.Optional()])
    confirmation_message = RichTextField(
        "Confirmation Message",
        description=
        "Message to be sent for confirmed participants. '*|FULLNAME|*' will be replaced with user's fullname.",
        validators=[wtf.Optional()])
    rejected_message = RichTextField(
        "Rejected Message",
        description=
        "Message to be sent for rejected participants. '*|FULLNAME|*' will be replaced with user's fullname.",
        validators=[wtf.Optional()])
    waitlisted_message = RichTextField(
        "Waitlisted Message",
        description=
        "Message to be sent for waitlisted participants. '*|FULLNAME|*' will be replaced with user's fullname.",
        validators=[wtf.Optional()])
Exemple #18
0
class FolderForm(Form):
    name = wtf.TextField(
        u"URL name",
        validators=[wtf.Optional(), valid_name],
        description=u"Folder name as it appears in the URL (without slashes)")
    title = wtf.TextField(
        u"Title",
        description=u"Folder title, used in the per-folder blog feed")
    theme = wtf.SelectField(u"Theme")

    def validate_name(self, field):
        # TODO
        pass
Exemple #19
0
class ExpenseReportForm(Form):
    """
    Create or edit an expense report.
    """
    title = wtf.TextField(u"Title",
                          validators=[wtf.Required()],
                          description=u"What are these expenses for?")
    budget = wtf.QuerySelectField(
        u"Budget",
        validators=[wtf.Optional()],
        query_factory=sorted_budgets,
        get_label='title',
        allow_blank=True,
        description=u"The budget source for these expenses")
    currency = wtf.SelectField(
        u"Currency",
        validators=[wtf.Required()],
        description=u"Currency for expenses in this report",
        choices=CURRENCIES)
    description = RichTextField(u"Description",
                                validators=[wtf.Optional()],
                                description=u"Notes on the expenses")
Exemple #20
0
class PlaylistForm(Form):
    title = wtf.TextField(u"Title",
                          validators=[wtf.Required()],
                          description=u"The name of your playlist")
    short_title = wtf.TextField(
        u"Short title",
        validators=[wtf.Optional()],
        description=
        u"Shorter title, displayed next to the channel's name when viewing a video"
    )
    name = wtf.TextField(
        u"URL Name",
        validators=[wtf.Optional()],
        description=u"Optional. Will be automatically generated if left blank")
    description = RichTextField(u"Description")
    recorded_date = wtf.DateField(
        u"Recorded date",
        validators=[wtf.Optional()],
        description=
        u"Date on which the videos in this playlist were recorded, if applicable"
    )
    published_date = wtf.DateField(
        u"Published date",
        validators=[wtf.Required()],
        default=date.today(),
        description=u"Date on which this playlist was created or made public")
    public = wtf.BooleanField(u"This playlist is public", default=True)

    def validate_name(self, field):
        if invalid_name.search(field.data):
            raise wtf.ValidationError(
                "The name cannot have spaces or non-alphanumeric characters")
        existing = Playlist.query.filter_by(channel=self.channel,
                                            name=field.data).first()
        if existing and existing.id != self.edit_id:
            raise wtf.ValidationError("That name is already in use")
Exemple #21
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 #22
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")
class ParticipantForm(Form):
    reason_to_join = RichTextField(
        "Reason To Join",
        description="Why would you love to join Hacknight",
        validators=[wtf.Required()],
        content_css="/static/css/editor.css")
    phone_no = wtf.TextField("Telephone No",
                             description="Telephone No",
                             validators=[wtf.Required()])
    email = wtf.html5.EmailField(
        "Email",
        description="Email Address, We will never spam you .",
        validators=[wtf.Required()])
    job_title = wtf.TextField(
        "Job Title",
        description="What is your job title? E.G: Senior Software "
        "Engineer at Awesome company",
        validators=[wtf.Required()])
    company = wtf.TextField("Company",
                            description="Company Name",
                            validators=[wtf.Optional()])
Exemple #24
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 #25
0
class SignInForm(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()])
    return_url = wtf.HiddenField(validators=[wtf.Optional()])
    submit = wtf.SubmitField('Login')

    def validate_login(form, field):
        if g.session.query(User).filter_by(login=field.data).count() < 1:
            raise wtf.ValidationError('There is no {0}.'.format(field.data))

    def validate_password(form, field):
        try:
            user = g.session.query(User).filter_by(login=form.login.data)[0]
        except IndexError:
            pass
        else:
            if user.password != field.data:
                raise wtf.ValidationError('Incorrect password.')
Exemple #26
0
class PlainTextConfigForm(wtf.Form):
    use_colours = wtf.BooleanField(
        'Use Colors',
        validators=[wtf.Optional()],
        default=False,
        description=('If checked, messages will include mIRC colouring.'))
Exemple #27
0
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]
Exemple #28
0
class VideoSlidesForm(Form):
    slides_url = wtf.html5.URLField(u"Slides URL", validators=[wtf.Optional()])
Exemple #29
0
class VideoAddForm(Form):
    video_url = wtf.html5.URLField(u"Video URL", validators=[wtf.Required()])
    slides_url = wtf.html5.URLField(u"Slides URL", validators=[wtf.Optional()])
Exemple #30
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.'))