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 ...@@ -32,26 +32,27 @@ from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph 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 = "" permissions = ""
if state != None: permission_roles = state.permission_roles
if hasattr(state, '__dict__'): if permission_roles:
if 'permission_roles' in state.__dict__.keys(): if role in permission_roles.get('Access contents information', ()):
if 'View' in state.__dict__['permission_roles'].keys(): permissions += "A"
if role in state.__dict__['permission_roles']['View']: if role in permission_roles.get('View', ()):
permissions += "V" permissions += "V"
if 'Access contents information' in state.__dict__['permission_roles'].keys(): if role in permission_roles.get('Modify portal content', ()):
if role in state.__dict__['permission_roles']['Access contents information']: permissions += "M"
permissions += "A" if role in permission_roles.get('Add portal content', ()):
if 'Modify portal content' in state.__dict__['permission_roles'].keys(): permissions += "C"
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"
return permissions return permissions
class DCWorkflowDocumentationHelper(DocumentationHelper): class DCWorkflowDocumentationHelper(DocumentationHelper):
""" """
Provides access to all documentation information Provides access to all documentation information
......
...@@ -28,8 +28,9 @@ ...@@ -28,8 +28,9 @@
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from DocumentationHelper import DocumentationHelper
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from DocumentationHelper import DocumentationHelper
from DCWorkflowDocumentationHelper import getStatePermissionsOfRole
class DCWorkflowStateDocumentationHelper(DocumentationHelper): class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
...@@ -53,25 +54,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -53,25 +54,7 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
return self.getDocumentedObject().transitions return self.getDocumentedObject().transitions
def getPermissionsOfRole(self, role): def getPermissionsOfRole(self, role):
""" return getStatePermissionsOfRole(self.getDocumentedObject(), 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
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner') security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsOfRoleOwner')
def getPermissionsOfRoleOwner(self): 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