workflows: fix redirection from global actions (#16722)

This commit is contained in:
Frédéric Péters 2017-06-07 09:37:02 +02:00
parent fd9e7bc128
commit ddaf734dcd
2 changed files with 33 additions and 1 deletions

View File

@ -1023,6 +1023,38 @@ def test_backoffice_handling_global_action(pub):
assert 'HELLO WORLD GLOBAL ACTION' in resp.body
assert formdef.data_class().get(formdata.id).status == 'wf-finished'
def test_backoffice_global_remove_action(pub):
create_user(pub)
create_environment(pub)
formdef = FormDef()
formdef.name = 'test global remove'
formdef.fields = []
workflow = Workflow.get_default_workflow()
workflow.id = '2'
action = workflow.add_global_action('FOOBAR')
remove = action.append_item('remove')
trigger = action.triggers[0]
trigger.roles = [x.id for x in Role.select() if x.name == 'foobar']
workflow.store()
formdef.workflow_id = workflow.id
formdef.workflow_roles = {'_receiver': 1}
formdef.store()
formdata = formdef.data_class()()
formdata.just_created()
formdata.store()
app = login(get_app(pub))
resp = app.get('/backoffice/management/%s/%s/' % (formdef.url_name, formdata.id))
assert 'remove' in resp.body
assert 'button-action-1' in resp.form.fields
resp = resp.form.submit('button-action-1')
resp = resp.follow()
assert resp.request.url == 'http://example.net/backoffice/management/test-global-remove/'
def test_backoffice_submission_context(pub):
user = create_user(pub)
create_environment(pub)

View File

@ -1306,7 +1306,7 @@ class WorkflowStatus(object):
if 'button-action-%s' % action.id in get_request().form:
url = perform_items(action.items, filled)
if url:
return redirect(url)
return url
return
evo = Evolution()