From ce9f96c9863e4df744eda9635bf891e02cac7b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 5 Jul 2018 17:36:28 +0200 Subject: [PATCH] backoffice: display timeout as is when it's not a straight number (#25090) --- tests/test_backoffice_pages.py | 25 +++++++++++++++++++++++++ wcs/workflows.py | 5 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py index ecac0ede..e70fc910 100644 --- a/tests/test_backoffice_pages.py +++ b/tests/test_backoffice_pages.py @@ -4234,3 +4234,28 @@ def test_backoffice_forms_condition_on_button(pub): resp = resp.click('Management', index=0) resp = resp.follow() assert '8 open on 50' in resp.body # only the accepted ones + +def test_workflow_inspect_page(pub): + create_superuser(pub) + create_environment(pub, set_receiver=True) + + workflow = Workflow.get_default_workflow() + workflow.id = '2' + + st1 = workflow.add_status('Status1') + jump = JumpWorkflowStatusItem() + jump.id = '_jump' + jump.timeout = '=86400' + jump.status = 'finished' + st1.items.append(jump) + jump.parent = st1 + workflow.store() + + app = login(get_app(pub)) + resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id) + assert '=86400'in resp.body + + jump.timeout = '82800' + workflow.store() + resp = app.get('/backoffice/workflows/%s/inspect' % workflow.id) + assert '23 hours' in resp.body diff --git a/wcs/workflows.py b/wcs/workflows.py index 9f6e6677..17242fd3 100644 --- a/wcs/workflows.py +++ b/wcs/workflows.py @@ -1620,7 +1620,10 @@ class WorkflowStatusItem(XmlSerialisable): return self.render_list_of_roles(self.by) def get_timeout_parameter_view_value(self): - return seconds2humanduration(int(self.timeout or 0)) + try: + return seconds2humanduration(int(self.timeout or 0)) + except ValueError: + return self.timeout # probably an expression def get_status_parameter_view_value(self): for status in self.parent.parent.possible_status: -- 2.18.0