Commit 7ce6948b authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5GroupManager: Use PAS API level.

Avoids hardcoding PAS plugin ID.
Also, rename "user_name" to a mode precise PAS notion, to avoid confusion.
parent ce2eac2c
...@@ -86,7 +86,7 @@ class ERP5GroupManager(BasePlugin): ...@@ -86,7 +86,7 @@ class ERP5GroupManager(BasePlugin):
return () return ()
@UnrestrictedMethod @UnrestrictedMethod
def _getGroupsForPrincipal(user_name, path): def _getGroupsForPrincipal(user_id, path):
security_category_dict = {} # key is the base_category_list, security_category_dict = {} # key is the base_category_list,
# value is the list of fetched categories # value is the list of fetched categories
security_group_list = [] security_group_list = []
...@@ -117,16 +117,15 @@ class ERP5GroupManager(BasePlugin): ...@@ -117,16 +117,15 @@ class ERP5GroupManager(BasePlugin):
security_definition_list = mapping_method() security_definition_list = mapping_method()
# get the person from its login - no security check needed # get the person from its login - no security check needed
user_list = self.erp5_users.enumerateUsers(id=user_name) user_list = [
if not user_list: x for x in self.searchUsers(id=user_id, exact_match=True)
if 'path' in x
]
if len(user_list) != 1:
return () return ()
else: user, = user_list
path = user_list[0].get('path') path = user['path']
if path: person_object = self.getPortalObject().unrestrictedTraverse(path)
person_object = self.getPortalObject().unrestrictedTraverse(path)
else:
# not ERP5 user
return ()
# Fetch category values from defined scripts # Fetch category values from defined scripts
for (method_name, base_category_list) in security_definition_list: for (method_name, base_category_list) in security_definition_list:
...@@ -140,7 +139,7 @@ class ERP5GroupManager(BasePlugin): ...@@ -140,7 +139,7 @@ class ERP5GroupManager(BasePlugin):
# Currently, passing portal_type='' (instead of 'Person') # Currently, passing portal_type='' (instead of 'Person')
# is the only way to make the difference. # is the only way to make the difference.
security_category_list.extend( security_category_list.extend(
method(base_category_list, user_name, person_object, '') method(base_category_list, user_id, person_object, '')
) )
except ConflictError: except ConflictError:
raise raise
...@@ -183,7 +182,7 @@ class ERP5GroupManager(BasePlugin): ...@@ -183,7 +182,7 @@ class ERP5GroupManager(BasePlugin):
cache_factory='erp5_content_short') cache_factory='erp5_content_short')
return _getGroupsForPrincipal( return _getGroupsForPrincipal(
user_name=principal.getId(), user_id=principal.getId(),
path=self.getPhysicalPath()) path=self.getPhysicalPath())
......
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