mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-27 02:43:01 +00:00
Remove SmoothNavigation Middleware
This commit is contained in:
parent
9a0d74c18b
commit
82355135b0
@ -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,
|
||||||
|
@ -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',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -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,10 +44,7 @@ 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 #}
|
|
||||||
<script
|
|
||||||
src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
|
|
||||||
crossorigin="anonymous"></script>
|
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 #}
|
||||||
|
Loading…
Reference in New Issue
Block a user