@@ -182,14 +182,15 @@ class ValidPassword(formencode.validator
return value
class ValidPasswordsMatch(formencode.validators.FancyValidator):
def validate_python(self, value, state):
if value['password'] != value['password_confirmation']:
pass_val = value.get('password') or value.get('new_password')
if pass_val != value['password_confirmation']:
e_dict = {'password_confirmation':
_('Passwords do not match')}
raise formencode.Invalid('', value, state, error_dict=e_dict)
class ValidAuth(formencode.validators.FancyValidator):
messages = {
@@ -494,33 +495,34 @@ class LoginForm(formencode.Schema):
not_empty=True,
messages={
'empty':_('Please enter a password'),
'tooShort':_('Enter %(min)i characters or more')}
)
#chained validators have access to all data
chained_validators = [ValidAuth]
def UserForm(edit=False, old_data={}):
class _UserForm(formencode.Schema):
allow_extra_fields = True
filter_extra_fields = True
username = All(UnicodeString(strip=True, min=1, not_empty=True),
ValidUsername(edit, old_data))
if edit:
new_password = All(UnicodeString(strip=True, min=6, not_empty=False))
password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=False))
admin = StringBoolean(if_missing=False)
else:
password = All(UnicodeString(strip=True, min=6, not_empty=True))
active = StringBoolean(if_missing=False)
name = UnicodeString(strip=True, min=1, not_empty=True)
lastname = UnicodeString(strip=True, min=1, not_empty=True)
email = All(Email(not_empty=True), UniqSystemEmail(old_data))
chained_validators = [ValidPassword]
chained_validators = [ValidPasswordsMatch, ValidPassword]
return _UserForm
def UsersGroupForm(edit=False, old_data={}, available_members=[]):
class _UsersGroupForm(formencode.Schema):
@@ -41,13 +41,22 @@
<label for="password">${_('Password')}:</label>
</div>
<div class="input">
${h.password('password',class_='small')}
<div class="field">
<div class="label">
<label for="password_confirmation">${_('Password confirmation')}:</label>
${h.password('password_confirmation',class_="small",autocomplete="off")}
<label for="name">${_('First Name')}:</label>
${h.text('name',class_='small')}
@@ -65,13 +65,22 @@
<label for="new_password">${_('New password')}:</label>
${h.password('new_password',class_='medium',autocomplete="off")}
<label for="password_confirmation">${_('New password confirmation')}:</label>
${h.password('password_confirmation',class_="medium",autocomplete="off")}
${h.text('name',class_='medium')}
@@ -54,13 +54,22 @@
${h.password('new_password',class_="medium",autocomplete="off")}
${h.text('name',class_="medium")}
@@ -151,16 +160,18 @@
${h.submit('remove_%s' % repo['name'],'',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
${h.end_form()}
</td>
</tr>
%endfor
%else:
<div style="padding:5px 0px 10px 0px;">
${_('No repositories yet')}
%if h.HasPermissionAny('hg.admin','hg.create.repository')():
${h.link_to(_('create one now'),h.url('admin_settings_create_repository'))}
${h.link_to(_('create one now'),h.url('admin_settings_create_repository'),class_="ui-button-small")}
%endif
</tbody>
</table>
@@ -134,12 +134,13 @@ class TestAdminSettingsController(TestCo
response = self.app.post(url('admin_settings_my_account_update'),
params=dict(_method='put',
username='test_admin',
new_password=new_password,
password_confirmation = new_password,
password='',
name=new_name,
lastname=new_lastname,
email=new_email,))
response.follow()
@@ -157,12 +158,13 @@ class TestAdminSettingsController(TestCo
old_password = 'test12'
response = self.app.post(url('admin_settings_my_account_update'), params=dict(
_method='put',
new_password=old_password,
password_confirmation = old_password,
name=old_name,
lastname=old_lastname,
email=old_email,))
@@ -183,12 +185,13 @@ class TestAdminSettingsController(TestCo
new_email = 'test_regular@mail.com'#already exisitn email
new_password='test12',
password_confirmation = 'test122',
name='NewName',
lastname='NewLastname',
assert 'This e-mail address is already taken' in response.body, 'Missing error message about existing email'
@@ -198,11 +201,12 @@ class TestAdminSettingsController(TestCo
new_email = 'newmail.pl'
assert 'An email address must contain a single @' in response.body, 'Missing error message about wrong email'
assert 'This username already exists' in response.body, 'Missing error message about existing user'
@@ -13,18 +13,20 @@ class TestAdminUsersController(TestContr
response = self.app.get(url('formatted_users', format='xml'))
def test_create(self):
self.log_user()
username = 'newtestuser'
password = 'test12'
password_confirmation = password
name = 'name'
lastname = 'lastname'
email = 'mail@mail.com'
response = self.app.post(url('users'), {'username':username,
'password':password,
'password_confirmation':password_confirmation,
'name':name,
'active':True,
'lastname':lastname,
'email':email})
@@ -87,12 +89,13 @@ class TestAdminUsersController(TestContr
email = 'todeletemail@mail.com'
'password_confirmation':password,
response = response.follow()
Status change: