Commit b74b7b37 authored by Jérome Perrin's avatar Jérome Perrin

ods_style: make `sheet_per_report_section` compatible with deferred style

parent c1541a14
Pipeline #2528 skipped
......@@ -136,14 +136,26 @@
</table:table>\n
</tal:block>\n
<tal:block tal:condition="sheet_per_report_section">\n
<tal:block tal:repeat="report_item python: report_item_list">\n
<tal:block tal:condition="python: report_item.getFormId()">\n
<table:table tal:attributes="table:name python: unicode(report_item.getTitle() or \'Sheet%s\' % repeat[\'report_item\'].index, \'utf-8\')">\n
<tal:block tal:condition="rendered_report_item_list">\n
<tal:block tal:repeat="report_item report_item_list">\n
<!-- FIXME: in deferred mode + sheet_per_report_section we do not have title -->\n
<table:table tal:attributes="table:name python: unicode(\'Sheet%s\' % repeat[\'report_item\'].index, \'utf-8\')">\n
<table:table-column table:style-name="co4" table:default-cell-style-name="text"/>\n
<tal:block metal:use-macro="here/report_view/macros/make_report_item_table"/>\n
<tal:block tal:replace="structure report_item"/>\n
</table:table>\n
</tal:block>\n
</tal:block>\n
\n
<tal:block tal:condition="not: rendered_report_item_list">\n
<tal:block tal:repeat="report_item python: report_item_list">\n
<tal:block tal:condition="python: report_item.getFormId()">\n
<table:table tal:attributes="table:name python: unicode(report_item.getTitle() or \'Sheet%s\' % repeat[\'report_item\'].index, \'utf-8\')">\n
<table:table-column table:style-name="co4" table:default-cell-style-name="text"/>\n
<tal:block metal:use-macro="here/report_view/macros/make_report_item_table"/>\n
</table:table>\n
</tal:block>\n
</tal:block>\n
</tal:block>\n
\n
<!-- include the report header as last page -->\n
<table:table tal:attributes="table:name python:unicode(form.getProperty(\'title\'), \'utf8\')" i18n:attributes="table:name">\n
......
......@@ -149,6 +149,38 @@ class TestODSDeferredStyle(TestDeferredStyle):
content_type = 'application/vnd.oasis.opendocument.spreadsheet'
attachment_file_extension = '.ods'
def test_report_view_sheet_per_report_section(self):
"""Test the sheet_per_report_section feature of erp5_ods_style.
"""
self.loginAsUser('bob')
self.portal.changeSkin('Deferred')
response = self.publish(
'/%s/person_module/pers/Base_viewHistory?deferred_portal_skin=%s&sheet_per_report_section:int=1'
% (self.portal.getId(), self.skin), '%s:%s' % (self.username, self.password))
self.tic()
last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text)
for part in mail_message.walk():
content_type = part.get_content_type()
file_name = part.get_filename()
if content_type == self.content_type:
# "History" is the title of Base_viewHistory form
file_name = part.get_filename()
expected_file_name = 'History%s' % self.attachment_file_extension
self.assertEqual(expected_file_name, file_name)
self.assertEqual('attachment; filename="%s"' % expected_file_name,
part.get('Content-Disposition'))
data = part.get_payload(decode=True)
error_list = Validator().validate(data)
if error_list:
self.fail(''.join(error_list))
break
else:
self.fail('Attachment not found in email\n%s' % message_text)
class TestODTDeferredStyle(TestDeferredStyle):
skin = 'ODT'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment