summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-18 12:00:34 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-02-18 12:00:34 +0100
commit6a868f55d08cd9be71be95af6617abdcab80a57c (patch)
treeac0c4136a3ab322f5519ba5b2511047b3a6cc505
parent50b565e74631a684b2b389cac55982db86d8d5ba (diff)
downloadIshtar-6a868f55d08cd9be71be95af6617abdcab80a57c.tar.bz2
Ishtar-6a868f55d08cd9be71be95af6617abdcab80a57c.zip
Force update of cache when modifying site configuration
-rw-r--r--ishtar_common/models.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index f5c6ed223..0b1f42460 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -821,9 +821,9 @@ class IshtarSiteProfile(models.Model, Cached):
return obj
-def get_current_profile():
+def get_current_profile(force=False):
cache_key, value = get_cache(IshtarSiteProfile, 'is-current-profile')
- if value:
+ if value and not force:
return value
q = IshtarSiteProfile.objects.filter(active=True)
if not q.count():
@@ -835,6 +835,14 @@ def get_current_profile():
return obj
+def cached_site_changed(sender, **kwargs):
+ if not kwargs['instance']:
+ return
+ get_current_profile(force=True)
+
+post_save.connect(cached_site_changed, sender=IshtarSiteProfile)
+
+
class GlobalVar(models.Model, Cached):
slug = models.SlugField(_(u"Variable name"), unique=True)
description = models.TextField(_(u"Description of the variable"),