summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exam/forms.py15
-rw-r--r--templates/exam/login.html4
-rw-r--r--templates/exam/register.html4
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>