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
iv
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
...
@@ -67,6 +67,7 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
default_reference
=
''
default_reference
=
''
state_type
=
()
state_type
=
()
acquire_permission
=
[]
acquire_permission
=
[]
state_permission_roles_dict
=
{}
# Declarative security
# Declarative security
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
...
@@ -113,15 +114,26 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
...
@@ -113,15 +114,26 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
# return possible transition id list:
# return possible transition id list:
return
self
.
getDestinationIdList
()
return
self
.
getDestinationIdList
()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'setStatePermissionRolesDict'
)
'setStatePermissionRolesDict'
)
def
setStatePermissionRolesDict
(
self
,
permission_roles
):
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
use a PersistentMapping so that the ZODB is updated
when this dict is changed
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
,
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'setPermission'
)
'setPermission'
)
...
@@ -129,7 +141,7 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
...
@@ -129,7 +141,7 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
"""
Set a permission for this State.
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
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getAvailableTypeList'
)
'getAvailableTypeList'
)
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
e0b58aa3
...
@@ -227,16 +227,15 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...
@@ -227,16 +227,15 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state
=
self
.
_getWorkflowStateOf
(
document
,
id_only
=
False
)
state
=
self
.
_getWorkflowStateOf
(
document
,
id_only
=
False
)
if
state
is
not
None
:
if
state
is
not
None
:
state_permission_list
=
state
.
getAcquirePermissionList
()
state_permission_list
=
state
.
getAcquirePermissionList
()
if
hasattr
(
state
,
'getStatePermissionRolesDict'
):
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
for
permission
,
role_list
in
state
.
getStatePermissionRolesDict
().
items
():
# tuple means "don't acquire" in zope internal security and list
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
# is used when acquisition should be done
if
permission
in
state_permission_list
:
if
permission
in
state_permission_list
:
role_list
=
list
(
role_list
)
role_list
=
list
(
role_list
)
else
:
else
:
role_list
=
tuple
(
role_list
)
role_list
=
tuple
(
role_list
)
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
if
modifyRolesForPermission
(
document
,
permission
,
role_list
):
changed
=
True
changed
=
True
return
changed
return
changed
# This method allows to update all objects using one workflow, for example
# This method allows to update all objects using one workflow, for example
...
@@ -872,8 +871,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...
@@ -872,8 +871,8 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state
=
SubElement
(
states
,
'state'
,
attrib
=
dict
(
reference
=
sdef
.
getReference
(),
portal_type
=
sdef
.
getPortalType
()))
state
=
SubElement
(
states
,
'state'
,
attrib
=
dict
(
reference
=
sdef
.
getReference
(),
portal_type
=
sdef
.
getPortalType
()))
for
property_id
in
sorted
(
state_prop_id_to_show
):
for
property_id
in
sorted
(
state_prop_id_to_show
):
if
property_id
==
'permission_roles'
:
if
property_id
==
'permission_roles'
:
property_value
=
sdef
.
getProperty
(
'state_permission_roles'
)
property_value
=
sdef
.
getProperty
(
'state_permission_roles
_dict
'
)
property_type
=
sdef
.
getPropertyType
(
'state_permission_roles'
)
property_type
=
sdef
.
getPropertyType
(
'state_permission_roles
_dict
'
)
elif
property_id
==
'transitions'
:
elif
property_id
==
'transitions'
:
property_value
=
sdef
.
getDestinationIdList
()
property_value
=
sdef
.
getDestinationIdList
()
destination_list
=
[]
destination_list
=
[]
...
@@ -1204,11 +1203,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...
@@ -1204,11 +1203,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for
permission
in
permission_list
:
for
permission
in
permission_list
:
permission_roles_dict
=
state
.
getStatePermissionRolesDict
()
permission_roles_dict
=
state
.
getStatePermissionRolesDict
()
if
permission
not
in
permission_roles_dict
:
if
permission
not
in
permission_roles_dict
:
state
.
state_permission_roles
[
permission
]
=
[]
state
.
state_permission_roles
_dict
[
permission
]
=
[]
# remove permission from state_permission_roles
dict
# remove permission from state_permission_roles
_
dict
permission_to_delete
=
[]
permission_to_delete
=
[]
for
permission
in
permission_roles_dict
:
for
permission
in
permission_roles_dict
:
if
permission
not
in
permission_list
:
if
permission
not
in
permission_list
:
permission_to_delete
.
append
(
permission
)
permission_to_delete
.
append
(
permission
)
for
permission
in
permission_to_delete
:
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