Commit c6590a7b authored by Julien Muchembled's avatar Julien Muchembled

* Show acquired permissions on workflow states.

* Display security settings for all permissions on workflow states.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25678 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6568eeef
......@@ -33,6 +33,12 @@ from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph
permission_code_dict = { 'Access contents information': (0, 'A')
, 'View' : (1, 'V')
, 'Modify portal content' : (2, 'M')
, 'Add portal content' : (3, 'C')
}
def getRoleList(workflow):
role_set = set()
for state in workflow.states.objectValues():
......@@ -164,11 +170,23 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionList')
def getPermissionList(self):
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionItemList')
def getPermissionItemList(self, **kw):
"""
"""
return getattr(self.getDocumentedObject(), "permissions", ())
permission_list = []
extra_code = 0
for permission in sorted(getattr(self.getDocumentedObject(),
"permissions", ())):
permission_code = permission_code_dict.get(permission)
if permission_code:
permission_code = permission_code[1]
else:
permission_code = str(extra_code)
extra_code += 1
permission_list.append(self.asContext(permission=permission,
code=permission_code))
return permission_list
security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistIdList')
def getWorklistIdList(self):
......
......@@ -30,7 +30,7 @@ from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.ERP5Type import Permissions
from DocumentationHelper import DocumentationHelper
from DCWorkflowDocumentationHelper import getRoleList
from DCWorkflowDocumentationHelper import getRoleList, permission_code_dict
class DCWorkflowStateDocumentationHelper(DocumentationHelper):
"""
......@@ -62,6 +62,12 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
"""
return getRoleList(self.getDocumentedObject().getWorkflow())
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquiredPermissions')
def getAcquiredPermissions(self):
"""
"""
return self.getPermissionsOfRole(None)
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsList')
def getPermissionsList(self):
"""
......@@ -76,17 +82,25 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
M = Modify Portal Content
C = Add Portal Content
"""
permissions = ""
permission_roles = self.getDocumentedObject().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"
permissions = []
state = self.getDocumentedObject()
permission_list = getattr(state.getWorkflow(), 'permissions', ())
if permission_list:
extra_sort = len(permission_code_dict)
extra_code = 0
for permission in sorted(permission_list):
permission_code = permission_code_dict.get(permission)
if permission_code is None:
permission_code = extra_sort, str(extra_code)
extra_code += 1
permission_info = state.getPermissionInfo(permission)
if role and role in permission_info['roles'] \
or not role and permission_info['acquired']:
permissions.append(permission_code)
permissions.sort()
permissions = ''.join(y for x,y in permissions)
return permissions
......
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