Commit 5fb2df6c authored by Nicolas Delaby's avatar Nicolas Delaby

Do not cast roles to tuple if one of other workflows use a list type

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29527 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3fbccf4c
# -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
...@@ -476,6 +477,7 @@ def updateRoleMappingsFor(self, ob): ...@@ -476,6 +477,7 @@ def updateRoleMappingsFor(self, ob):
roles = [] roles = []
refused_roles = [] refused_roles = []
role_type = 'list' role_type = 'list'
other_role_type_list = []
if sdef.permission_roles is not None: if sdef.permission_roles is not None:
roles = sdef.permission_roles.get(p, roles) roles = sdef.permission_roles.get(p, roles)
if type(roles) is type(()): if type(roles) is type(()):
...@@ -487,14 +489,17 @@ def updateRoleMappingsFor(self, ob): ...@@ -487,14 +489,17 @@ def updateRoleMappingsFor(self, ob):
if p in other_workflow.permissions: if p in other_workflow.permissions:
other_roles = other_sdef.permission_roles.get(p, []) other_roles = other_sdef.permission_roles.get(p, [])
if type(other_roles) is type(()) : if type(other_roles) is type(()) :
role_type = 'tuple' other_role_type_list.append('tuple')
else:
other_role_type_list.append('list')
for role in roles: for role in roles:
if role not in other_roles : if role not in other_roles :
refused_roles.append(role) refused_roles.append(role)
for role in refused_roles : for role in refused_roles :
if role in roles : if role in roles :
roles.remove(role) roles.remove(role)
if role_type=='tuple': if role_type == 'tuple' and ((not other_role_type_list) or ('list' not in other_role_type_list)):
#If at least, one of other workflows manage security and for all are role_type are tuple
roles = tuple(roles) roles = tuple(roles)
if modifyRolesForPermission(ob, p, roles): if modifyRolesForPermission(ob, p, roles):
changed = 1 changed = 1
......
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