Commit bca79a5e authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents ede6b5db 994bb972
......@@ -79,6 +79,7 @@ class UsernameField(forms.RegexField):
'numbers and following characters: @ . + - _'
)
}
kwargs['required'] = True
self.valid = None
super(UsernameField, self).__init__(*args, **kwargs)
......@@ -87,16 +88,17 @@ class UsernameField(forms.RegexField):
'''
Username validation, requires length of five chars and unique.
'''
existing = User.objects.filter(
username__iexact=value
)
if existing.exists() and value != self.valid:
raise forms.ValidationError(
_(
'This username is already taken. '
'Please choose another.'
)
if value is not None:
existing = User.objects.filter(
username__iexact=value
)
if existing.exists() and value != self.valid:
raise forms.ValidationError(
_(
'This username is already taken. '
'Please choose another.'
)
)
return super(UsernameField, self).clean(value)
......
......@@ -293,6 +293,7 @@ class ProfileTest(ViewTestCase):
'first_name': 'First',
'last_name': 'Last',
'email': 'noreply@weblate.org',
'username': 'testik',
}
)
self.assertRedirects(response, reverse('profile'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment