Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
fe8638e1
Commit
fe8638e1
authored
Jan 27, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permission_role: directly uses Workflow definded getRoleList.
parent
262e68c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
39 deletions
+13
-39
product/ERP5Workflow/Document/PermissionRoles.py
product/ERP5Workflow/Document/PermissionRoles.py
+7
-6
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+0
-7
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+6
-26
No files found.
product/ERP5Workflow/Document/PermissionRoles.py
View file @
fe8638e1
...
@@ -72,14 +72,15 @@ class PermissionRoles(XMLObject):
...
@@ -72,14 +72,15 @@ class PermissionRoles(XMLObject):
if
self
.
is_selected
==
1
:
if
self
.
is_selected
==
1
:
permission_id
=
int
(
self
.
id
.
split
(
'_'
)[
1
])
permission_id
=
int
(
self
.
id
.
split
(
'_'
)[
1
])
role_id
=
int
(
self
.
id
.
split
(
'_'
)[
2
])
role_id
=
int
(
self
.
id
.
split
(
'_'
)[
2
])
LOG
(
'zwj: Assign %s to %s'
%
(
role_id
,
permission_id
),
WARNING
,
"in PermissionRole."
)
### zwj: make sure here gets the right coordinates
permission_list
=
sorted
(
self
.
getParent
().
getParent
().
getManagedPermissionList
()
)
# LOG('zwj: Assign %s to %s' %(role_id, permission_id), WARNING, "in PermissionRole."
)
role_list
=
sorted
([
"Anonymous"
,
"Assignee"
,
"Assignor"
,
"Associate"
,
erp5workflow
=
self
.
getParent
().
getParent
()
"Auditor"
,
"Authenticated"
,
"Author"
,
"Manager"
,
permission_list
=
sorted
(
erp5workflow
.
getManagedPermissionList
())
"Member"
,
"Owner"
,
"Reviewer"
]
)
role_list
=
erp5workflow
.
getRoleList
(
)
permission
=
permission_list
[
permission_id
]
permission
=
permission_list
[
permission_id
]
role
=
role_list
[
role_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'
:
if
role
==
'None'
:
role
=
[
'Manager'
]
role
=
[
'Manager'
]
return
permission
,
role
return
permission
,
role
product/ERP5Workflow/Document/State.py
View file @
fe8638e1
...
@@ -52,7 +52,6 @@ class State(XMLObject, XMLMatrix):
...
@@ -52,7 +52,6 @@ class State(XMLObject, XMLMatrix):
isRADContent
=
1
isRADContent
=
1
###zwj: security features
###zwj: security features
erp5_permission_roles
=
{}
# { permission: [role] or (role,) }
erp5_permission_roles
=
{}
# { permission: [role] or (role,) }
group_roles
=
None
# Declarative security
# Declarative security
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -175,12 +174,6 @@ class State(XMLObject, XMLMatrix):
...
@@ -175,12 +174,6 @@ class State(XMLObject, XMLMatrix):
kwd
[
'base_id'
]
=
'movement'
kwd
[
'base_id'
]
=
'movement'
return
XMLMatrix
.
newCell
(
self
,
*
kw
,
**
kwd
)
return
XMLMatrix
.
newCell
(
self
,
*
kw
,
**
kwd
)
### matrix method
def
setPermission
(
self
,
permission
,
acquired
,
roles
,
REQUEST
=
None
):
def
setPermission
(
self
,
permission
,
acquired
,
roles
,
REQUEST
=
None
):
"""Set a permission for this State."""
"""Set a permission for this State."""
pr
=
self
.
erp5_permission_roles
pr
=
self
.
erp5_permission_roles
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
fe8638e1
...
@@ -58,9 +58,7 @@ class Workflow(XMLObject):
...
@@ -58,9 +58,7 @@ class Workflow(XMLObject):
### zwj: for security issue
### zwj: for security issue
managed_permission
=
()
managed_permission
=
()
managed_role
=
()
managed_role
=
()
group
=
()
erp5_permission_roles
=
{}
# { permission: [role] or (role,) }
erp5_permission_roles
=
{}
# { permission: [role] or (role,) }
erp5_role_groups
=
()
role_list
=
sorted
([
"Anonymous"
,
"Assignee"
,
"Assignor"
,
"Associate"
,
role_list
=
sorted
([
"Anonymous"
,
"Assignee"
,
"Assignor"
,
"Associate"
,
"Auditor"
,
"Authenticated"
,
"Author"
,
"Manager"
,
"Auditor"
,
"Authenticated"
,
"Author"
,
"Manager"
,
"Member"
,
"Owner"
,
"Reviewer"
])
"Member"
,
"Owner"
,
"Reviewer"
])
...
@@ -175,22 +173,13 @@ class Workflow(XMLObject):
...
@@ -175,22 +173,13 @@ class Workflow(XMLObject):
sdef
=
sdef
=
document
.
_getDefaultAcquiredValue
(
self
.
getStateBaseCategory
())
sdef
=
sdef
=
document
.
_getDefaultAcquiredValue
(
self
.
getStateBaseCategory
())
if
sdef
is
None
:
if
sdef
is
None
:
return
0
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
### zwj: get all matrix cell objects
permission_role_matrix_cells
=
sdef
.
objectValues
(
portal_type
=
"PermissionRoles"
)
permission_role_matrix_cells
=
sdef
.
objectValues
(
portal_type
=
"PermissionRoles"
)
### zwj: build a permission roles dict
### zwj: build a permission roles dict
for
perm_role
in
permission_role_matrix_cells
:
for
perm_role
in
permission_role_matrix_cells
:
permission
,
role
=
perm_role
.
getPermissionRole
()
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
permission
!=
'None'
:
if
self
.
erp5_permission_roles
.
has_key
(
permission
):
if
self
.
erp5_permission_roles
.
has_key
(
permission
):
self
.
erp5_permission_roles
[
permission
]
+=
(
role
,)
self
.
erp5_permission_roles
[
permission
]
+=
(
role
,)
...
@@ -201,23 +190,14 @@ class Workflow(XMLObject):
...
@@ -201,23 +190,14 @@ class Workflow(XMLObject):
for
permission_roles
in
self
.
erp5_permission_roles
.
keys
():
for
permission_roles
in
self
.
erp5_permission_roles
.
keys
():
if
modifyRolesForPermission
(
document
,
permission_roles
,
self
.
erp5_permission_roles
[
permission_roles
]):
if
modifyRolesForPermission
(
document
,
permission_roles
,
self
.
erp5_permission_roles
[
permission_roles
]):
changed
=
1
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
return
changed
def
getRoleList
(
self
):
def
getRoleList
(
self
):
return
self
.
role_list
return
self
.
role_list
### zwj: unknown objective function
"""
def _checkTransitionGuard(self, t, document, **kw):
def _checkTransitionGuard(self, t, document, **kw):
guard = t.guard
guard = t.guard
if guard is None:
if guard is None:
...
@@ -225,7 +205,7 @@ class Workflow(XMLObject):
...
@@ -225,7 +205,7 @@ class Workflow(XMLObject):
if guard.check(getSecurityManager(), self, document, **kw):
if guard.check(getSecurityManager(), self, document, **kw):
return 1
return 1
return
return
"""
### Security feature end
### Security feature end
###########
###########
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment