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 ...@@ -33,6 +33,12 @@ from Products.ERP5Type import Permissions
from Products.DCWorkflowGraph.DCWorkflowGraph import getGraph 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): def getRoleList(workflow):
role_set = set() role_set = set()
for state in workflow.states.objectValues(): for state in workflow.states.objectValues():
...@@ -164,11 +170,23 @@ class DCWorkflowDocumentationHelper(DocumentationHelper): ...@@ -164,11 +170,23 @@ class DCWorkflowDocumentationHelper(DocumentationHelper):
variable_id_list = self.getVariableIdList() variable_id_list = self.getVariableIdList()
return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list) return map(lambda x: ('%s/variables/%s' % (self.uri, x)), variable_id_list)
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionList') security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionItemList')
def getPermissionList(self): 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') security.declareProtected(Permissions.AccessContentsInformation, 'getWorklistIdList')
def getWorklistIdList(self): def getWorklistIdList(self):
......
...@@ -30,7 +30,7 @@ from AccessControl import ClassSecurityInfo ...@@ -30,7 +30,7 @@ from AccessControl import ClassSecurityInfo
from Globals import InitializeClass from Globals import InitializeClass
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from DocumentationHelper import DocumentationHelper from DocumentationHelper import DocumentationHelper
from DCWorkflowDocumentationHelper import getRoleList from DCWorkflowDocumentationHelper import getRoleList, permission_code_dict
class DCWorkflowStateDocumentationHelper(DocumentationHelper): class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
...@@ -62,6 +62,12 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -62,6 +62,12 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
""" """
return getRoleList(self.getDocumentedObject().getWorkflow()) return getRoleList(self.getDocumentedObject().getWorkflow())
security.declareProtected(Permissions.AccessContentsInformation, 'getAcquiredPermissions')
def getAcquiredPermissions(self):
"""
"""
return self.getPermissionsOfRole(None)
security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsList') security.declareProtected(Permissions.AccessContentsInformation, 'getPermissionsList')
def getPermissionsList(self): def getPermissionsList(self):
""" """
...@@ -76,17 +82,25 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper): ...@@ -76,17 +82,25 @@ class DCWorkflowStateDocumentationHelper(DocumentationHelper):
M = Modify Portal Content M = Modify Portal Content
C = Add Portal Content C = Add Portal Content
""" """
permissions = "" permissions = []
permission_roles = self.getDocumentedObject().permission_roles state = self.getDocumentedObject()
if permission_roles: permission_list = getattr(state.getWorkflow(), 'permissions', ())
if role in permission_roles.get('Access contents information', ()): if permission_list:
permissions += "A" extra_sort = len(permission_code_dict)
if role in permission_roles.get('View', ()): extra_code = 0
permissions += "V" for permission in sorted(permission_list):
if role in permission_roles.get('Modify portal content', ()): permission_code = permission_code_dict.get(permission)
permissions += "M" if permission_code is None:
if role in permission_roles.get('Add portal content', ()): permission_code = extra_sort, str(extra_code)
permissions += "C" 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 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