Le cache des pages ne contient pas le formulaire

This commit is contained in:
Jean-Marie Favreau 2024-11-14 22:38:39 +01:00
parent 1f60bf0c39
commit df27949036
4 changed files with 41 additions and 32 deletions

View File

@ -8,6 +8,8 @@ from django.urls import reverse
from colorfield.fields import ColorField
from django_ckeditor_5.fields import CKEditor5Field
from urllib.parse import urlparse
from django.core.cache import cache
import urllib.request
import os
from django.core.files import File
@ -213,6 +215,10 @@ class Tag(models.Model):
return reverse("view_tag", kwargs={"t": self.name})
def get_tag_groups(nb_suggestions=10, exclude=False, include=False):
id_cache = 'all_tags ' + str(exclude) + ' ' + str(include) + ' ' + str(nb_suggestions)
result = cache.get(id_cache)
if not result: #
free_tags = Event.get_all_tags(False)
obj_tags = Tag.objects
@ -245,6 +251,7 @@ class Tag(models.Model):
result = ((_('Suggestions'), [(t["tag"], t["tag"]) for t in tags1]),
(_('Others'), [(t["tag"], t["tag"]) for t in tags2]))
cache.set(id_cache, result, 300) # 5mn
return result

View File

@ -25,12 +25,12 @@
{% block content %}
{% get_current_language as LANGUAGE_CODE %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout month user.is_authenticated calendar.firstdate filter.to_str LANGUAGE_CODE %}
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=0 %}
{% get_current_language as LANGUAGE_CODE %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout month user.is_authenticated calendar.firstdate filter.to_str LANGUAGE_CODE %}
<article>
<header>

View File

@ -21,9 +21,6 @@
{% block content %}
{% get_current_language as LANGUAGE_CODE %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.to_str calendar.calendar_days_list|length LANGUAGE_CODE %}
<article id="filters">
<header><h1 id="index-avenir">{% block title %}{% block og_title %}
@ -40,6 +37,10 @@
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=1 %}
{% get_current_language as LANGUAGE_CODE %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.to_str calendar.calendar_days_list|length LANGUAGE_CODE %}
<footer>
<a href="{% if calendar.calendar_days_list|length == 1 %}{% url 'day_view' date_pred.year date_pred.month date_pred.day %}{% else %}{% url 'a_venir_jour' date_pred.year date_pred.month date_pred.day %}{% endif %}" aria-label="dates précédentes" role="button">
{% picto_from_name "chevrons-left" %}

View File

@ -21,12 +21,13 @@
{% block content %}
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=0 %}
{% get_current_language as LANGUAGE_CODE %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout week user.is_authenticated calendar.firstdate filter.to_str LANGUAGE_CODE %}
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=0 %}
<article>
<header>
<div class="title small"><h1>