workflows: fix attachements xml import on sendmail action (#20319)

This commit is contained in:
Thomas NOËL 2017-11-28 11:39:18 +01:00
parent c4fc21a21a
commit 69c9fd57d1
2 changed files with 22 additions and 0 deletions

View File

@ -477,6 +477,22 @@ def test_sendmail_other_destination(pub):
assert Role.count() == 0
assert wf2.possible_status[0].items[0].to == sendmail.to
def test_sendmail_attachments(pub):
wf = Workflow(name='status')
st1 = wf.add_status('Status1', 'st1')
sendmail = SendmailWorkflowStatusItem()
st1.items.append(sendmail)
sendmail.parent = st1
sendmail.attachments = ['form_var_file_raw', 'form_fbo1']
wf2 = assert_import_export_works(wf)
assert wf2.possible_status[0].items[0].attachments == sendmail.attachments
sendmail.attachments = []
wf2 = assert_import_export_works(wf)
assert wf2.possible_status[0].items[0].attachments == []
def test_sms(pub):
wf = Workflow(name='status')
st1 = wf.add_status('Status1', 'st1')

View File

@ -2054,6 +2054,12 @@ class SendmailWorkflowStatusItem(WorkflowStatusItem):
return super(SendmailWorkflowStatusItem, self)._get_role_id_from_xml(
elem, charset, include_id=include_id)
def attachments_init_with_xml(self, elem, charset, include_id=False):
if elem is None:
self.attachments = None
else:
self.attachments = [item.text.encode(charset) for item in elem.findall('attachment')]
def render_list_of_roles_or_emails(self, roles):
t = []
for r in roles: