diff --git a/apps/member/views.py b/apps/member/views.py
index 3570f7b2..6f982c64 100644
--- a/apps/member/views.py
+++ b/apps/member/views.py
@@ -249,6 +249,9 @@ class ClubAddMemberView(LoginRequiredMixin, CreateView):
context = super().get_context_data(**kwargs)
context['formset'] = MemberFormSet()
context['helper'] = FormSetHelper()
+
+ context['no_cache'] = True
+
return context
def post(self, request, *args, **kwargs):
diff --git a/apps/note/views.py b/apps/note/views.py
index 61012f34..167ef4f0 100644
--- a/apps/note/views.py
+++ b/apps/note/views.py
@@ -28,6 +28,9 @@ class TransactionCreate(LoginRequiredMixin, CreateView):
context = super().get_context_data(**kwargs)
context['title'] = _('Transfer money from your account '
'to one or others')
+
+ context['no_cache'] = True
+
return context
def get_form(self, form_class=None):
@@ -138,6 +141,10 @@ class ConsoView(LoginRequiredMixin, CreateView):
context['transaction_templates'] = TransactionTemplate.objects.all() \
.order_by('template_type')
context['title'] = _("Consommations")
+
+ # select2 compatibility
+ context['no_cache'] = True
+
return context
def get_success_url(self):
diff --git a/note_kfet/middlewares.py b/note_kfet/middlewares.py
new file mode 100644
index 00000000..73b87e36
--- /dev/null
+++ b/note_kfet/middlewares.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+from django.http import HttpResponseRedirect
+
+from urllib.parse import urlencode, parse_qs, urlsplit, urlunsplit
+
+
+class TurbolinksMiddleware(object):
+ """
+ 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
+
diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py
index 410f496f..9019b4e0 100644
--- a/note_kfet/settings/base.py
+++ b/note_kfet/settings/base.py
@@ -75,6 +75,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
+ 'note_kfet.middlewares.TurbolinksMiddleware',
]
ROOT_URLCONF = 'note_kfet.urls'
diff --git a/requirements.txt b/requirements.txt
index 2899ef61..21c24808 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@ chardet==3.0.4
defusedxml==0.6.0
Django~=2.2
django-allauth==0.39.1
-django-autocomplete-light==3.3.0
+django-autocomplete-light==3.5.1
django-crispy-forms==1.7.2
django-extensions==2.1.9
django-filter==2.2.0
@@ -14,6 +14,7 @@ django-rest-polymorphic==0.1.8
django-reversion==3.0.3
django-tables2==2.1.0
docutils==0.14
+psycopg2==2.8.4
idna==2.8
oauthlib==3.1.0
Pillow==6.1.0
diff --git a/templates/base.html b/templates/base.html
index ba7b4c9e..4b5f9872 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -22,6 +22,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
+ {% if no_cache %}
+
+ {% endif %}
{# Bootstrap CSS #}
+ {# JQuery, Bootstrap and Turbolinks JavaScript #}
+
+
+
+
+
{# Si un formulaire requiert des données supplémentaires (notamment JS), les données sont chargées #}
{% if form.media %}
{{ form.media }}
@@ -139,16 +155,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
-{# Bootstrap JavaScript #}
-
-
-
{% block extrajavascript %}
{% endblock extrajavascript %}