Commit 879c7f40 authored by Jérome Perrin's avatar Jérome Perrin

core: support Manager user in Base_getDialogSectionCategoryItemList

Base_getDialogSectionCategoryItemList was supporting the case of
users from zodb_users plugin, but not the case of ERP5 users with
roles set from zodb_roles.

It's a more and more common case to make manager users using a
"normal" ERP5 user as person (so that we can reset password etc)
and to give Manager role by zodb_roles, but this was not supported
by this script.
parent e6f788f7
Pipeline #11941 failed with stage
in 0 seconds
......@@ -1902,3 +1902,21 @@ class Base_getDialogSectionCategoryItemListTest(ERP5TypeTestCase):
],
['Another Top Level Group', 'group/main_group_2'],
])
def test_person_user_with_manager_role_added_by_zodb_roles(self):
self.person.newContent(portal_type='Assignment').open()
self.tic()
self.portal.acl_users.zodb_roles.doAssignRoleToPrincipal(self.user_id, 'Manager')
self.login(self.user_id)
self.assertEqual(
self.portal.Base_getDialogSectionCategoryItemList(), [
['', ''],
['Main Group', 'group/main_group'],
['Main Group/Sub Group', 'group/main_group/sub_group'],
[
'Main Group/Another Sub Group',
'group/main_group/another_sub_group'
],
['Another Top Level Group', 'group/main_group_2'],
])
......@@ -11,7 +11,11 @@ group_title_item_list = portal.Base_getPreferredCategoryChildItemList(
base=True,
)
user = portal.portal_membership.getAuthenticatedMember().getUserValue()
zope_user = portal.portal_membership.getAuthenticatedMember()
if 'Manager' in zope_user.getRolesInContext(context):
return group_title_item_list
user = zope_user.getUserValue()
if getattr(user, 'getPortalType', lambda: None)() != 'Person':
return group_title_item_list
......
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