Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_workflow
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenjie.zheng
erp5_workflow
Commits
3c9a222c
Commit
3c9a222c
authored
Jul 20, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow: cleanup files.
parent
a3ec2f6a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
4 additions
and
203 deletions
+4
-203
product/ERP5Workflow/Document/State.py
product/ERP5Workflow/Document/State.py
+4
-41
product/ERP5Workflow/Document/Transition.py
product/ERP5Workflow/Document/Transition.py
+0
-14
product/ERP5Workflow/Document/Variable.py
product/ERP5Workflow/Document/Variable.py
+0
-24
product/ERP5Workflow/Document/Workflow.py
product/ERP5Workflow/Document/Workflow.py
+0
-55
product/ERP5Workflow/Document/Worklist.py
product/ERP5Workflow/Document/Worklist.py
+0
-69
No files found.
product/ERP5Workflow/Document/State.py
View file @
3c9a222c
...
@@ -65,57 +65,20 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, XMLMatrix):
...
@@ -65,57 +65,20 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, XMLMatrix):
PropertySheet
.
Reference
,
PropertySheet
.
Reference
,
PropertySheet
.
State
,)
PropertySheet
.
State
,)
def
getAvailableTransitionList
(
self
,
document
):
transition_list
=
self
.
getDestinationValueList
(
portal_type
=
'Transition'
)
result_list
=
[]
for
transition
in
transition_list
:
value
=
transition
.
_checkPermission
(
document
)
if
value
:
result_list
.
append
(
transition
)
return
result_list
def
getWorkflowHistory
(
self
,
document
,
remove_undo
=
0
,
remove_not_displayed
=
0
):
"""
Return history tuple
"""
wh
=
document
.
workflow_history
[
self
.
getParentValue
().
_generateHistoryKey
()]
result
=
[]
# Remove undo
if
not
remove_undo
:
result
=
[
x
.
copy
()
for
x
in
wh
]
else
:
result
=
[]
for
x
in
wh
:
if
x
.
has_key
(
'undo'
)
and
x
[
'undo'
]
==
1
:
result
.
pop
()
else
:
result
.
append
(
x
.
copy
())
return
result
def
getVariableValue
(
self
,
document
,
variable_name
):
"""
Get current value of the variable from the object
"""
status_dict
=
self
.
getParentValue
().
getCurrentStatusDict
(
document
)
return
status_dict
[
variable_name
]
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."""
p
r
=
self
.
erp5_permission_roles
p
ermission_role
=
self
.
erp5_permission_roles
if
p
r
is
None
:
if
p
ermission_role
is
None
:
self
.
erp5_permission_roles
=
p
r
=
PersistentMapping
()
self
.
erp5_permission_roles
=
p
ermission_role
=
PersistentMapping
()
if
acquired
:
if
acquired
:
roles
=
list
(
roles
)
roles
=
list
(
roles
)
else
:
else
:
roles
=
tuple
(
roles
)
roles
=
tuple
(
roles
)
p
r
[
permission
]
=
roles
p
ermission_role
[
permission
]
=
roles
def
getPermissionRoleList
(
self
):
def
getPermissionRoleList
(
self
):
return
self
.
erp5_permission_roles
return
self
.
erp5_permission_roles
def
getWorkflow
(
self
):
return
aq_parent
(
aq_inner
(
aq_parent
(
aq_inner
(
self
))))
def
getDestinationReferenceList
(
self
):
def
getDestinationReferenceList
(
self
):
ref_list
=
[]
ref_list
=
[]
for
tr
in
self
.
getDestinationValueList
():
for
tr
in
self
.
getDestinationValueList
():
...
...
product/ERP5Workflow/Document/Transition.py
View file @
3c9a222c
...
@@ -108,17 +108,3 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject):
...
@@ -108,17 +108,3 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject):
self
.
guard
.
groups
=
self
.
getGroupList
()
self
.
guard
.
groups
=
self
.
getGroupList
()
if
self
.
guard
.
expr
!=
self
.
getExpression
():
if
self
.
guard
.
expr
!=
self
.
getExpression
():
self
.
guard
.
expr
=
self
.
getExpression
()
self
.
guard
.
expr
=
self
.
getExpression
()
def
_checkPermission
(
self
,
document
):
"""
Check if transition is allowed.
"""
expr_value
=
self
.
getGuardExpression
(
evaluate
=
0
)
if
expr_value
is
not
None
:
# do not use 'getGuardExpression' to calculate tales because
# it caches value which is bad. Instead do it manually
value
=
_evaluateTales
(
document
,
expr_value
)
else
:
value
=
True
#print "CALC", expr_value, '-->', value
return
value
product/ERP5Workflow/Document/Variable.py
View file @
3c9a222c
...
@@ -99,27 +99,3 @@ class Variable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
...
@@ -99,27 +99,3 @@ class Variable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
if
self
.
info_guard
is
not
None
:
if
self
.
info_guard
is
not
None
:
res
=
self
.
info_guard
.
getSummary
()
res
=
self
.
info_guard
.
getSummary
()
return
res
return
res
# zwj: originated from DC workflow; seems useless here?
def
setProperties
(
self
,
description
,
default_value
=
''
,
default_expr
=
''
,
for_catalog
=
0
,
for_status
=
0
,
update_always
=
0
,
props
=
None
,
REQUEST
=
None
):
self
.
description
=
str
(
description
)
self
.
default_value
=
str
(
default_value
)
if
default_expr
:
self
.
default_expr
=
Expression
(
default_expr
)
else
:
self
.
default_expr
=
None
g
=
Guard
()
if
g
.
changeFromProperties
(
props
or
REQUEST
):
self
.
info_guard
=
g
else
:
self
.
info_guard
=
None
self
.
for_catalog
=
bool
(
for_catalog
)
self
.
for_status
=
bool
(
for_status
)
self
.
update_always
=
bool
(
update_always
)
if
REQUEST
is
not
None
:
return
self
.
manage_properties
(
REQUEST
,
'Properties changed.'
)
\ No newline at end of file
product/ERP5Workflow/Document/Workflow.py
View file @
3c9a222c
...
@@ -977,61 +977,6 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...
@@ -977,61 +977,6 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return
etree
.
tostring
(
root
,
encoding
=
'utf-8'
,
return
etree
.
tostring
(
root
,
encoding
=
'utf-8'
,
xml_declaration
=
True
,
pretty_print
=
True
)
xml_declaration
=
True
,
pretty_print
=
True
)
###########
## Graph ##
###########
getGraph
=
getGraph
def
getPOT
(
self
,
*
args
,
**
kwargs
):
"""
get the pot, copy from:
"dcworkfow2dot.py":http://awkly.org/Members/sidnei/weblog_storage/blog_27014
and Sidnei da Silva owns the copyright of the this function
"""
out
=
[]
transition_dict
=
{}
out
.
append
(
'digraph "%s" {'
%
self
.
getTitle
())
transition_with_init_state_list
=
[]
for
state
in
self
.
objectValues
(
portal_type
=
'State'
):
out
.
append
(
'%s [shape=box,label="%s",'
\
'style="filled",fillcolor="#ffcc99"];'
%
\
(
state
.
getId
(),
state
.
getTitle
()))
# XXX Use API instead of getDestinationValueList
for
available_transition
in
state
.
getDestinationValueList
():
transition_with_init_state_list
.
append
(
available_transition
.
getId
())
destination_state
=
available_transition
.
getDestinationValue
()
if
destination_state
is
None
:
# take care of 'remain in state' transitions
destination_state
=
state
#
key
=
(
state
.
getId
(),
destination_state
.
getId
())
value
=
transition_dict
.
get
(
key
,
[])
value
.
append
(
available_transition
.
getTitle
())
transition_dict
[
key
]
=
value
# iterate also on transitions, and add transitions with no initial state
for
transition
in
self
.
objectValues
(
portal_type
=
'Transition'
):
trans_id
=
transition
.
getId
()
if
trans_id
not
in
transition_with_init_state_list
:
destination_state
=
transition
.
getDestinationValue
()
if
destination_state
is
None
:
dest_state_id
=
None
else
:
dest_state_id
=
destination_state
.
getId
()
key
=
(
None
,
dest_state_id
)
value
=
transition_dict
.
get
(
key
,
[])
value
.
append
(
transition
.
getTitle
())
transition_dict
[
key
]
=
value
for
k
,
v
in
transition_dict
.
items
():
out
.
append
(
'%s -> %s [label="%s"];'
%
(
k
[
0
],
k
[
1
],
',
\
\
n'
.
join
(
v
)))
out
.
append
(
'}'
)
return
'
\
n
'
.
join
(
out
)
def
Guard_checkWithoutRoles
(
self
,
sm
,
wf_def
,
ob
,
**
kw
):
def
Guard_checkWithoutRoles
(
self
,
sm
,
wf_def
,
ob
,
**
kw
):
"""Checks conditions in this guard.
"""Checks conditions in this guard.
This function is the same as Guard.check, but roles are not taken
This function is the same as Guard.check, but roles are not taken
...
...
product/ERP5Workflow/Document/Worklist.py
View file @
3c9a222c
...
@@ -170,72 +170,3 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
...
@@ -170,72 +170,3 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
if isinstance(values, Expression):
if isinstance(values, Expression):
return values.text
return values.text
return '
;
'.join(values)
return '
;
'.join(values)
def setProperties(self, description,
actbox_name='', actbox_url='', actbox_category='
global
',
actbox_icon='', props=None, REQUEST=None):
'''
'''
if props is None:
props = REQUEST
self.description = str(description)
for key in self.getAvailableCatalogVars():
# Populate var_matches.
# add field in real time
fieldname = '
var_match_
%
s
' % key
v = props.get(fieldname, '')
if v:
if not self.var_matches:
self.var_matches = PersistentMapping()
if tales_re.match(v).group(1):
# Found a TALES prefix
self.var_matches[key] = Expression(v)
else:
# Falling back to formatted string
v = [ var.strip() for var in v.split('
;
') ]
self.var_matches[key] = tuple(v)
else:
if self.var_matches and self.var_matches.has_key(key):
del self.var_matches[key]
self.actbox_name = str(actbox_name)
self.actbox_url = str(actbox_url)
self.actbox_category = str(actbox_category)
self.actbox_icon = str(actbox_icon)
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.guard = g
else:
self.guard = None
if REQUEST is not None:
return self.manage_properties(REQUEST, '
Properties
changed
.
')
def search(self, info=None, **kw):
""" Perform the search corresponding to this worklist
Returns sequence of ZCatalog brains
- info is a mapping for resolving formatted string variable references
- additional keyword/value pairs may be used to restrict the query
"""
if not self.var_matches:
return
if info is None:
info = {}
catalog = getToolByName(self, '
portal_catalog
')
criteria = {}
for key, values in self.var_matches.items():
if isinstance(values, Expression):
wf = self.getParent()
portal = wf._getPortalRoot()
context = createExprContext(StateChangeInfo(portal, wf))
criteria[key] = values(context)
else:
criteria[key] = [x % info for x in values]
criteria.update(kw)
return catalog.searchResults(**criteria)
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