Commit 1133bb18 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

Revert "ERP5Type/patches/User: drop SimpleUser.getRolesInContext patch"

This reverts commit bf230f1f.

pushed by mistake
parent 0d128c11
...@@ -59,3 +59,33 @@ def getRoles(self, _transactional_variable_pool=local()): ...@@ -59,3 +59,33 @@ def getRoles(self, _transactional_variable_pool=local()):
return role_tuple + extra_role_tuple return role_tuple + extra_role_tuple
SimpleUser.getRoles = getRoles SimpleUser.getRoles = getRoles
def getRolesInContext(self, object):
"""
Return the list of roles assigned to the user, including local roles
assigned in context of the passed in object.
"""
userid = self.getId()
result = set()
object = aq_inner(object)
while 1:
local_role_dict = getattr(object, '__ac_local_roles__', None)
if local_role_dict:
if callable(local_role_dict):
local_role_dict = local_role_dict() or {}
result.update(local_role_dict.get(userid, ()))
parent = aq_parent(aq_inner(object))
if parent is not None:
object = parent
continue
new = getattr(object, '__self__', None)
if new is not None:
object = aq_inner(new)
continue
break
# Patched: Developer role should never be available as local role
result.discard(DEVELOPER_ROLE_ID)
result.update(self.getRoles())
return list(result)
SimpleUser.getRolesInContext = getRolesInContext
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment