From 82355135b060fb01a45be1e94212fbbc6d2f0f06 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 21 Feb 2020 21:15:49 +0100 Subject: [PATCH] Remove SmoothNavigation Middleware --- note_kfet/middlewares.py | 26 -------------------------- note_kfet/settings/base.py | 1 - templates/base.html | 9 +++------ 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/note_kfet/middlewares.py b/note_kfet/middlewares.py index e2b8d7c6..73b87e36 100644 --- a/note_kfet/middlewares.py +++ b/note_kfet/middlewares.py @@ -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, diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index b45dc55c..9019b4e0 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -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', ] diff --git a/templates/base.html b/templates/base.html index 15ebef01..4b5f9872 100644 --- a/templates/base.html +++ b/templates/base.html @@ -34,7 +34,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - {# Bootstrap JavaScript #} + {# JQuery, Bootstrap and Turbolinks JavaScript #} @@ -44,11 +44,8 @@ SPDX-License-Identifier: GPL-3.0-or-later - - {# Turbolinks JavaScript #} - + {# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #} {% if form.media %}