0001-workflows-remove-skipped-conditional-jumps-from-acti.patch
tests/workflow/test_all.py | ||
---|---|---|
6506 | 6506 |
assert two_pubs.loggederror_class.count() == 1 |
6507 | 6507 |
logged_error = two_pubs.loggederror_class.select()[0] |
6508 | 6508 |
assert logged_error.summary == 'Mismatch in target object: expected "Other data", got "Data"' |
6509 | ||
6510 | ||
6511 |
def test_conditional_jump_vs_tracing(pub): |
|
6512 |
workflow = Workflow(name='wf') |
|
6513 |
st1 = workflow.add_status('Status1', 'st1') |
|
6514 |
workflow.add_status('Status2', 'st2') |
|
6515 |
comment = st1.append_item('register-comment') |
|
6516 |
comment.comment = 'hello world' |
|
6517 |
jump1 = st1.append_item('jump') |
|
6518 |
jump1.parent = st1 |
|
6519 |
jump1.condition = {'type': 'django', 'value': 'False'} |
|
6520 |
jump1.status = 'wf-st2' |
|
6521 |
jump2 = st1.append_item('jump') |
|
6522 |
jump2.parent = st1 |
|
6523 |
jump2.status = 'wf-st2' |
|
6524 |
workflow.store() |
|
6525 | ||
6526 |
formdef = FormDef() |
|
6527 |
formdef.name = 'baz' |
|
6528 |
formdef.workflow = workflow |
|
6529 |
formdef.store() |
|
6530 | ||
6531 |
formdata = formdef.data_class()() |
|
6532 |
formdata.just_created() |
|
6533 |
formdata.store() |
|
6534 |
perform_items(st1.items, formdata) |
|
6535 |
formdata.refresh_from_storage() |
|
6536 |
assert formdata.evolution[0].parts[-1].actions[0][1:] == ('register-comment', str(comment.id)) |
|
6537 |
assert formdata.evolution[0].parts[-1].actions[1][1:] == ('jump', str(jump2.id)) |
wcs/wf/jump.py | ||
---|---|---|
28 | 28 | |
29 | 29 |
from wcs.api import get_user_from_api_query_string, is_url_signed |
30 | 30 |
from wcs.conditions import Condition |
31 |
from wcs.workflows import Workflow, WorkflowGlobalAction, WorkflowStatusJumpItem, register_item_class |
|
31 |
from wcs.workflows import ( |
|
32 |
SkipActionException, |
|
33 |
Workflow, |
|
34 |
WorkflowGlobalAction, |
|
35 |
WorkflowStatusJumpItem, |
|
36 |
register_item_class, |
|
37 |
) |
|
32 | 38 | |
33 | 39 |
from ..qommon import _, errors, force_str |
34 | 40 |
from ..qommon.cron import CronJob |
... | ... | |
257 | 263 |
if wf_status: |
258 | 264 |
self.handle_markers_stack(formdata) |
259 | 265 |
formdata.status = 'wf-%s' % wf_status[0].id |
266 |
else: |
|
267 |
raise SkipActionException() |
|
260 | 268 | |
261 | 269 |
def check_condition(self, formdata, *args, **kwargs): |
262 | 270 |
# ship condition check here so it is not evaluated twice. |
wcs/workflows.py | ||
---|---|---|
92 | 92 |
except AbortActionException as e: |
93 | 93 |
url = url or e.url |
94 | 94 |
break |
95 |
except SkipActionException: |
|
96 |
# it was actually skipped, remove it from performed actions |
|
97 |
performed_actions.pop() |
|
98 |
continue |
|
95 | 99 |
if formdata.status != old_status: |
96 | 100 |
break |
97 | 101 |
if performed_actions: |
... | ... | |
135 | 139 |
self.url = url |
136 | 140 | |
137 | 141 | |
142 |
class SkipActionException(Exception): |
|
143 |
pass |
|
144 | ||
145 | ||
138 | 146 |
class RedisplayFormException(Exception): |
139 | 147 |
pass |
140 | 148 | |
141 |
- |