Auto-reload with turbolinks
This commit is contained in:
		@@ -12,6 +12,8 @@ class Ticket(models.Model):
 | 
			
		||||
 | 
			
		||||
    note = models.CharField(
 | 
			
		||||
        max_length=255,
 | 
			
		||||
        blank=True,
 | 
			
		||||
        null=True,
 | 
			
		||||
        verbose_name=_("note")
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,3 +5,10 @@ from django.views.generic import TemplateView
 | 
			
		||||
 | 
			
		||||
class TombolaView(TemplateView):
 | 
			
		||||
    template_name = "tombola.html"
 | 
			
		||||
 | 
			
		||||
    def get_context_data(self, **kwargs):
 | 
			
		||||
        context = super().get_context_data()
 | 
			
		||||
 | 
			
		||||
        context['title'] = "Tombola Saper[list]popette"
 | 
			
		||||
 | 
			
		||||
        return context
 | 
			
		||||
 
 | 
			
		||||
@@ -90,7 +90,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
 | 
			
		||||
                <form action="{% url 'set_language' %}" method="post"
 | 
			
		||||
                      class="form-inline">
 | 
			
		||||
                    <span class="text-muted mr-1">
 | 
			
		||||
                        NoteKfet2020 —
 | 
			
		||||
                        Tombola Saper[list]popette —
 | 
			
		||||
                        <a href="mailto:tresorie.bde@lists.crans.org"
 | 
			
		||||
                           class="text-muted">Nous contacter</a> —
 | 
			
		||||
                    </span>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,34 @@
 | 
			
		||||
 | 
			
		||||
{% load i18n static %}
 | 
			
		||||
 | 
			
		||||
{# Remove page title #}
 | 
			
		||||
{% block contenttitle %}{% endblock %}
 | 
			
		||||
{% block extracss %}
 | 
			
		||||
    <meta name="turbolinks-cache-control" content="no-preview">
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
 | 
			
		||||
{% 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 %}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user