Commit af158c9a4ed923385a51b827856e48fc32399a36
1 parent
7b200a81
Exists in
master
and in
39 other branches
Changing validation of username
Showing
1 changed file
with
11 additions
and
0 deletions
Show diff stats
src/accounts/models.py
@@ -5,7 +5,9 @@ import urlparse | @@ -5,7 +5,9 @@ import urlparse | ||
5 | from django.db import models, DatabaseError | 5 | from django.db import models, DatabaseError |
6 | from django.contrib.auth.hashers import check_password | 6 | from django.contrib.auth.hashers import check_password |
7 | from django.contrib.auth.models import AbstractUser | 7 | from django.contrib.auth.models import AbstractUser |
8 | +from django.core import validators | ||
8 | from django.core.urlresolvers import reverse | 9 | from django.core.urlresolvers import reverse |
10 | +from django.utils.translation import ugettext_lazy as _ | ||
9 | 11 | ||
10 | from conversejs import xmpp | 12 | from conversejs import xmpp |
11 | 13 | ||
@@ -50,3 +52,12 @@ class User(AbstractUser): | @@ -50,3 +52,12 @@ class User(AbstractUser): | ||
50 | # The following workaroud allows to change email field to unique | 52 | # The following workaroud allows to change email field to unique |
51 | # without having to rewrite all AbstractUser here | 53 | # without having to rewrite all AbstractUser here |
52 | User._meta.get_field('email')._unique = True | 54 | User._meta.get_field('email')._unique = True |
55 | +User._meta.get_field('username').help_text = _( | ||
56 | + u'Required. 30 characters or fewer. Letters, digits and ' | ||
57 | + u'./+/-/_ only.' | ||
58 | +) | ||
59 | +User._meta.get_field('username').validators[0] = validators.RegexValidator( | ||
60 | + r'^[\w.+-]+$', | ||
61 | + _('Enter a valid username.'), | ||
62 | + 'invalid' | ||
63 | +) |