Ticket #6588: allow_dots_in_usernames-1.patch

File allow_dots_in_usernames-1.patch, 2.8 KB (added by Torsten Bronger, 16 years ago)
  • django/core/validators.py

     
    2323_datere = r'\d{4}-\d{1,2}-\d{1,2}'
    2424_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
    2525alnum_re = re.compile(r'^\w+$')
     26alnumdot_re = re.compile(r'^[\.\w]+$')
    2627alnumurl_re = re.compile(r'^[-\w/]+$')
    2728ansi_date_re = re.compile('^%s$' % _datere)
    2829ansi_time_re = re.compile('^%s$' % _timere)
     
    6768    def __str__(self):
    6869        return str(self.messages)
    6970
     71def isAlphaDotNumeric(field_data, all_data):
     72    if not alnumdot_re.search(field_data):
     73        raise ValidationError, "This value must contain only letters, dots, digits and underscores."
     74
    7075def isAlphaNumeric(field_data, all_data):
    7176    if not alnum_re.search(field_data):
    7277        raise ValidationError, _("This value must contain only letters, numbers and underscores.")
  • django/contrib/auth/models.py

     
    128128
    129129    Username and password are required. Other fields are optional.
    130130    """
    131     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)."))
     131    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)."))
    132132    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    133133    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    134134    email = models.EmailField(_('e-mail address'), blank=True)
  • django/contrib/auth/forms.py

     
    1111    def __init__(self):
    1212        self.fields = (
    1313            oldforms.TextField(field_name='username', length=30, max_length=30, is_required=True,
    14                 validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
     14                validator_list=[validators.isAlphaDotNumeric, self.isValidUsername]),
    1515            oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
    1616            oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
    1717                validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
Back to Top