diff --git a/product/ERP5Type/DocumentationHelper/DCWorkflowDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/DCWorkflowDocumentationHelper.py index 1b738fa0bde2bd0b9307a56765c3ac71d6474b06..ddfbf2d69d1554a31ef5da1da70d83d7f2b0100c 100644 --- a/product/ERP5Type/DocumentationHelper/DCWorkflowDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/DCWorkflowDocumentationHelper.py @@ -32,26 +32,27 @@ from DocumentationHelper import DocumentationHelper from Products.ERP5Type import Permissions from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph -def getStatePermissionsOfRole(state=None, role=''): +def getStatePermissionsOfRole(state, role): + """ + Returns list of permissions for a given role with AVMC format above + A = Access contents information + V = View + M = Modify Portal Content + C = Add Portal Content + """ permissions = "" - if state != None: - if hasattr(state, '__dict__'): - if 'permission_roles' in state.__dict__.keys(): - if 'View' in state.__dict__['permission_roles'].keys(): - if role in state.__dict__['permission_roles']['View']: - permissions += "V" - if 'Access contents information' in state.__dict__['permission_roles'].keys(): - if role in state.__dict__['permission_roles']['Access contents information']: - permissions += "A" - if 'Modify portal content' in state.__dict__['permission_roles'].keys(): - if role in state.__dict__['permission_roles']['Modify portal content']: - permissions += "M" - if 'Add portal content' in state.__dict__['permission_roles'].keys(): - if role in state.__dict__['permission_roles']['Add portal content']: - permissions += "C" + permission_roles = state.permission_roles + if permission_roles: + if role in permission_roles.get('Access contents information', ()): + permissions += "A" + if role in permission_roles.get('View', ()): + permissions += "V" + if role in permission_roles.get('Modify portal content', ()): + permissions += "M" + if role in permission_roles.get('Add portal content', ()): + permissions += "C" return permissions - class DCWorkflowDocumentationHelper(DocumentationHelper): """ Provides access to all documentation information diff --git a/product/ERP5Type/DocumentationHelper/DCWorkflowStateDocumentationHelper.py b/product/ERP5Type/DocumentationHelper/DCWorkflowStateDocumentationHelper.py index 198d93a1d1d0b318524fc25ea0c6b04742577976..70a7c5286e4708ba6a1c120bb30c3feca07865d1 100644 --- a/product/ERP5Type/DocumentationHelper/DCWorkflowStateDocumentationHelper.py +++ b/product/ERP5Type/DocumentationHelper/DCWorkflowStateDocumentationHelper.py @@ -28,8 +28,9 @@ from AccessControl import ClassSecurityInfo from Globals import InitializeClass -from DocumentationHelper import DocumentationHelper from Products.ERP5Type import Permissions +from DocumentationHelper import DocumentationHelper +from DCWorkflowDocumentationHelper import getStatePermissionsOfRole class DCWorkflowStateDocumentationHelper(DocumentationHelper): """ @@ -53,25 +54,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): return self.getDocumentedObject().transitions def getPermissionsOfRole(self, role): - """ - Returns list of permissions for a given role with AVMC format above - A = Access contents information - V = View - M = Modify Portal Content - C = Add Portal Content - """ - permissions = "" - permission_roles = self.getDocumentedObject().permission_roles - if permission_roles: - if role in state.permission_roles.get('Access contents information', ()): - permissions += "A" - if role in state.permission_roles.get('View', ()): - permissions += "V" - if role in state.permission_roles.get('Modify portal content', ()): - permissions += "M" - if role in state.permission_roles.get('Add portal content', ()): - permissions += "C" - return permissions + return getStatePermissionsOfRole(self.getDocumentedObject(), role) security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner') def getPermissionsOfRoleOwner(self):