Beispiel #1
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.'
    ))
Beispiel #2
0
class UserUpdateForm(wtf.Form):
  username = wtf.StringField('Username',
      [wtf.validators.required(), wtf.validators.length(min=3)],
      filters=[util.email_filter],
    )
  name = wtf.StringField('Name',
      [wtf.validators.required()], filters=[util.strip_filter],
    )
  email = wtf.StringField('Email',
      [wtf.validators.optional(), wtf.validators.email()],
      filters=[util.email_filter],
    )
  admin = wtf.BooleanField('Admin')
  active = wtf.BooleanField('Active')
  permissions = wtf.SelectMultipleField('Permissions',
      filters=[util.sort_filter],
    )

  _permission_choices = set()

  def __init__(self, *args, **kwds):
    super(UserUpdateForm, self).__init__(*args, **kwds)
    self.permissions.choices = [
        (p, p) for p in sorted(UserUpdateForm._permission_choices)
      ]

  @auth.permission_registered.connect
  def _permission_registered_callback(sender, permission):
    UserUpdateForm._permission_choices.add(permission)
Beispiel #3
0
class TeamPermissionAssignForm(Form):
    """
    Assign permissions to a team
    """
    team_id = wtf.RadioField(
        "Team",
        validators=[wtf.Required()],
        description='Select a team to assign permissions to')
    perms = wtf.SelectMultipleField("Permissions", validators=[wtf.Required()])

    def validate_team_id(self, field):
        teams = [team for team in self.org.teams if team.userid == field.data]
        if len(teams) != 1:
            raise wtf.ValidationError("Unknown team")
        self.team = teams[0]
Beispiel #4
0
class UserPermissionAssignForm(Form):
    """
    Assign permissions to a user
    """
    username = wtf.TextField(
        "User",
        validators=[wtf.Required()],
        description='Lookup a user by their username or email address')
    perms = wtf.SelectMultipleField("Permissions", validators=[wtf.Required()])

    def validate_username(self, field):
        existing = getuser(field.data)
        if existing is None:
            raise wtf.ValidationError("User does not exist")
        self.user = existing
Beispiel #5
0
class ClientTeamAccessForm(Form):
    """
    Select organizations that the client has access to the teams of
    """
    organizations = wtf.SelectMultipleField('Organizations')
Beispiel #6
0
class PermissionEditForm(Form):
    """
    Edit a user or team's permissions
    """
    perms = wtf.SelectMultipleField("Permissions", validators=[wtf.Required()])