Le cache des pages ne contient pas le formulaire
This commit is contained in:
parent
1f60bf0c39
commit
df27949036
@ -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,38 +215,43 @@ class Tag(models.Model):
|
||||
return reverse("view_tag", kwargs={"t": self.name})
|
||||
|
||||
def get_tag_groups(nb_suggestions=10, exclude=False, include=False):
|
||||
free_tags = Event.get_all_tags(False)
|
||||
id_cache = 'all_tags ' + str(exclude) + ' ' + str(include) + ' ' + str(nb_suggestions)
|
||||
result = cache.get(id_cache)
|
||||
if not result: #
|
||||
|
||||
obj_tags = Tag.objects
|
||||
free_tags = Event.get_all_tags(False)
|
||||
|
||||
try:
|
||||
if exclude:
|
||||
obj_tags = obj_tags.filter(Q(in_excluded_suggestions=True))
|
||||
if include:
|
||||
obj_tags = obj_tags.filter(Q(in_included_suggestions=True)|Q(principal=True))
|
||||
except FieldDoesNotExist:
|
||||
pass
|
||||
|
||||
if not exclude and not include:
|
||||
obj_tags = obj_tags.filter(principal=True)
|
||||
obj_tags = Tag.objects
|
||||
|
||||
obj_tags = obj_tags.values_list("name", flat=True)
|
||||
try:
|
||||
if exclude:
|
||||
obj_tags = obj_tags.filter(Q(in_excluded_suggestions=True))
|
||||
if include:
|
||||
obj_tags = obj_tags.filter(Q(in_included_suggestions=True)|Q(principal=True))
|
||||
except FieldDoesNotExist:
|
||||
pass
|
||||
|
||||
if not exclude and not include:
|
||||
obj_tags = obj_tags.filter(principal=True)
|
||||
|
||||
if len(obj_tags) > nb_suggestions:
|
||||
nb_suggestions = len(obj_tags)
|
||||
|
||||
tags = [{"tag": t["tag"], "count": 1000000 if t["tag"] in obj_tags else t["count"]} for t in free_tags]
|
||||
obj_tags = obj_tags.values_list("name", flat=True)
|
||||
|
||||
tags.sort(key=lambda x: -x["count"])
|
||||
if len(obj_tags) > nb_suggestions:
|
||||
nb_suggestions = len(obj_tags)
|
||||
|
||||
tags = [{"tag": t["tag"], "count": 1000000 if t["tag"] in obj_tags else t["count"]} for t in free_tags]
|
||||
|
||||
tags1 = tags[0:nb_suggestions]
|
||||
tags1.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
tags2 = tags[nb_suggestions:]
|
||||
tags2.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
tags.sort(key=lambda x: -x["count"])
|
||||
|
||||
result = ((_('Suggestions'), [(t["tag"], t["tag"]) for t in tags1]),
|
||||
(_('Others'), [(t["tag"], t["tag"]) for t in tags2]))
|
||||
tags1 = tags[0:nb_suggestions]
|
||||
tags1.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
tags2 = tags[nb_suggestions:]
|
||||
tags2.sort(key=lambda x: remove_accents(x["tag"]).lower())
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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" %}
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user