On ajoute une fonction de suppression de cache

Fix #136
This commit is contained in:
Jean-Marie Favreau 2024-12-15 19:00:52 +01:00
parent 63d3cb76ea
commit 430c7b47a2
5 changed files with 286 additions and 240 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
{% extends "agenda_culturel/page-admin.html" %}
{% block fluid %}{% endblock %}
{% block content %}
<article>
<header>
<h1>{% block title %}{% block og_title %}Vider le cache{% endblock %}{% endblock %}</h1>
</header>
<form method="post">{% csrf_token %}
<p>Êtes-vous sûr·e de vouloir vider le cache&nbsp;? Toutes les pages seront
générées lors de leur consultation, mais cela peut ralentir temporairemenet l'expérience de navigation.
</p>
{{ form }}
<footer>
<div class="grid buttons">
<a href="{{ cancel_url }}" role="button" class="secondary">Annuler</a>
<input type="submit" value="Confirmer">
</div>
</footer>
</form>
</article>
{% endblock %}

View File

@ -68,6 +68,7 @@
<h3>Configuration interne</h3> <h3>Configuration interne</h3>
<nav> <nav>
<ul> <ul>
<li><a href="{% url 'clear_cache' %}">Vider le cache</a></li>
<li><a href="{% url 'admin:index' %}">Administration de django</a></li> <li><a href="{% url 'admin:index' %}">Administration de django</a></li>
</ul> </ul>
</nav> </nav>

View File

@ -208,6 +208,8 @@ urlpatterns = [
{"sitemaps": sitemaps}, {"sitemaps": sitemaps},
name="django.contrib.sitemaps.views.sitemap", name="django.contrib.sitemaps.views.sitemap",
), ),
path("cache/clear", clear_cache, name="clear_cache"),
] ]
if settings.DEBUG: if settings.DEBUG:

View File

@ -2227,3 +2227,15 @@ def delete_tag(request, t):
"agenda_culturel/tag_confirm_delete_by_name.html", "agenda_culturel/tag_confirm_delete_by_name.html",
{"tag": t, "nb": nb, "nbi": nbi, "cancel_url": cancel_url, "obj": obj}, {"tag": t, "nb": nb, "nbi": nbi, "cancel_url": cancel_url, "obj": obj},
) )
def clear_cache(request):
if request.method == "POST":
cache.clear()
messages.success(request, _("Cache successfully cleared."))
return HttpResponseRedirect(reverse_lazy("administration"))
else:
return render(
request,
"agenda_culturel/clear_cache.html",
)