summaryrefslogtreecommitdiff
path: root/exam
diff options
context:
space:
mode:
authorPrabhu Ramachandran2011-11-19 08:38:13 +0530
committerPrabhu Ramachandran2011-11-19 08:38:13 +0530
commit6fcc55a442d52c251408566f6bc924b15cef0bb3 (patch)
treed356677a0da1db3732693b487fea73d27a9c3fd7 /exam
parent7e370f3017572fb202d48a9ca884bfd7d3880d63 (diff)
downloadonline_test-6fcc55a442d52c251408566f6bc924b15cef0bb3.tar.gz
online_test-6fcc55a442d52c251408566f6bc924b15cef0bb3.tar.bz2
online_test-6fcc55a442d52c251408566f6bc924b15cef0bb3.zip
ENH: Fixing login/registration forms and uname/pwd
The login and registration forms are now rendered as tables which looks much nicer. The username now can take letters, digits, period and underscore. The password can take letters, digits and punctuation.
Diffstat (limited to 'exam')
-rw-r--r--exam/forms.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/exam/forms.py b/exam/forms.py
index 38466e8..0ae9d65 100644
--- a/exam/forms.py
+++ b/exam/forms.py
@@ -4,10 +4,10 @@ from exam.models import Profile
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
-from string import letters, punctuation
+from string import letters, punctuation, digits
-UNAME_CHARS = letters + "."
-PWD_CHARS = letters + punctuation
+UNAME_CHARS = letters + "._" + digits
+PWD_CHARS = letters + punctuation + digits
class UserRegisterForm(forms.Form):
@@ -23,19 +23,20 @@ class UserRegisterForm(forms.Form):
u_name = self.cleaned_data["username"]
if u_name.strip(UNAME_CHARS):
- raise forms.ValidationError("Only letters and period character are \
- allowed in username")
+ msg = "Only letters, digits, period and underscore characters are "\
+ "allowed in username"
+ raise forms.ValidationError(msg)
try:
User.objects.get(username__iexact = u_name)
- raise forms.ValidationError("Username already exists")
+ raise forms.ValidationError("Username already exists.")
except User.DoesNotExist:
return u_name
def clean_password(self):
pwd = self.cleaned_data['password']
if pwd.strip(PWD_CHARS):
- raise forms.ValidationError("Only letters and punctuation are \
+ raise forms.ValidationError("Only letters, digits and punctuation are \
allowed in password")
return pwd