mirror of https://gitlab.crans.org/bde/nk20
Merge branch 'turbolinks' into 'master'
Turbolinks See merge request bde/nk20!15
This commit is contained in:
commit
8c364c769e
|
@ -249,6 +249,9 @@ class ClubAddMemberView(LoginRequiredMixin, CreateView):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['formset'] = MemberFormSet()
|
context['formset'] = MemberFormSet()
|
||||||
context['helper'] = FormSetHelper()
|
context['helper'] = FormSetHelper()
|
||||||
|
|
||||||
|
context['no_cache'] = True
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
|
|
@ -28,6 +28,9 @@ class TransactionCreate(LoginRequiredMixin, CreateView):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['title'] = _('Transfer money from your account '
|
context['title'] = _('Transfer money from your account '
|
||||||
'to one or others')
|
'to one or others')
|
||||||
|
|
||||||
|
context['no_cache'] = True
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
def get_form(self, form_class=None):
|
||||||
|
@ -138,6 +141,10 @@ class ConsoView(LoginRequiredMixin, CreateView):
|
||||||
context['transaction_templates'] = TransactionTemplate.objects.all() \
|
context['transaction_templates'] = TransactionTemplate.objects.all() \
|
||||||
.order_by('template_type')
|
.order_by('template_type')
|
||||||
context['title'] = _("Consommations")
|
context['title'] = _("Consommations")
|
||||||
|
|
||||||
|
# select2 compatibility
|
||||||
|
context['no_cache'] = True
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -75,6 +75,7 @@ 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.TurbolinksMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'note_kfet.urls'
|
ROOT_URLCONF = 'note_kfet.urls'
|
||||||
|
|
|
@ -3,7 +3,7 @@ chardet==3.0.4
|
||||||
defusedxml==0.6.0
|
defusedxml==0.6.0
|
||||||
Django~=2.2
|
Django~=2.2
|
||||||
django-allauth==0.39.1
|
django-allauth==0.39.1
|
||||||
django-autocomplete-light==3.3.0
|
django-autocomplete-light==3.5.1
|
||||||
django-crispy-forms==1.7.2
|
django-crispy-forms==1.7.2
|
||||||
django-extensions==2.1.9
|
django-extensions==2.1.9
|
||||||
django-filter==2.2.0
|
django-filter==2.2.0
|
||||||
|
@ -14,6 +14,7 @@ django-rest-polymorphic==0.1.8
|
||||||
django-reversion==3.0.3
|
django-reversion==3.0.3
|
||||||
django-tables2==2.1.0
|
django-tables2==2.1.0
|
||||||
docutils==0.14
|
docutils==0.14
|
||||||
|
psycopg2==2.8.4
|
||||||
idna==2.8
|
idna==2.8
|
||||||
oauthlib==3.1.0
|
oauthlib==3.1.0
|
||||||
Pillow==6.1.0
|
Pillow==6.1.0
|
||||||
|
|
|
@ -22,6 +22,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
<meta name="msapplication-TileColor" content="#da532c">
|
<meta name="msapplication-TileColor" content="#da532c">
|
||||||
<meta name="msapplication-config" content="{% static "favicon/browserconfig.xml" %}">
|
<meta name="msapplication-config" content="{% static "favicon/browserconfig.xml" %}">
|
||||||
<meta name="theme-color" content="#ffffff">
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
{% if no_cache %}
|
||||||
|
<meta name="turbolinks-cache-control" content="no-cache">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Bootstrap CSS #}
|
{# Bootstrap CSS #}
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
|
@ -31,6 +34,19 @@ 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">
|
||||||
|
|
||||||
|
{# 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>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
|
||||||
|
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
|
||||||
|
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
|
||||||
|
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 %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
|
@ -139,16 +155,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
{# Bootstrap JavaScript #}
|
|
||||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
|
|
||||||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
|
|
||||||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
|
|
||||||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
{% block extrajavascript %}
|
{% block extrajavascript %}
|
||||||
{% endblock extrajavascript %}
|
{% endblock extrajavascript %}
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue