workflows: fix attachment of files with no varnames (#67463)
This commit is contained in:
parent
a189231a7a
commit
76a774d38e
|
@ -368,6 +368,17 @@ def test_email_attachments(pub, emails):
|
|||
assert emails.emails['foobar']['msg'].get_payload()[0].get_content_type() == 'text/html'
|
||||
assert emails.emails['foobar']['msg'].get_payload()[1].get_content_type() == 'image/jpeg'
|
||||
|
||||
# check with template with varname-less field
|
||||
emails.empty()
|
||||
sendmail.attachments = ['{{form_fbo1_1x}}']
|
||||
sendmail.perform(formdata)
|
||||
get_response().process_after_jobs()
|
||||
assert emails.count() == 1
|
||||
assert emails.emails['foobar']['msg'].is_multipart()
|
||||
assert emails.emails['foobar']['msg'].get_content_subtype() == 'mixed'
|
||||
assert emails.emails['foobar']['msg'].get_payload()[0].get_content_type() == 'text/html'
|
||||
assert emails.emails['foobar']['msg'].get_payload()[1].get_content_type() == 'image/jpeg'
|
||||
|
||||
# check with variable
|
||||
emails.empty()
|
||||
sendmail.attachments = ['form_var_backoffice_file1_raw']
|
||||
|
|
|
@ -704,7 +704,7 @@ class LazyFormData(LazyFormDef):
|
|||
except AttributeError:
|
||||
if key.startswith('f'):
|
||||
for field in self._formdef.get_all_fields():
|
||||
if str(field.id) == str(key[1:]):
|
||||
if str(field.id).replace('-', '_') == str(key[1:]):
|
||||
return self._formdata.data.get(field.id)
|
||||
raise
|
||||
|
||||
|
|
Loading…
Reference in New Issue