Ticket #722: username.patch

File username.patch, 1.9 KB (added by david@…, 18 years ago)

Updates patch to M-R.

  • django/core/validators.py

     
    2929phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
    3030slug_re = re.compile(r'^[-\w]+$')
    3131url_re = re.compile(r'^https?://\S+$')
     32username_re = re.compile(r'^[-\w.@+]+$')
    3233
    3334lazy_inter = lazy(lambda a,b: str(a) % b, str)
    3435
     
    5859    def __str__(self):
    5960        return str(self.messages)
    6061
     62def isUserName(field_data, all_data):
     63    if not username_re.search(field_data):
     64        raise ValidationError, "This value must contain only letters, numbers and underscores, dashes, . and @."
     65
    6166def isAlphaNumeric(field_data, all_data):
    6267    if not alnum_re.search(field_data):
    6368        raise ValidationError, gettext("This value must contain only letters, numbers and underscores.")
  • django/contrib/auth/models.py

     
    8787
    8888    Username and password are required. Other fields are optional.
    8989    """
    90     username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
     90    username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isUserName], help_text=_("Required. 30 characters or fewer. Letters, digits, dash, period, @ and underscores."))
    9191    first_name = models.CharField(_('first name'), maxlength=30, blank=True)
    9292    last_name = models.CharField(_('last name'), maxlength=30, blank=True)
    9393    email = models.EmailField(_('e-mail address'), blank=True)
Back to Top