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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastien Robin
erp5
Commits
e0b58aa3
Commit
e0b58aa3
authored
Oct 12, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: rename and fix state_permission_roles
parent
92cfba78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
19 deletions
+30
-19
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+16
-4
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+14
-15
No files found.
product/ERP5Workflow/Document/State.py
View file @
e0b58aa3
...
...
@@ -67,6 +67,7 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
default_reference
=
''
state_type
=
()
acquire_permission
=
[]
state_permission_roles_dict
=
{}
# Declarative security
security
=
ClassSecurityInfo
()
...
...
@@ -113,15 +114,26 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
# return possible transition id list:
return
self
.
getDestinationIdList
()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'setStatePermissionRolesDict'
)
def
setStatePermissionRolesDict
(
self
,
permission_roles
):
"""
create a dict containing state/permission role dict
create a dict containing the state's permission (as key) and its
associated role list (value)
use a PersistentMapping so that the ZODB is updated
when this dict is changed
"""
self
.
state_permission_roles
=
PersistentMapping
(
permission_roles
)
self
.
state_permission_roles_dict
=
PersistentMapping
(
permission_roles
)
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'getStatePermissionRolesDict'
)
def
getStatePermissionRolesDict
(
self
):
"""
return the permission/roles dict
"""
if
self
.
state_permission_roles_dict
is
None
:
return
{}
return
self
.
state_permission_roles_dict
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setPermission'
)
...
...
@@ -129,7 +141,7 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
Set a permission for this State.
"""
self
.
state_permission_roles
[
permission
]
=
list
(
roles
)
self
.
state_permission_roles
_dict
[
permission
]
=
list
(
roles
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAvailableTypeList'
)
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
e0b58aa3
...
...
@@ -227,16 +227,15 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state
=
self
.
_getWorkflowStateOf
(
document
,
id_only
=
False
)
if
state
is
not
None
:
state_permission_list
=
state
.
getAcquirePermissionList
()
if
hasattr
(
state
,
'getStatePermissionRolesDict'
):
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if
permission
in
state_permission_list
:
role_list
=
list
(
role_list
)
else
:
role_list
=
tuple
(
role_list
)
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
changed
=
True
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if
permission
in
state_permission_list
:
role_list
=
list
(
role_list
)
else
:
role_list
=
tuple
(
role_list
)
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
changed
=
True
return
changed
# This method allows to update all objects using one workflow, for example
...
...
@@ -872,8 +871,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state
=
SubElement
(
states
,
'state'
,
attrib
=
dict
(
reference
=
sdef
.
getReference
(),
portal_type
=
sdef
.
getPortalType
()))
for
property_id
in
sorted
(
state_prop_id_to_show
):
if
property_id
==
'permission_roles'
:
property_value
=
sdef
.
getProperty
(
'state_permission_roles'
)
property_type
=
sdef
.
getPropertyType
(
'state_permission_roles'
)
property_value
=
sdef
.
getProperty
(
'state_permission_roles
_dict
'
)
property_type
=
sdef
.
getPropertyType
(
'state_permission_roles
_dict
'
)
elif
property_id
==
'transitions'
:
property_value
=
sdef
.
getDestinationIdList
()
destination_list
=
[]
...
...
@@ -1204,11 +1203,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for
permission
in
permission_list
:
permission_roles_dict
=
state
.
getStatePermissionRolesDict
()
if
permission
not
in
permission_roles_dict
:
state
.
state_permission_roles
[
permission
]
=
[]
# remove permission from state_permission_roles
dict
state
.
state_permission_roles
_dict
[
permission
]
=
[]
# remove permission from state_permission_roles
_
dict
permission_to_delete
=
[]
for
permission
in
permission_roles_dict
:
if
permission
not
in
permission_list
:
permission_to_delete
.
append
(
permission
)
for
permission
in
permission_to_delete
:
del
state
.
state_permission_roles
[
permission
]
del
state
.
state_permission_roles
_dict
[
permission
]
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