summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/views.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index db7498c..52cdc5f 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -68,14 +68,14 @@ def add_to_group(users):
user.groups.add(group)
-def index(request):
+def index(request, next_url=None):
"""The start page.
"""
user = request.user
if user.is_authenticated():
if user.groups.filter(name='moderator').count() > 0:
- return my_redirect('/exam/manage/')
- return my_redirect("/exam/quizzes/")
+ return my_redirect('/exam/manage/' if not next_url else next_url)
+ return my_redirect("/exam/quizzes/" if not next_url else next_url)
return my_redirect("/exam/login/")
@@ -324,27 +324,25 @@ def user_login(request):
user = request.user
ci = RequestContext(request)
if user.is_authenticated():
- if user.groups.filter(name='moderator').count() > 0:
- return my_redirect('/exam/manage/')
- return my_redirect("/exam/quizzes/")
+ return index(request)
+
+ next_url = request.GET.get('next')
if request.method == "POST":
form = UserLoginForm(request.POST)
if form.is_valid():
user = form.cleaned_data
login(request, user)
- if user.groups.filter(name='moderator').count() > 0:
- return my_redirect('/exam/manage/')
- return my_redirect('/exam/login/')
+ return index(request, next_url)
else:
context = {"form": form}
- return my_render_to_response('yaksh/login.html', context,
- context_instance=ci)
+
else:
form = UserLoginForm()
context = {"form": form}
- return my_render_to_response('yaksh/login.html', context,
- context_instance=ci)
+
+ return my_render_to_response('yaksh/login.html', context,
+ context_instance=ci)