Apply django changeset 12634 to our copy, to permit usernames containing '@'. See http://code.djangoproject.com/changeset/12634 .
- Legacy-Id: 2049
This commit is contained in:
parent
081f170b20
commit
86605a0d91
|
@ -11,9 +11,9 @@ class UserCreationForm(forms.ModelForm):
|
|||
"""
|
||||
A form that creates a user, with no privileges, from the given username and password.
|
||||
"""
|
||||
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
|
||||
help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
|
||||
error_message = _("This value must contain only letters, numbers and underscores."))
|
||||
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
|
||||
help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
|
||||
error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
|
||||
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
|
||||
password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput)
|
||||
|
||||
|
@ -44,9 +44,9 @@ class UserCreationForm(forms.ModelForm):
|
|||
return user
|
||||
|
||||
class UserChangeForm(forms.ModelForm):
|
||||
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
|
||||
help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
|
||||
error_message = _("This value must contain only letters, numbers and underscores."))
|
||||
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
|
||||
help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
|
||||
error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
|
|
|
@ -125,7 +125,7 @@ class User(models.Model):
|
|||
|
||||
Username and password are required. Other fields are optional.
|
||||
"""
|
||||
username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
|
||||
username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
|
||||
first_name = models.CharField(_('first name'), max_length=30, blank=True)
|
||||
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
||||
email = models.EmailField(_('e-mail address'), blank=True)
|
||||
|
|
|
@ -21,7 +21,7 @@ False
|
|||
# The username contains invalid data.
|
||||
|
||||
>>> data = {
|
||||
... 'username': 'jsmith@example.com',
|
||||
... 'username': 'jsmith!',
|
||||
... 'password1': 'test123',
|
||||
... 'password2': 'test123',
|
||||
... }
|
||||
|
@ -29,7 +29,7 @@ False
|
|||
>>> form.is_valid()
|
||||
False
|
||||
>>> form["username"].errors
|
||||
[u'This value must contain only letters, numbers and underscores.']
|
||||
[u'This value may contain only letters, numbers and @/./+/-/_ characters.']
|
||||
|
||||
# The verification password is incorrect.
|
||||
|
||||
|
@ -65,7 +65,7 @@ False
|
|||
# The success case.
|
||||
|
||||
>>> data = {
|
||||
... 'username': 'jsmith2',
|
||||
... 'username': 'jsmith2@example.com',
|
||||
... 'password1': 'test123',
|
||||
... 'password2': 'test123',
|
||||
... }
|
||||
|
@ -73,7 +73,7 @@ False
|
|||
>>> form.is_valid()
|
||||
True
|
||||
>>> form.save()
|
||||
<User: jsmith2>
|
||||
<User: jsmith2@example.com>
|
||||
|
||||
# The user submits an invalid username.
|
||||
|
||||
|
@ -189,7 +189,7 @@ True
|
|||
>>> form.is_valid()
|
||||
False
|
||||
>>> form['username'].errors
|
||||
[u'This value must contain only letters, numbers and underscores.']
|
||||
[u'This value may contain only letters, numbers and @/./+/-/_ characters.']
|
||||
|
||||
|
||||
### PasswordResetForm
|
||||
|
|
76
django/django-changeset-12634.patch
Normal file
76
django/django-changeset-12634.patch
Normal file
|
@ -0,0 +1,76 @@
|
|||
Index: django/contrib/auth/tests/forms.py
|
||||
===================================================================
|
||||
--- django/contrib/auth/tests/forms.py (revision 9906)
|
||||
+++ django/contrib/auth/tests/forms.py (revision 12634)
|
||||
@@ -22,5 +22,5 @@
|
||||
|
||||
>>> data = {
|
||||
-... 'username': 'jsmith@example.com',
|
||||
+... 'username': 'jsmith!',
|
||||
... 'password1': 'test123',
|
||||
... 'password2': 'test123',
|
||||
@@ -30,5 +30,5 @@
|
||||
False
|
||||
>>> form["username"].errors
|
||||
-[u'This value must contain only letters, numbers and underscores.']
|
||||
+[u'This value may contain only letters, numbers and @/./+/-/_ characters.']
|
||||
|
||||
# The verification password is incorrect.
|
||||
@@ -66,5 +66,5 @@
|
||||
|
||||
>>> data = {
|
||||
-... 'username': 'jsmith2',
|
||||
+... 'username': 'jsmith2@example.com',
|
||||
... 'password1': 'test123',
|
||||
... 'password2': 'test123',
|
||||
@@ -74,5 +74,5 @@
|
||||
True
|
||||
>>> form.save()
|
||||
-<User: jsmith2>
|
||||
+<User: jsmith2@example.com>
|
||||
|
||||
# The user submits an invalid username.
|
||||
@@ -190,5 +190,5 @@
|
||||
False
|
||||
>>> form['username'].errors
|
||||
-[u'This value must contain only letters, numbers and underscores.']
|
||||
+[u'This value may contain only letters, numbers and @/./+/-/_ characters.']
|
||||
|
||||
|
||||
Index: django/contrib/auth/models.py
|
||||
===================================================================
|
||||
--- django/contrib/auth/models.py (revision 12506)
|
||||
+++ django/contrib/auth/models.py (revision 12634)
|
||||
@@ -178,5 +178,5 @@
|
||||
Username and password are required. Other fields are optional.
|
||||
"""
|
||||
- username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
|
||||
+ username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
|
||||
first_name = models.CharField(_('first name'), max_length=30, blank=True)
|
||||
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
||||
Index: django/contrib/auth/forms.py
|
||||
===================================================================
|
||||
--- django/contrib/auth/forms.py (revision 12218)
|
||||
+++ django/contrib/auth/forms.py (revision 12634)
|
||||
@@ -12,7 +12,7 @@
|
||||
A form that creates a user, with no privileges, from the given username and password.
|
||||
"""
|
||||
- username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
|
||||
- help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
|
||||
- error_message = _("This value must contain only letters, numbers and underscores."))
|
||||
+ username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
|
||||
+ help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
|
||||
+ error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
|
||||
password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput)
|
||||
password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput,
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
class UserChangeForm(forms.ModelForm):
|
||||
- username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
|
||||
- help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
|
||||
- error_message = _("This value must contain only letters, numbers and underscores."))
|
||||
+ username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$',
|
||||
+ help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."),
|
||||
+ error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters."))
|
||||
|
||||
class Meta:
|
Loading…
Reference in a new issue