mirror of https://gitlab.crans.org/bde/nk20
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
|
||||
|
||||
|
||||
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,
|
||||
|
|
|
@ -75,7 +75,6 @@ MIDDLEWARE = [
|
|||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.sites.middleware.CurrentSiteMiddleware',
|
||||
'note_kfet.middlewares.SmoothNavigationMiddleware',
|
||||
'note_kfet.middlewares.TurbolinksMiddleware',
|
||||
]
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
<link rel="stylesheet"
|
||||
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"
|
||||
integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh"
|
||||
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"
|
||||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
{# Turbolinks JavaScript #}
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"
|
||||
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 #}
|
||||
{% if form.media %}
|
||||
|
|
Loading…
Reference in New Issue