1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 09:58:23 +02:00

Remove SmoothNavigation Middleware

This commit is contained in:
Alexandre Iooss
2020-02-21 21:15:49 +01:00
parent 9a0d74c18b
commit 82355135b0
3 changed files with 3 additions and 33 deletions

View File

@ -6,32 +6,6 @@ from django.http import HttpResponseRedirect
from urllib.parse import urlencode, parse_qs, urlsplit, urlunsplit
class SmoothNavigationMiddleware(object):
"""Keep `?back=` queryset parameter on POST requests."""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request): # noqa D102
response = self.get_response(request)
if isinstance(response, HttpResponseRedirect):
back = request.GET.get('back')
if back:
_, _, back_path, _, _ = urlsplit(back)
scheme, netloc, path, query_string, fragment = urlsplit(response['location'])
query_params = parse_qs(query_string)
if path == back_path:
query_params.pop('back', None)
elif 'back' not in query_params:
query_params['back'] = [back]
new_query_string = urlencode(query_params, doseq=True)
response['location'] = urlunsplit((scheme, netloc, path, new_query_string, fragment))
return response
class TurbolinksMiddleware(object):
"""
Send the `Turbolinks-Location` header in response to a visit that was redirected,