summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-30 02:01:46 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-30 02:01:46 +0200
commit252186d3df11f79b29043a95f1cc20af63310ae1 (patch)
tree97db6fdd9fb3e621a49181afe1cf2734b2f85d01 /ishtar_common
parent0467ab45a66c3d452dc9b1702fc2b9c6736c7c75 (diff)
downloadIshtar-252186d3df11f79b29043a95f1cc20af63310ae1.tar.bz2
Ishtar-252186d3df11f79b29043a95f1cc20af63310ae1.zip
Access control: fix evaluation of availability of actions
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/menu_base.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/ishtar_common/menu_base.py b/ishtar_common/menu_base.py
index 0117b375d..c6d02daa5 100644
--- a/ishtar_common/menu_base.py
+++ b/ishtar_common/menu_base.py
@@ -87,18 +87,22 @@ class MenuItem:
return False
if not self.access_controls:
return True
+ if not hasattr(user, 'ishtaruser'):
+ return False
+ # manage by specific idx - person type
+ if user.ishtaruser.has_right(self.idx, session=session):
+ return True
prefix = (self.model._meta.app_label + '.') if self.model else ''
for access_control in self.access_controls:
+ # check by person type
+ if user.ishtaruser.has_right(access_control, session=session):
+ return True
access_control = prefix + access_control
- if hasattr(user, 'ishtaruser') and \
- user.ishtaruser.has_perm(access_control, self.model,
- session=session) or \
+ # check by specific access control
+ if user.ishtaruser.has_perm(access_control, self.model,
+ session=session) or \
access_control in user.get_group_permissions():
return True
- # manage by person type
- if hasattr(user, 'ishtaruser'):
- if user.ishtaruser.has_right(self.idx, session=session):
- return True
return False
def is_available(self, user, obj=None, session=None):