summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
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
commite264115195002ee05658f59e8943b22460903e74 (patch)
treeac0c4136a3ab322f5519ba5b2511047b3a6cc505 /ishtar_common/models.py
parent2d8c714fe516361c2a47eba30542ae57452de22f (diff)
downloadIshtar-e264115195002ee05658f59e8943b22460903e74.tar.bz2
Ishtar-e264115195002ee05658f59e8943b22460903e74.zip
Force update of cache when modifying site configuration
Diffstat (limited to 'ishtar_common/models.py')
-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"),