do not jump after edit if target status is unknown (#23882)
This commit is contained in:
parent
64bad2d27e
commit
52ba7c30ac
|
@ -1611,6 +1611,23 @@ def test_form_multi_page_post_edit(pub):
|
|||
assert 'barXYZ' in resp.body # unchanged value is still there
|
||||
assert formdef.data_class().get(data_id).status == 'wf-%s' % st2.id
|
||||
|
||||
# jump to a nonexistent status == do not jump
|
||||
editable.status = 'deleted_status_id'
|
||||
workflow.store()
|
||||
# go back to st1
|
||||
formdata = formdef.data_class().get(data_id)
|
||||
formdata.status = 'wf-%s' % st1.id
|
||||
formdata.store()
|
||||
assert formdef.data_class().get(data_id).status == 'wf-%s' % st1.id
|
||||
page = login(get_app(pub), username='foo', password='foo').get('/test/%s/' % data_id)
|
||||
resp = page.forms[0].submit('button_editable')
|
||||
resp = resp.follow()
|
||||
resp.forms[0]['f1'] = 'foo3'
|
||||
resp = resp.forms[0].submit('submit')
|
||||
resp = resp.forms[0].submit('submit')
|
||||
resp = resp.follow()
|
||||
assert formdef.data_class().get(data_id).status == 'wf-%s' % st1.id # stay on st1
|
||||
|
||||
def test_form_count_dispatching(pub):
|
||||
user = create_user(pub)
|
||||
|
||||
|
|
|
@ -1066,9 +1066,11 @@ class FormPage(Directory):
|
|||
wf_status = self.edited_data.get_status()
|
||||
url = None
|
||||
for item in wf_status.items:
|
||||
if item.id == self.edit_action_id and item.status:
|
||||
self.edited_data.jump_status(item.status)
|
||||
url = self.edited_data.perform_workflow()
|
||||
if item.id == self.edit_action_id:
|
||||
wf_status = item.get_target_status(self.edited_data)
|
||||
if wf_status:
|
||||
self.edited_data.jump_status(wf_status[0].id)
|
||||
url = self.edited_data.perform_workflow()
|
||||
break
|
||||
return redirect(url or '.')
|
||||
|
||||
|
|
Loading…
Reference in New Issue