Auto-reload with turbolinks

This commit is contained in:
Yohann D'ANELLO 2020-02-29 11:57:19 +01:00
parent abee482257
commit 204623c960
4 changed files with 36 additions and 3 deletions

View File

@ -12,6 +12,8 @@ class Ticket(models.Model):
note = models.CharField( note = models.CharField(
max_length=255, max_length=255,
blank=True,
null=True,
verbose_name=_("note") verbose_name=_("note")
) )

View File

@ -5,3 +5,10 @@ from django.views.generic import TemplateView
class TombolaView(TemplateView): class TombolaView(TemplateView):
template_name = "tombola.html" template_name = "tombola.html"
def get_context_data(self, **kwargs):
context = super().get_context_data()
context['title'] = "Tombola Saper[list]popette"
return context

View File

@ -90,7 +90,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<form action="{% url 'set_language' %}" method="post" <form action="{% url 'set_language' %}" method="post"
class="form-inline"> class="form-inline">
<span class="text-muted mr-1"> <span class="text-muted mr-1">
NoteKfet2020 &mdash; Tombola Saper[list]popette &mdash;
<a href="mailto:tresorie.bde@lists.crans.org" <a href="mailto:tresorie.bde@lists.crans.org"
class="text-muted">Nous contacter</a> &mdash; class="text-muted">Nous contacter</a> &mdash;
</span> </span>

View File

@ -2,10 +2,34 @@
{% load i18n static %} {% load i18n static %}
{# Remove page title #} {% block extracss %}
{% block contenttitle %}{% endblock %} <meta name="turbolinks-cache-control" content="no-preview">
{% endblock %}
{% block content %} {% block content %}
{% endblock %} {% endblock %}
{% block extrajavascript %}
<script>
var reloadWithTurbolinks = (function () {
var scrollPosition
function reload () {
scrollPosition = [window.scrollX, window.scrollY]
Turbolinks.visit(window.location.toString(), { action: 'replace' })
}
document.addEventListener('turbolinks:load', function () {
if (scrollPosition) {
window.scrollTo.apply(window, scrollPosition)
scrollPosition = null
}
})
return reload
})()
setTimeout(function(){ reloadWithTurbolinks(); }, 2000);
</script>
{% endblock %}