diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 0b1f42460..77a9bf868 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -42,7 +42,7 @@ from django.core.urlresolvers import reverse, NoReverseMatch from django.db.utils import DatabaseError from django.db.models import Q, Max, Count from django.db.models.base import ModelBase -from django.db.models.signals import post_save, pre_delete +from django.db.models.signals import post_save, pre_delete, post_delete from django.utils.translation import ugettext_lazy as _, ugettext, \ pgettext_lazy @@ -801,7 +801,7 @@ class IshtarSiteProfile(models.Model, Cached): obj = self if raw: return obj - q = self.__class__.objects.filter(active=True).exclude(pk=self.pk) + q = self.__class__.objects.filter(active=True).exclude(slug=self.slug) if obj.active and q.count(): for profile in q.all(): profile.active = False @@ -822,7 +822,7 @@ class IshtarSiteProfile(models.Model, Cached): def get_current_profile(force=False): - cache_key, value = get_cache(IshtarSiteProfile, 'is-current-profile') + cache_key, value = get_cache(IshtarSiteProfile, ['is-current-profile']) if value and not force: return value q = IshtarSiteProfile.objects.filter(active=True) @@ -836,11 +836,10 @@ def get_current_profile(force=False): def cached_site_changed(sender, **kwargs): - if not kwargs['instance']: - return get_current_profile(force=True) post_save.connect(cached_site_changed, sender=IshtarSiteProfile) +post_delete.connect(cached_site_changed, sender=IshtarSiteProfile) class GlobalVar(models.Model, Cached): |