From 9a0b62aa1691d0b19101996fd1b4e8a9f127db1b Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 14 Sep 2024 14:55:50 +0200 Subject: [PATCH] Mise en cache des CSS de styles --- src/agenda_culturel/templatetags/cat_extra.py | 94 ++++++++++--------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/src/agenda_culturel/templatetags/cat_extra.py b/src/agenda_culturel/templatetags/cat_extra.py index 6fef4b5..010d867 100644 --- a/src/agenda_culturel/templatetags/cat_extra.py +++ b/src/agenda_culturel/templatetags/cat_extra.py @@ -1,5 +1,6 @@ from django import template from django.utils.safestring import mark_safe +from django.core.cache import cache from agenda_culturel.models import Category import colorsys @@ -67,59 +68,62 @@ def background_color_adjust_color(color, alpha=1): @register.simple_tag def css_categories(): - result = '" + result += "." + c["css_class"] + ".circ-cat.recurrent:hover, " + result += ".selected.recurrent:hover ." + c["css_class"] + " {" + result += "background: none;" + result += ( + "color: " + + adjust_color(adjust_lightness_saturation(c["color"], 0.2, 1.2)) + + ";" + ) + result += "}" + + result += "" + cache.set('css_categories', result, 3600) # 1 hour return mark_safe(result)