Commit 67337cd1 authored by Julien Muchembled's avatar Julien Muchembled

Fix display of permissions on workflow states.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25612 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5fd031ec
......@@ -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']:
permission_roles = state.permission_roles
if permission_roles:
if role in permission_roles.get('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']:
if role in permission_roles.get('View', ()):
permissions += "V"
if role in permission_roles.get('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']:
if role in permission_roles.get('Add portal content', ()):
permissions += "C"
return permissions
class DCWorkflowDocumentationHelper(DocumentationHelper):
"""
Provides access to all documentation information
......
......@@ -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):
......
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