summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exam/forms.py2
-rw-r--r--exam/views.py10
-rw-r--r--templates/exam/register.html5
3 files changed, 5 insertions, 12 deletions
diff --git a/exam/forms.py b/exam/forms.py
index 7ee4b0e..38466e8 100644
--- a/exam/forms.py
+++ b/exam/forms.py
@@ -62,7 +62,7 @@ class UserRegisterForm(forms.Form):
new_profile.roll_number = self.cleaned_data["roll_number"]
new_profile.save()
- return new_user
+ return u_name, pwd
class UserLoginForm(forms.Form):
username = forms.CharField(max_length = 30)
diff --git a/exam/views.py b/exam/views.py
index 43ac388..7ee3c53 100644
--- a/exam/views.py
+++ b/exam/views.py
@@ -38,13 +38,11 @@ def user_register(request):
form = UserRegisterForm(request.POST)
if form.is_valid():
data = form.cleaned_data
- new_user = form.save()
+ u_name, pwd = form.save()
- context = {}
- context['full_name'] = new_user.first_name.title() + " " + \
- new_user.last_name.title()
- return render_to_response('exam/register.html', context,
- context_instance=RequestContext(request))
+ new_user = authenticate(username = u_name, password = pwd)
+ login(request, new_user)
+ return redirect("/exam/start/")
else:
return render_to_response('exam/register.html',{'form':form},
diff --git a/templates/exam/register.html b/templates/exam/register.html
index c0d0cb7..2ffc140 100644
--- a/templates/exam/register.html
+++ b/templates/exam/register.html
@@ -1,4 +1,3 @@
-{% if form %}
Please provide the following details.
<form action="" method="post">
{% csrf_token %}
@@ -7,7 +6,3 @@ Please provide the following details.
<input type="submit" value="Register" />
</form>
-{% else %}
-Congratulations {{ full_name }}! You have successfully registered.<br />
-Please proceed to <a href="/exam/login/">Login</a>.
-{% endif %}