workflows: don't crash on missing/previous destination status (#48992)

This commit is contained in:
Frédéric Péters 2020-11-30 19:39:23 +01:00
parent 8960b8d075
commit 7b7c4a54ea
2 changed files with 22 additions and 2 deletions

View File

@ -1008,6 +1008,18 @@ def test_workflows_edit_choice_action_line_details(pub):
assert resp.html.find('a', {'href': 'items/1/'}).text == \
'Manual Jump ("Resubmit", to Resubmit, by User (and set marker))'
jump.status = 'error'
wf.store()
resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
assert resp.html.find('a', {'href': 'items/1/'}).text == \
'Manual Jump (broken, missing destination status)'
jump.status = '_previous'
wf.store()
resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
assert resp.html.find('a', {'href': 'items/1/'}).text == \
'Manual Jump ("Resubmit", to previously marked status, by User (and set marker))'
def test_workflows_action_subpath(pub):
create_superuser(pub)

View File

@ -2441,8 +2441,16 @@ class ChoiceWorkflowStatusItem(WorkflowStatusJumpItem):
return _('computed label')
def get_line_details(self):
if self.label and self.status:
to_status = self.parent.parent.get_status(self.status)
to_status = None
if self.status == '_previous':
to_status = WorkflowStatus(_('previously marked status'))
elif self.status:
try:
to_status = self.parent.parent.get_status(self.status)
except KeyError:
return _('broken, missing destination status')
if self.label and to_status:
more = ''
if self.set_marker_on_status:
more += ' ' + _('(and set marker)')