summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index a6fc8722d..3eceb8df0 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2558,28 +2558,42 @@ class Person(Address, Merge, OwnPerms, ValueGetter):
res = cache.get(cache_key)
if res in (True, False):
return res
+ # list all cache key in order to clean them on profiel change
+ cache_key_list = 'sessionlist-{}'.format(session.session_key)
+ key_list = cache.get(cache_key_list, [])
+ key_list.append(cache_key)
+ cache.set(cache_key_list, key_list, settings.CACHE_TIMEOUT)
if type(right_name) in (list, tuple):
- res = bool(self.person_types.filter(
- txt_idx__in=right_name).count()) or \
- bool(self.person_types.filter(
- groups__permissions__codename__in=right_name).count()) or\
+ res = bool(
+ self.profiles.filter(
+ current=True,
+ profile_type__txt_idx__in=right_name
+ ).count()) or \
+ bool(self.profiles.filter(
+ current=True,
+ profile_type__groups__permissions__codename__in=right_name
+ ).count()) or \
bool(self.ishtaruser.user_ptr.groups.filter(
permissions__codename__in=right_name
).count()) or\
bool(self.ishtaruser.user_ptr.user_permissions.filter(
codename__in=right_name).count())
- # or self.person_types.filter(wizard__url_name__in=right_name).count())
else:
- res = bool(self.person_types.filter(txt_idx=right_name).count()) or\
- bool(self.person_types.filter(
- groups__permissions__codename=right_name).count()) or \
+ res = bool(
+ self.profiles.filter(
+ current=True,
+ profile_type__txt_idx__in=right_name
+ ).count()) or \
+ bool(self.profiles.filter(
+ current=True,
+ profile_type__groups__permissions__codename=right_name
+ ).count()) or \
bool(self.ishtaruser.user_ptr.groups.filter(
permissions__codename__in=[right_name]
).count()) or \
bool(self.ishtaruser.user_ptr.user_permissions.filter(
codename__in=[right_name]).count())
- # or self.person_types.filter(wizard__url_name=right_name).count())
if session:
cache.set(cache_key, res, settings.CACHE_TIMEOUT)
return res