Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit fc36ba4

Browse files
committed
call it "username" because that's what it is (bug 698064)
1 parent dcae44a commit fc36ba4

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

apps/amo/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,16 @@ def slugify(s, ok=SLUG_OK, lower=True, spaces=False, delimiter='-'):
298298
return new.lower() if lower else new
299299

300300

301-
def slug_validator(s, ok=SLUG_OK, lower=True, spaces=False, delimiter='-'):
301+
def slug_validator(s, ok=SLUG_OK, lower=True, spaces=False, delimiter='-',
302+
message=validate_slug.message, code=validate_slug.code):
302303
"""
303304
Raise an error if the string has any punctuation characters.
304305
305306
Regexes don't work here because they won't check alnums in the right
306307
locale.
307308
"""
308309
if not (s and slugify(s, ok, lower, spaces, delimiter) == s):
309-
raise ValidationError(validate_slug.message,
310-
code=validate_slug.code)
310+
raise ValidationError(message, code=code)
311311

312312

313313
def raise_required():

apps/users/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ class UsernameMixin:
157157

158158
def clean_username(self):
159159
name = self.cleaned_data['username']
160-
slug_validator(name, lower=False)
160+
slug_validator(name, lower=False,
161+
message=_('Enter a valid username consisting of letters, numbers, '
162+
'underscores or hyphens.'))
161163
if BlacklistedUsername.blocked(name):
162164
raise forms.ValidationError(_('This username cannot be used.'))
163165
return name

apps/users/tests/test_forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from django.contrib.auth.models import User
44
from django.contrib.auth.tokens import default_token_generator
55
from django.core import mail
6-
from django.core.validators import validate_slug
76
from django.utils.http import int_to_base36
87

98
from django.conf import settings
@@ -399,7 +398,9 @@ def test_invalid_username(self):
399398
'password2': 'xxxlonger',
400399
'username': 'Todd/Rochelle', }
401400
r = self.client.post('/en-US/firefox/users/register', data)
402-
self.assertFormError(r, 'form', 'username', validate_slug.message)
401+
self.assertFormError(r, 'form', 'username',
402+
'Enter a valid username consisting of letters, numbers, '
403+
'underscores or hyphens.')
403404

404405
def test_blacklisted_username(self):
405406
data = {'email': 'testo@example.com',

0 commit comments

Comments
 (0)