on supprime le cache d'un événement quand on le modifie

Fix #254
This commit is contained in:
Jean-Marie Favreau 2024-12-15 18:55:14 +01:00
parent d770cf23f0
commit 63d3cb76ea

View File

@ -10,6 +10,7 @@ from colorfield.fields import ColorField
from django_ckeditor_5.fields import CKEditor5Field
from urllib.parse import urlparse
from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key
from django.contrib.auth.models import User, AnonymousUser
import emoji
@ -1156,6 +1157,12 @@ class Event(models.Model):
# first save the current object
super().save(*args, **kwargs)
# clear cache
for is_auth in [False, True]:
key = make_template_fragment_key("event_body", [is_auth, self])
cache.delete(key)
logger.warning("on passe par le save")
# then if its a clone, update the representative
if clone:
self.other_versions.representative = self