Commit fe8638e1 authored by wenjie.zheng's avatar wenjie.zheng

Permission_role: directly uses Workflow definded getRoleList.

parent 262e68c3
......@@ -72,14 +72,15 @@ class PermissionRoles(XMLObject):
if self.is_selected == 1:
permission_id = int(self.id.split('_')[1])
role_id = int(self.id.split('_')[2])
LOG('zwj: Assign %s to %s' %(role_id, permission_id), WARNING, "in PermissionRole.")
permission_list = sorted(self.getParent().getParent().getManagedPermissionList())
role_list = sorted(["Anonymous", "Assignee", "Assignor", "Associate",
"Auditor", "Authenticated", "Author", "Manager",
"Member", "Owner", "Reviewer"])
### zwj: make sure here gets the right coordinates
# LOG('zwj: Assign %s to %s' %(role_id, permission_id), WARNING, "in PermissionRole.")
erp5workflow = self.getParent().getParent()
permission_list = sorted(erp5workflow.getManagedPermissionList())
role_list = erp5workflow.getRoleList()
permission = permission_list[permission_id]
role = role_list[role_id]
LOG('zwj: Assign %s to %s' %(role, permission), WARNING, "in PermissionRole.")
### zwj: check the name of the role and permission is the ones we want
#LOG('zwj: Assign %s to %s' %(role, permission), WARNING, "in PermissionRole.")
if role == 'None':
role = ['Manager']
return permission, role
......@@ -52,7 +52,6 @@ class State(XMLObject, XMLMatrix):
isRADContent = 1
###zwj: security features
erp5_permission_roles = {} # { permission: [role] or (role,) }
group_roles = None
# Declarative security
security = ClassSecurityInfo()
......@@ -175,12 +174,6 @@ class State(XMLObject, XMLMatrix):
kwd['base_id'] = 'movement'
return XMLMatrix.newCell(self, *kw, **kwd)
### matrix method
def setPermission(self, permission, acquired, roles, REQUEST=None):
"""Set a permission for this State."""
pr = self.erp5_permission_roles
......
......@@ -58,9 +58,7 @@ class Workflow(XMLObject):
### zwj: for security issue
managed_permission = ()
managed_role = ()
group = ()
erp5_permission_roles = {} # { permission: [role] or (role,) }
erp5_role_groups = ()
role_list = sorted(["Anonymous", "Assignee", "Assignor", "Associate",
"Auditor", "Authenticated", "Author", "Manager",
"Member", "Owner", "Reviewer"])
......@@ -175,22 +173,13 @@ class Workflow(XMLObject):
sdef = sdef = document._getDefaultAcquiredValue(self.getStateBaseCategory())
if sdef is None:
return 0
"""
# Update the role -> permission map.
if self.permissions:
for p in self.permissions:
roles = []
if sdef.erp5_permission_roles is not None: ### permission is defined in state
roles = sdef.erp5_permission_roles.get(p, roles)
if modifyRolesForPermission(document, p, roles):
changed = 1
"""
### zwj: get all matrix cell objects
permission_role_matrix_cells = sdef.objectValues(portal_type = "PermissionRoles")
### zwj: build a permission roles dict
for perm_role in permission_role_matrix_cells:
permission,role = perm_role.getPermissionRole()
LOG('zwj: Assign %s to %s' %(role, permission), WARNING, "in Workflow.")
### zwj: double check the right role and permission are obtained
#LOG('zwj: Assign %s to %s' %(role, permission), WARNING, "in Workflow.")
if permission != 'None':
if self.erp5_permission_roles.has_key(permission):
self.erp5_permission_roles[permission] += (role,)
......@@ -201,23 +190,14 @@ class Workflow(XMLObject):
for permission_roles in self.erp5_permission_roles.keys():
if modifyRolesForPermission(document, permission_roles, self.erp5_permission_roles[permission_roles]):
changed = 1
"""
# Update the group -> role map.
groups = self.getGroups()
managed_roles = self.getRoles()
if groups and managed_roles:
for group in groups:
roles = ()
if sdef.group_roles is not None:
roles = sdef.group_roles.get(group, ())
if modifyRolesForGroup(document, group, roles, managed_roles):
changed = 1
"""
return changed
def getRoleList(self):
return self.role_list
### zwj: unknown objective function
"""
def _checkTransitionGuard(self, t, document, **kw):
guard = t.guard
if guard is None:
......@@ -225,7 +205,7 @@ class Workflow(XMLObject):
if guard.check(getSecurityManager(), self, document, **kw):
return 1
return
"""
### Security feature end
###########
......
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