Ticket #722: username_re.patch

File username_re.patch, 1.5 KB (added by ian@…, 19 years ago)

patch to allow less restrictive usernames

  • core/validators.py

     
    2323phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
    2424slug_re = re.compile(r'^[-\w]+$')
    2525url_re = re.compile(r'^http://\S+$')
     26username_re = re.compile(r'^[-\w.@+]+$')
    2627
    2728from django.conf.settings import JING_PATH
    2829
     
    5253    def __str__(self):
    5354        return str(self.messages)
    5455
     56def isUserName(field_data, all_data):
     57    if not username_re.search(field_data):
     58        raise ValidationError, "This value must contain only letters, numbers and underscores, dashes, and @."
     59
    5560def isAlphaNumeric(field_data, all_data):
    5661    if not alnum_re.search(field_data):
    5762        raise ValidationError, "This value must contain only letters, numbers and underscores."
  • models/auth.py

     
    2525        return self.name
    2626
    2727class User(meta.Model):
    28     username = meta.CharField(maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric])
     28    username = meta.CharField(maxlength=30, unique=True, validator_list=[validators.isUserName])
    2929    first_name = meta.CharField(maxlength=30, blank=True)
    3030    last_name = meta.CharField(maxlength=30, blank=True)
    3131    email = meta.EmailField('e-mail address', blank=True)
Back to Top