Пример #1
0
    def form_fields(self):
        context = self.context
        home_path_field = schemaish.String(
            validator=karlvalidators.PathExists(context),
            description=('The first page to show after logging in. '
                         'Leave blank to show a community or the '
                         'community list.'))
        password_field = schemaish.String(validator=(
            validator.All(karlvalidators.PasswordLength(min_pw_length()),
                          validator.Required())))
        fields = [('login', login_field), ('groups', groups_field),
                  ('home_path', home_path_field), ('password', password_field)]
        fields += super(AddUserFormController, self).form_fields()

        # Get rid of unique email address validation, because we need to do
        # that in the controller so we can manage whether or not email belongs
        # to deactivated user.
        email_field = schemaish.String(
            validator=validator.All(validator.Required(), validator.Email()))
        for i in xrange(len(fields)):
            if fields[i][0] == 'email':
                fields[i] = ('email', email_field)
                break

        return fields
Пример #2
0
    def form_fields(self):
        context = self.context
        home_path_field = schemaish.String(
            validator=karlvalidators.PathExists(context),
            description=('The first page to show after logging in. '
                         'Leave blank to show a community or the '
                         'community list.'))
        fields = []
        if self.user is not None:
            fields.append(('login', login_field))
            fields.append(('groups', groups_field))
        fields.append(('home_path', home_path_field))
        if self.is_staff:
            former_staff_action_field = schemaish.String(
                description='What action to take if user is no longer OSI '
                'Staff.')
            fields.insert(2,
                          ('former_staff_action', former_staff_action_field))
        elif self.user is not None:
            password_field = schemaish.String(
                validator=karlvalidators.PasswordLength(min_pw_length),
                title='Reset Password',
                description=('Enter a new password for the user here, '
                             'or leave blank to leave the password '
                             'unchanged.'))
            fields.insert(1, ('password', password_field))

        fields += super(AdminFCBase, self).form_fields()
        fields.append(('board', schemaish.String()))
        return fields
Пример #3
0
 def form_fields(self):
     context = self.context
     home_path_field = schemaish.String(
         validator=karlvalidators.PathExists(context),
         description=('The first page to show after logging in. '
                      'Leave blank to show a community or the '
                      'community list.'))
     if self.user is not None:
         password_field = schemaish.String(
             validator=karlvalidators.PasswordLength(min_pw_length()),
             title='Reset Password',
             description=('Enter a new password for the user here, '
                          'or leave blank to leave the password '
                          'unchanged.'))
         fields = [('login', login_field), ('groups', groups_field),
                   ('home_path', home_path_field),
                   ('password', password_field)]
     else:
         fields = [('home_path', home_path_field)]
     fields += super(AdminEditProfileFormController, self).form_fields()
     return fields