Ticket #6588: allow_dots_in_usernames-1.patch.txt

File allow_dots_in_usernames-1.patch.txt, 2.8 KB (added by Torsten Bronger, 15 years ago)
Line 
1Index: django/core/validators.py
2===================================================================
3--- django/core/validators.py (revision 7104)
4+++ django/core/validators.py (working copy)
5@@ -23,6 +23,7 @@
6 _datere = r'\d{4}-\d{1,2}-\d{1,2}'
7 _timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
8 alnum_re = re.compile(r'^\w+$')
9+alnumdot_re = re.compile(r'^[\.\w]+$')
10 alnumurl_re = re.compile(r'^[-\w/]+$')
11 ansi_date_re = re.compile('^%s$' % _datere)
12 ansi_time_re = re.compile('^%s$' % _timere)
13@@ -67,6 +68,10 @@
14 def __str__(self):
15 return str(self.messages)
16
17+def isAlphaDotNumeric(field_data, all_data):
18+ if not alnumdot_re.search(field_data):
19+ raise ValidationError, "This value must contain only letters, dots, digits and underscores."
20+
21 def isAlphaNumeric(field_data, all_data):
22 if not alnum_re.search(field_data):
23 raise ValidationError, _("This value must contain only letters, numbers and underscores.")
24Index: django/contrib/auth/models.py
25===================================================================
26--- django/contrib/auth/models.py (revision 7104)
27+++ django/contrib/auth/models.py (working copy)
28@@ -128,7 +128,7 @@
29
30 Username and password are required. Other fields are optional.
31 """
32- username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
33+ username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaDotNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, dots, digits and underscores)."))
34 first_name = models.CharField(_('first name'), max_length=30, blank=True)
35 last_name = models.CharField(_('last name'), max_length=30, blank=True)
36 email = models.EmailField(_('e-mail address'), blank=True)
37Index: django/contrib/auth/forms.py
38===================================================================
39--- django/contrib/auth/forms.py (revision 7104)
40+++ django/contrib/auth/forms.py (working copy)
41@@ -11,7 +11,7 @@
42 def __init__(self):
43 self.fields = (
44 oldforms.TextField(field_name='username', length=30, max_length=30, is_required=True,
45- validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
46+ validator_list=[validators.isAlphaDotNumeric, self.isValidUsername]),
47 oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
48 oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
49 validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
Back to Top