예제 #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
파일: people.py 프로젝트: iotest3/new
    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):
     min_pw_length = get_setting(None, 'min_pw_length')
     login_field = schemaish.String(validator=validator.Required())
     password_field = schemaish.String(validator=validator.All(
         validator.Required(),
         karlvalidators.PasswordLength(min_pw_length)),
                                       title='New Password')
     fields = [
         ('login', login_field),
         ('password', password_field),
     ]
     return fields
예제 #4
0
 def form_fields(self):
     users = find_users(self.context)
     userid = self.context.__name__
     user = users.get_by_id(userid)
     old_password_field = schemaish.String(
         title="Old Password",
         validator=validator.All(
             validator.Required(),
             karlvalidators.CorrectUserPassword(user),
         ))
     new_password_field = schemaish.String(
         title="New Password",
         validator=validator.All(
             karlvalidators.PasswordLength(min_pw_length()),
             validator.Required()))
     fields = [
         ('old_password', old_password_field),
         ('password', new_password_field),
     ]
     return fields
예제 #5
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