Ticket #722: username_re.patch
File username_re.patch, 1.5 KB (added by , 19 years ago) |
---|
-
core/validators.py
23 23 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE) 24 24 slug_re = re.compile(r'^[-\w]+$') 25 25 url_re = re.compile(r'^http://\S+$') 26 username_re = re.compile(r'^[-\w.@+]+$') 26 27 27 28 from django.conf.settings import JING_PATH 28 29 … … 52 53 def __str__(self): 53 54 return str(self.messages) 54 55 56 def 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 55 60 def isAlphaNumeric(field_data, all_data): 56 61 if not alnum_re.search(field_data): 57 62 raise ValidationError, "This value must contain only letters, numbers and underscores." -
models/auth.py
25 25 return self.name 26 26 27 27 class User(meta.Model): 28 username = meta.CharField(maxlength=30, unique=True, validator_list=[validators.is AlphaNumeric])28 username = meta.CharField(maxlength=30, unique=True, validator_list=[validators.isUserName]) 29 29 first_name = meta.CharField(maxlength=30, blank=True) 30 30 last_name = meta.CharField(maxlength=30, blank=True) 31 31 email = meta.EmailField('e-mail address', blank=True)