From b6a5e9070824c5afc0ef92be56752601e1bca109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 11 Oct 2021 19:46:18 +0200 Subject: [PATCH] workflows: play actions if jumping to current status from global action (#57750) --- tests/form_pages/test_all.py | 4 ++-- wcs/formdata.py | 2 +- wcs/workflows.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/form_pages/test_all.py b/tests/form_pages/test_all.py index 225fa6010..2941ccc9c 100644 --- a/tests/form_pages/test_all.py +++ b/tests/form_pages/test_all.py @@ -6026,10 +6026,10 @@ def test_user_global_action_same_status_store(pub): assert 'button-action-1' in resp.form.fields resp = resp.form.submit('button-action-1') # click global action - # check status actions are not rerun + # check status actions are rerun resp = app.get(formdata.get_url()) assert formdef.data_class().get(formdata.id).status == 'wf-new' - assert formdef.data_class().get(formdata.id).data['bo1'] == '123' + assert formdef.data_class().get(formdata.id).data['bo1'] == '321' def test_anonymous_user_global_action(pub): diff --git a/wcs/formdata.py b/wcs/formdata.py index 617350693..2431a4c16 100644 --- a/wcs/formdata.py +++ b/wcs/formdata.py @@ -591,7 +591,7 @@ class FormData(StorableObject): for action in self.formdef.workflow.get_global_actions_for_user(formdata=self, user=user): if action.id != action_id: continue - return perform_items(action.items, self, event=(event_name, action.id)) + return perform_items(action.items, self, event=(event_name, action.id), global_action=True) def get_workflow_messages(self, position='top', user=None): wf_status = self.get_visible_status(user=user) diff --git a/wcs/workflows.py b/wcs/workflows.py index 40d747408..9e1cf2664 100644 --- a/wcs/workflows.py +++ b/wcs/workflows.py @@ -70,7 +70,7 @@ def lax_int(s): return -1 -def perform_items(items, formdata, depth=20, event=None): +def perform_items(items, formdata, depth=20, event=None, global_action=False): if depth == 0: # prevents infinite loops return url = None @@ -96,7 +96,7 @@ def perform_items(items, formdata, depth=20, event=None): if formdata.id: # don't save formdata it has been removed formdata.store() - if formdata.status != old_status: + if formdata.status != old_status or (global_action and 'jump' in [x[1] for x in performed_actions]): if not formdata.evolution: formdata.evolution = [] evo = Evolution()