diff -uNr --exclude=.svn django-trunk/django/contrib/auth/forms.py django-5786/django/contrib/auth/forms.py
|
old
|
new
|
|
| 11 | 11 | """ |
| 12 | 12 | A form that creates a user, with no privileges, from the given username and password. |
| 13 | 13 | """ |
| 14 | | username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$', |
| 15 | | help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."), |
| 16 | | error_message = _("This value must contain only letters, numbers and underscores.")) |
| | 14 | username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$', |
| | 15 | help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."), |
| | 16 | error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters.")) |
| 17 | 17 | password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput) |
| 18 | 18 | password2 = forms.CharField(label=_("Password confirmation"), widget=forms.PasswordInput, |
| 19 | 19 | help_text = _("Enter the same password as above, for verification.")) |
| … |
… |
|
| 45 | 45 | return user |
| 46 | 46 | |
| 47 | 47 | class UserChangeForm(forms.ModelForm): |
| 48 | | username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$', |
| 49 | | help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."), |
| 50 | | error_message = _("This value must contain only letters, numbers and underscores.")) |
| | 48 | username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^[\w.@+-]+$', |
| | 49 | help_text = _("Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only."), |
| | 50 | error_message = _("This value may contain only letters, numbers and @/./+/-/_ characters.")) |
| 51 | 51 | |
| 52 | 52 | class Meta: |
| 53 | 53 | model = User |
diff -uNr --exclude=.svn django-trunk/django/contrib/auth/models.py django-5786/django/contrib/auth/models.py
|
old
|
new
|
|
| 177 | 177 | |
| 178 | 178 | Username and password are required. Other fields are optional. |
| 179 | 179 | """ |
| 180 | | username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores).")) |
| | 180 | username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters")) |
| 181 | 181 | first_name = models.CharField(_('first name'), max_length=30, blank=True) |
| 182 | 182 | last_name = models.CharField(_('last name'), max_length=30, blank=True) |
| 183 | 183 | email = models.EmailField(_('e-mail address'), blank=True) |
diff -uNr --exclude=.svn django-trunk/django/contrib/auth/tests/forms.py django-5786/django/contrib/auth/tests/forms.py
|
old
|
new
|
|
| 21 | 21 | # The username contains invalid data. |
| 22 | 22 | |
| 23 | 23 | >>> data = { |
| 24 | | ... 'username': 'jsmith@example.com', |
| | 24 | ... 'username': 'jsmith!', |
| 25 | 25 | ... 'password1': 'test123', |
| 26 | 26 | ... 'password2': 'test123', |
| 27 | 27 | ... } |
| … |
… |
|
| 29 | 29 | >>> form.is_valid() |
| 30 | 30 | False |
| 31 | 31 | >>> form["username"].errors |
| 32 | | [u'This value must contain only letters, numbers and underscores.'] |
| | 32 | [u'This value may contain only letters, numbers and @/./+/-/_ characters.'] |
| 33 | 33 | |
| 34 | 34 | # The verification password is incorrect. |
| 35 | 35 | |
| … |
… |
|
| 65 | 65 | # The success case. |
| 66 | 66 | |
| 67 | 67 | >>> data = { |
| 68 | | ... 'username': 'jsmith2', |
| | 68 | ... 'username': 'jsmith2@example.com', |
| 69 | 69 | ... 'password1': 'test123', |
| 70 | 70 | ... 'password2': 'test123', |
| 71 | 71 | ... } |
| … |
… |
|
| 73 | 73 | >>> form.is_valid() |
| 74 | 74 | True |
| 75 | 75 | >>> form.save() |
| 76 | | <User: jsmith2> |
| | 76 | <User: jsmith2@example.com> |
| 77 | 77 | |
| 78 | 78 | # The user submits an invalid username. |
| 79 | 79 | |
| … |
… |
|
| 189 | 189 | >>> form.is_valid() |
| 190 | 190 | False |
| 191 | 191 | >>> form['username'].errors |
| 192 | | [u'This value must contain only letters, numbers and underscores.'] |
| | 192 | [u'This value may contain only letters, numbers and @/./+/-/_ characters.'] |
| 193 | 193 | |
| 194 | 194 | |
| 195 | 195 | ### PasswordResetForm |