diff options
author | Prabhu Ramachandran | 2011-11-19 08:38:13 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2011-11-19 08:38:13 +0530 |
commit | 6fcc55a442d52c251408566f6bc924b15cef0bb3 (patch) | |
tree | d356677a0da1db3732693b487fea73d27a9c3fd7 | |
parent | 7e370f3017572fb202d48a9ca884bfd7d3880d63 (diff) | |
download | online_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.
-rw-r--r-- | exam/forms.py | 15 | ||||
-rw-r--r-- | templates/exam/login.html | 4 | ||||
-rw-r--r-- | templates/exam/register.html | 4 |
3 files changed, 14 insertions, 9 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 diff --git a/templates/exam/login.html b/templates/exam/login.html index b8594f4..8f0ef6c 100644 --- a/templates/exam/login.html +++ b/templates/exam/login.html @@ -9,7 +9,9 @@ Please login to proceed.</p> <form action="" method="post"> {% csrf_token %} -{{ form.as_p }} +<table> +{{ form.as_table }} +</table> <input type="submit" value="Login" /> </form> diff --git a/templates/exam/register.html b/templates/exam/register.html index d002570..921e7b5 100644 --- a/templates/exam/register.html +++ b/templates/exam/register.html @@ -7,7 +7,9 @@ Please provide the following details. <form action="" method="post"> {% csrf_token %} -{{ form.as_p }} +<table> +{{ form.as_table }} +</table> <input type="submit" value="Register" /> </form> |