# HG changeset patch # User Madhusudan.C.S # Date 1295341434 -19800 # Node ID 7b006fb467c2a336d2bdb617905e46a3af0984d2 # Parent 8d88ec95a8284ea74f86cd133089a1682581d3ea Redirect the login to home page if the login is made from logout page. diff -r 8d88ec95a828 -r 7b006fb467c2 pytask/profile/views.py --- a/pytask/profile/views.py Tue Jan 18 01:47:55 2011 +0530 +++ b/pytask/profile/views.py Tue Jan 18 14:33:54 2011 +0530 @@ -1,3 +1,5 @@ +from urllib2 import urlparse + from django import http from django import shortcuts from django.contrib.auth.decorators import login_required @@ -195,15 +197,25 @@ @login_required def login_proceed(request): - """View that handles the successful login. - """ + """View that handles the successful login. + """ + + template_name = '_user_login.html' - template_name = '_user_login.html' - response = { - 'authentication': 'success', - 'markup': loader.render_to_string(template_name, - RequestContext(request, {})) - } + # Check if the request came from logout page, if so set + # authentication to redirect to home page + if reverse('auth_logout') == urlparse.urlsplit( + request.META['HTTP_REFERER'])[2]: + response = { + 'authentication': 'success', + 'redirect': reverse('home_page'), + } + else: + response = { + 'authentication': 'success', + 'markup': loader.render_to_string(template_name, + RequestContext(request, {})) + } - json_response = json.dumps(response) - return http.HttpResponse(json_response) + json_response = json.dumps(response) + return http.HttpResponse(json_response)