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
00aa62f6
Commit
00aa62f6
authored
Dec 07, 2016
by
iv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: minor improvements
improve for loop, call less time the same method, ...
parent
c43e12ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+2
-1
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+10
-9
No files found.
product/ERP5Workflow/Document/State.py
View file @
00aa62f6
...
@@ -113,7 +113,8 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
...
@@ -113,7 +113,8 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
instead of getting all the transition objects from the destination list
instead of getting all the transition objects from the destination list
to then use their ids, extract the information from the string
to then use their ids, extract the information from the string
"""
"""
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getDestinationList
()]
return
[
path
.
split
(
'/'
)[
-
1
]
for
path
in
self
.
getCategoryList
()
if
path
.
startswith
(
'destination/'
)]
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getDestinationValueList'
)
'getDestinationValueList'
)
...
...
product/ERP5Workflow/Document/Workflow.py
View file @
00aa62f6
...
@@ -257,18 +257,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
...
@@ -257,18 +257,19 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
state
=
self
.
_getWorkflowStateOf
(
ob
)
state
=
self
.
_getWorkflowStateOf
(
ob
)
tool
=
aq_parent
(
aq_inner
(
self
))
tool
=
aq_parent
(
aq_inner
(
self
))
other_workflow_list
=
[
x
for
x
in
tool
.
getWorkflowsFor
(
ob
)
if
x
.
id
!=
self
.
id
and
x
.
getPortalType
()
in
(
'DCWorkflowDefinition'
,
'Workflow'
)]
other_data_list
=
[]
other_data_list
=
[]
new_permission_roles_dict
=
{}
new_permission_roles_dict
=
{}
for
other_workflow
in
other_workflow_list
:
for
other_workflow
in
tool
.
getWorkflowsFor
(
ob
):
if
other_workflow
.
id
==
self
.
id
or
other_workflow
.
getPortalType
()
in
\
(
'DCWorkflowDefinition'
,
'Workflow'
):
continue
other_state
=
other_workflow
.
_getWorkflowStateOf
(
ob
)
other_state
=
other_workflow
.
_getWorkflowStateOf
(
ob
)
if
other_state
is
not
None
:
if
other_state
is
not
None
:
other_state_permission_roles_dict
=
other_state
.
getStatePermissionRolesDict
()
other_state_permission_roles_dict
=
other_state
.
getStatePermissionRolesDict
()
if
other_state_permission_roles_dict
is
not
None
:
if
other_state_permission_roles_dict
is
not
None
:
other_data_list
.
append
((
other_workflow
,
other_state
))
other_data_list
.
append
((
other_workflow
,
other_state
,
other_state_permission_roles_dict
))
# Be carefull, permissions_roles should not change
# Be carefull, permissions_roles should not change
# from list to tuple or vice-versa. (in modifyRolesForPermission,
# from list to tuple or vice-versa. (in modifyRolesForPermission,
# list means acquire roles, tuple means do not acquire)
# list means acquire roles, tuple means do not acquire)
...
@@ -284,9 +285,9 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
...
@@ -284,9 +285,9 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
roles
=
list
(
roles
)
roles
=
list
(
roles
)
# We will check that each role is activated
# We will check that each role is activated
# in each DCWorkflow
# in each DCWorkflow
for
other_workflow
,
other_state
in
other_data_list
:
for
other_workflow
,
other_state
,
other_state_permission_roles_dict
in
other_data_list
:
if
p
in
other_workflow
.
workflow_managed_permission
:
if
p
in
other_workflow
.
workflow_managed_permission
:
other_roles
=
other_state
.
getStatePermissionRolesDict
()
.
get
(
p
,
[])
other_roles
=
other_state
_permission_roles_dict
.
get
(
p
,
[])
other_role_type_list
.
append
(
type
(
other_roles
))
other_role_type_list
.
append
(
type
(
other_roles
))
for
role
in
roles
:
for
role
in
roles
:
if
role
not
in
other_roles
:
if
role
not
in
other_roles
:
...
@@ -722,7 +723,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
...
@@ -722,7 +723,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
new_state
=
old_state
new_state
=
old_state
else
:
else
:
new_state
=
new_sdef
.
getReference
()
new_state
=
new_sdef
.
getReference
()
former_status
=
s
elf
.
getCurrentStatusDict
(
document
)
former_status
=
s
tatus_dict
# Execute the "before" script.
# Execute the "before" script.
before_script_success
=
1
before_script_success
=
1
...
@@ -1165,7 +1166,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
...
@@ -1165,7 +1166,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject, CacheCookieMixin):
# Figure out the old and new states.
# Figure out the old and new states.
old_sdef
=
self
.
_getWorkflowStateOf
(
ob
)
old_sdef
=
self
.
_getWorkflowStateOf
(
ob
)
if
old_sdef
is
None
:
if
old_sdef
is
None
:
old_state
=
s
elf
.
_getWorkflowStateOf
(
ob
,
id_only
=
True
)
old_state
=
s
tate
.
getReference
(
)
else
:
else
:
old_state
=
old_sdef
.
getId
()
old_state
=
old_sdef
.
getId
()
if
old_state
==
new_state_id
:
if
old_state
==
new_state_id
:
...
...
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