From bbc09fc2345fe9d4fb32b30214d36bb48efcfbf8 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Tue, 20 Dec 2016 08:19:00 +0100 Subject: [PATCH] fixup! Use PAS API. --- .../erp5_core/Base_getOwnerTitle.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getOwnerTitle.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getOwnerTitle.py index 066d9c2451..99e8c613c2 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getOwnerTitle.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getOwnerTitle.py @@ -1,9 +1,15 @@ """Returns the name of the owner of current document """ -owner_id_list = [i[0] for i in context.get_local_roles() if 'Owner' in i[1]] -if owner_id_list: - found_user_path_set = {x['path'] for x in context.acl_users.searchUsers(id=tuple(owner_id_list), exact_match=True) if 'path' in x} - if found_user_path_set: - found_user_path, = found_user_path_set - return context.getPortalObject().restrictedTraverse(found_user_path).getTitle() - return owner_id_list[0] +from zExceptions import Unauthorized +# A single value is generally expecteted, do not bother optimising for other cases unless necessary. +owner_id = None +for user_id, role_set in context.get_local_roles(): + if 'Owner' in role_set: + owner_id = user_id + try: + user = context.Base_getUserValueByUserId(user_id) + if user is not None: + return user.getTitle() + except Unauthorized: + pass +return owner_id -- 2.30.9