From 1d31c3c2d140812bd9bbe9aeae66450f585d81b3 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 26 Sep 2017 17:13:47 +0200 Subject: [PATCH] mail with attachments, draft #8274 --- wcs/workflows.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wcs/workflows.py b/wcs/workflows.py index 191aada7..3909cb35 100644 --- a/wcs/workflows.py +++ b/wcs/workflows.py @@ -2015,6 +2015,7 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem): subject = None body = None custom_from = None + attachments = None comment = None @@ -2053,7 +2054,7 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem): return _('Send mail (not completed)') def get_parameters(self): - return ('to', 'subject', 'body', 'custom_from') + return ('to', 'subject', 'body', 'attachments', 'custom_from') def fill_admin_form(self, form): self.add_parameters_widgets(form, self.get_parameters()) @@ -2076,6 +2077,24 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem): value=self.body, cols=80, rows=10, validation_function=ComputedExpressionWidget.validate_ezt, hint=_('Available variables: url, url_status, details, name, number, comment, field_NAME')) + attachments_fields = [(None, '---', None)] + for field in self.parent.parent.get_backoffice_fields(): + if field.key != 'file': + continue + if field.varname: + codename = 'form_var_%s' % field.varname + label = htmltext('%s (%s)') % (field.label, codename) + else: + codename = '__f%s' % field.id # __fbo + label = field.label + attachments_fields.append((codename, label, codename)) + if 'attachments' in parameters: + form.add(WidgetList, '%sattachments' % prefix, title=_('Attachments'), + element_type=SingleSelectWidgetWithOther, + value=self.attachments, + add_element_label=_('Add attachment'), + element_kwargs={'render_br': False, 'options': attachments_fields}, + hint=_('"Other" attachement choice should be a Python expression')) if 'custom_from' in parameters: form.add(ComputedExpressionWidget, '%scustom_from' % prefix, title=_('Custom From Address'), value=self.custom_from, -- 2.14.1