diff --git a/tests/workflow/test_email.py b/tests/workflow/test_email.py index 6c591d5ba..6e0768589 100644 --- a/tests/workflow/test_email.py +++ b/tests/workflow/test_email.py @@ -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'] diff --git a/wcs/variables.py b/wcs/variables.py index 6b9c1a479..75360857c 100644 --- a/wcs/variables.py +++ b/wcs/variables.py @@ -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