Remove SmoothNavigation Middleware

This commit is contained in:
Alexandre Iooss 2020-02-21 21:15:49 +01:00
parent 9a0d74c18b
commit 82355135b0
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
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 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): class TurbolinksMiddleware(object):
""" """
Send the `Turbolinks-Location` header in response to a visit that was redirected, Send the `Turbolinks-Location` header in response to a visit that was redirected,

View File

@ -75,7 +75,6 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware', 'django.middleware.locale.LocaleMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware',
'note_kfet.middlewares.SmoothNavigationMiddleware',
'note_kfet.middlewares.TurbolinksMiddleware', 'note_kfet.middlewares.TurbolinksMiddleware',
] ]

View File

@ -34,7 +34,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<link rel="stylesheet" <link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
{# Bootstrap JavaScript #} {# JQuery, Bootstrap and Turbolinks JavaScript #}
<script src="https://code.jquery.com/jquery-3.4.1.min.js" <script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
@ -44,11 +44,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
{# Turbolinks JavaScript #} crossorigin="anonymous"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
crossorigin="anonymous"></script>
{# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #} {# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #}
{% if form.media %} {% if form.media %}