diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 12 |
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"), |