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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
erp5
Commits
63e5b34f
Commit
63e5b34f
authored
Jun 22, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workflow.py: showAsXML has the same structure as DCWorkflow_showAsXML.
parent
32208a44
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
16 deletions
+39
-16
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+39
-16
No files found.
product/ERP5Workflow/Document/Workflow.py
View file @
63e5b34f
...
...
@@ -741,14 +741,29 @@ class Workflow(IdAsReferenceMixin("workflow_", "prefix"), XMLObject):
root
=
Element
(
'erp5'
)
return_as_object
=
False
# Define a list of property to show to users:
workflow_prop_id_to_show
=
[
'title'
,
'description'
,
'state_var'
,
'permissions'
,
'initial_state'
]
# workflow as XML, need to rename DC workflow's portal_type before comparison.
workflow
=
SubElement
(
root
,
'workflow'
,
attrib
=
dict
(
id
=
self
.
get
Id
(),
attrib
=
dict
(
id
=
self
.
get
Reference
(),
portal_type
=
self
.
getPortalType
()))
"""
for prop_id in sorted(
self.propertyIds()
):
for
prop_id
in
sorted
(
workflow_prop_id_to_show
):
# In most case, we should not synchronize acquired properties
if
prop_id
not
in
(
'uid'
,
'workflow_history'
,
'id'
,
'portal_type'
,):
if
prop_id
==
'permissions'
:
value
=
self
.
getProperty
(
'workflow_managed_permission_list'
)
prop_type
=
self
.
getPropertyType
(
'workflow_managed_permission_list'
)
sub_object
=
SubElement
(
workflow
,
prop_id
,
attrib
=
dict
(
type
=
prop_type
))
elif
prop_id
==
'initial_state'
:
value
=
self
.
getSourceValue
().
getReference
()
sub_object
=
SubElement
(
workflow
,
prop_id
,
attrib
=
dict
(
type
=
'string'
))
elif
prop_id
==
'state_var'
:
value
=
self
.
getProperty
(
'state_variable'
)
sub_object
=
SubElement
(
workflow
,
prop_id
,
attrib
=
dict
(
type
=
'string'
))
else
:
value
=
self
.
getProperty
(
prop_id
)
if
value
is
None
:
# not registered if not defined.
...
...
@@ -774,6 +789,10 @@ class Workflow(IdAsReferenceMixin("workflow_", "prefix"), XMLObject):
else
:
raise
ValueError
(
"XMLExportImport failed, the data is undefined"
)
elif
prop_type
in
(
'lines'
,
'tokens'
,):
if
prop_id
==
'initial_state'
:
if
self
.
getSourceValue
():
sub_object
.
text
=
self
.
getSourceValue
().
getReference
()
else
:
value
=
[
word
.
decode
(
'utf-8'
).
encode
(
'ascii'
,
'xmlcharrefreplace'
)
\
for
word
in
value
]
sub_object
.
append
(
marshaller
(
value
))
...
...
@@ -784,6 +803,7 @@ class Workflow(IdAsReferenceMixin("workflow_", "prefix"), XMLObject):
sub_object
.
text
=
unicode
(
escape
(
value
),
'utf-8'
)
elif
prop_type
!=
'None'
:
sub_object
.
text
=
str
(
value
)
"""
# We should now describe security settings
for user_role in self.get_local_roles():
local_role_node = SubElement(workflow, 'local_role',
...
...
@@ -806,19 +826,20 @@ class Workflow(IdAsReferenceMixin("workflow_", "prefix"), XMLObject):
local_group_node = SubElement(workflow, 'local_group',
attrib=dict(id=group_role[0], type='tokens'))
local_group_node.append(marshaller(group_role[1]))
"""
# 1. State as XML
state_reference_list = []
state_list = self.objectValues(portal_type='State')
# show reference instead of id
state_prop_id_to_show = ['reference', 'title', 'description',
'categories_list', 'is_selected', 'state_permission_roles']
for sdef in state_list:
state_reference_list.append(sdef.getReference())
states = SubElement(workflow, 'states', attrib=dict(state_list=str(state_reference_list),
number_of_element=str(len(state_reference_list))))
for sdef in state_list:
state = SubElement(states, 'state', attrib=dict(reference=sdef.getReference()))
for
property_id
in
sorted
(
s
def
.
propertyIds
()
):
for property_id in sorted(s
tate_prop_id_to_show
):
property_value = sdef.getProperty(property_id)
if property_value is None:
# do not register if not defined.
...
...
@@ -894,7 +915,9 @@ class Workflow(IdAsReferenceMixin("workflow_", "prefix"), XMLObject):
number_of_element=str(len(script_reference_list))))
for sdef in script_list:
script = SubElement(scripts, 'script', attrib=dict(reference=sdef.getReference()))
"""
# return xml object
if
return_as_object
:
return
root
return
etree
.
tostring
(
root
,
encoding
=
'utf-8'
,
...
...
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