# HG changeset patch # User raph # Date 1279206435 -7200 # Node ID 7c40b98f627f04f27bc515967195ca2f9794e893 # Parent c2c262ac12731bfd410e6f4fa7530fa48da94c75# Parent b8672f57ba3cd4e876277a13c69621446b940052 Merge with b8672f57ba3cd4e876277a13c69621446b940052 diff -r c2c262ac1273 -r 7c40b98f627f buildout.cfg --- a/buildout.cfg Thu Jul 15 16:23:58 2010 +0200 +++ b/buildout.cfg Thu Jul 15 17:07:15 2010 +0200 @@ -6,6 +6,7 @@ django-extensions django-piston omelette +unzip = true develop = . [python] @@ -30,6 +31,7 @@ django-flash django-tagging # django-piston +# api dependency # django-css # chardet feedparser diff -r c2c262ac1273 -r 7c40b98f627f src/cm/middleware.py --- a/src/cm/middleware.py Thu Jul 15 16:23:58 2010 +0200 +++ b/src/cm/middleware.py Thu Jul 15 17:07:15 2010 +0200 @@ -2,6 +2,7 @@ from django.conf import settings from django.http import HttpResponseServerError,HttpResponseRedirect from django.core.urlresolvers import reverse +from urllib import urlencode class CmMiddleware(object): @@ -11,7 +12,8 @@ traceback.print_exc() if type(exception) == UnauthorizedException: if request.user.is_anonymous(): - login_url = reverse('login') + '?next=%s' %request.META['PATH_INFO'] + query = urlencode({'next': request.META['PATH_INFO'], 'q' : request.META['QUERY_STRING'] }) + login_url = reverse('login') + '?' + query return HttpResponseRedirect(login_url) else: redirect_url = reverse('unauthorized') diff -r c2c262ac1273 -r 7c40b98f627f src/cm/security.py --- a/src/cm/security.py Thu Jul 15 16:23:58 2010 +0200 +++ b/src/cm/security.py Thu Jul 15 17:07:15 2010 +0200 @@ -198,8 +198,7 @@ def _dec(view_func): def _check_global_perm(request, *args, **kwargs): if must_be_logged_in and not is_authenticated(request): - login_url = reverse('login') - return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, urlquote(request.get_full_path()))) + raise UnauthorizedException('Should be logged in') if has_perm(request, perm_name, text=None): return view_func(request, *args, **kwargs) @@ -229,8 +228,7 @@ if must_be_logged_in and not is_authenticated(request): if not api: - login_url = reverse('login') - return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, urlquote(request.get_full_path()))) + raise UnauthorizedException('Should be logged in') else: return rc.FORBIDDEN diff -r c2c262ac1273 -r 7c40b98f627f src/cm/templates/site/login_form.html --- a/src/cm/templates/site/login_form.html Thu Jul 15 16:23:58 2010 +0200 +++ b/src/cm/templates/site/login_form.html Thu Jul 15 17:07:15 2010 +0200 @@ -27,6 +27,9 @@ {% if request.GET.next %} {% endif %} +{% if request.GET.q %} + +{% endif %} diff -r c2c262ac1273 -r 7c40b98f627f src/cm/views/user.py --- a/src/cm/views/user.py Thu Jul 15 16:23:58 2010 +0200 +++ b/src/cm/views/user.py Thu Jul 15 17:07:15 2010 +0200 @@ -544,8 +544,12 @@ display_message(request, _(u"You're logged in!")) next = request.POST.get('next', None) + q = request.POST.get('q', None) if next and next.startswith('/'): - return HttpResponseRedirect(next) + if q: + return HttpResponseRedirect(next + '?' + q) + else: + return HttpResponseRedirect(next) else: return HttpResponseRedirect(reverse('index'))