From 8e5b0082823e529cfabdc4d937d0c154927bec4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 17 May 2021 16:04:01 +0200 Subject: [PATCH] workflows: fix display of email action recipients with computed value (#54032) --- tests/test_workflows.py | 20 ++++++++++++++++++++ wcs/workflows.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 400b2366f..ecc3401c5 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -3103,6 +3103,26 @@ def test_workflow_display_message_line_details(pub): assert display_message.get_line_details() == 'with actions, for foorole' +def test_workflow_email_line_details(pub): + workflow = Workflow(name='email') + st1 = workflow.add_status('Status1', 'st1') + sendmail = SendmailWorkflowStatusItem() + sendmail.parent = st1 + + assert sendmail.get_line_details() == 'not completed' + + role = pub.role_class(name='foorole') + role.store() + sendmail.to = [role.id] + assert sendmail.get_line_details() == 'to foorole' + + sendmail.to = ['test@example.net'] + assert sendmail.get_line_details() == 'to test@example.net' + + sendmail.to = ['{{ foobar }}'] + assert sendmail.get_line_details() == 'to computed value' + + def test_workflow_roles(pub, emails): pub.substitutions.feed(MockSubstitutionVariables()) diff --git a/wcs/workflows.py b/wcs/workflows.py index 33c4cb34d..b89a0e73f 100644 --- a/wcs/workflows.py +++ b/wcs/workflows.py @@ -2816,7 +2816,7 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem): role_label = get_role_translation_label(self.parent.parent, r) if role_label: t.append(role_label) - return ', '.join(t) + return ', '.join([str(x) for x in t]) def get_to_parameter_view_value(self): return self.render_list_of_roles_or_emails(self.to)