1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-24 06:28:49 +02:00

Drop turbolinks support, too useless

This commit is contained in:
Emmy D'Anello
2023-02-20 13:42:36 +01:00
parent 731dfc049f
commit 5abca36498
11 changed files with 26 additions and 68 deletions

View File

@ -52,34 +52,3 @@ class SessionMiddleware(object):
_set_current_user_and_ip(None, None, None)
return response
class TurbolinksMiddleware(object): # pragma: no cover
"""
Send the `Turbolinks-Location` header in response to a visit that was redirected,
and Turbolinks will replace the browser's topmost history entry.
"""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
is_turbolinks = request.META.get('HTTP_TURBOLINKS_REFERRER')
is_response_redirect = response.has_header('Location')
if is_turbolinks:
if is_response_redirect:
location = response['Location']
prev_location = request.session.pop('_turbolinks_redirect_to', None)
if prev_location is not None:
# relative subsequent redirect
if location.startswith('.'):
location = prev_location.split('?')[0] + location
request.session['_turbolinks_redirect_to'] = location
else:
if request.session.get('_turbolinks_redirect_to'):
location = request.session.pop('_turbolinks_redirect_to')
response['Turbolinks-Location'] = location
return response