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

Happens the extension in the filename in original format as well


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30100 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 18404aff
......@@ -522,8 +522,11 @@ class OOoTemplate(ZopePageTemplate):
return self._asFormat(ooo, format, request, batch_mode)
if not format and not batch_mode:
request.RESPONSE.setHeader('Content-Type','%s; charset=utf-8' % self.content_type)
request.RESPONSE.setHeader('Content-disposition', 'inline;filename="%s"' % self.title_or_id())
request.RESPONSE.setHeader('Content-Type',
'%s; charset=utf-8' % self.content_type)
request.RESPONSE.setHeader('Content-disposition',
'inline;filename="%s%s"' % (self.title_or_id(),
guess_extension(self.content_type)))
if DevelopmentMode:
# Validate XML in development mode
......
......@@ -42,6 +42,7 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
"""Tests deferred styles for ERP5."""
skin = content_type = None
recipient_email_address = 'invalid@example.com'
attachment_file_extension = ''
username = 'bob'
password = 'bobpwd'
first_name = 'Bob'
......@@ -100,10 +101,10 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
for part in mail_message.walk():
content_type = part.get_content_type()
file_name = part.get_filename()
# XXX the attachment name might change some day
if file_name == 'report_view':
if file_name == 'report_view%s' % self.attachment_file_extension:
self.assertEquals(content_type, self.content_type)
self.assertEquals('attachment; filename="report_view"',
self.assertEquals('attachment; filename="report_view%s"' %
self.attachment_file_extension,
part.get('Content-Disposition'))
data = part.get_payload(decode=True)
error_list = Validator().validate(data)
......@@ -117,11 +118,13 @@ class TestDeferredStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
class TestODSDeferredStyle(TestDeferredStyle):
skin = 'ODS'
content_type = 'application/vnd.oasis.opendocument.spreadsheet'
attachment_file_extension = '.ods'
class TestODTDeferredStyle(TestDeferredStyle):
skin = 'ODT'
content_type = 'application/vnd.oasis.opendocument.text'
attachment_file_extension = '.odt'
def test_suite():
......
......@@ -77,7 +77,7 @@ class TestOoodResponse(ERP5TypeTestCase):
ERP5Site_viewNothingAsOdt(batch_mode=0)
self.assertEqual('application/vnd.oasis.opendocument.text',
request.RESPONSE.getHeader('content-type').split(';')[0])
self.assertEqual('inline;filename="ERP5Site_viewNothingAsOdt"',
self.assertEqual('inline;filename="ERP5Site_viewNothingAsOdt.odt"',
request.RESPONSE.getHeader('content-disposition'))
def test_01b_noExcEmptyFormatNoBatchMode(self):
......@@ -87,7 +87,7 @@ class TestOoodResponse(ERP5TypeTestCase):
ERP5Site_viewNothingAsOdt(format='', batch_mode=0)
self.assertEqual('application/vnd.oasis.opendocument.text',
request.RESPONSE.getHeader('content-type').split(';')[0])
self.assertEqual('inline;filename="ERP5Site_viewNothingAsOdt"',
self.assertEqual('inline;filename="ERP5Site_viewNothingAsOdt.odt"',
request.RESPONSE.getHeader('content-disposition'))
def test_02_noExcNoFormatBatchMode(self):
......
......@@ -123,7 +123,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
response = self.publish('/' + self.folder.Dynamic_viewAsOdt.absolute_url(1))
self.assertEqual('application/vnd.oasis.opendocument.text',
response.getHeader('content-type').split(';')[0])
self.assertEqual('inline;filename="Dynamic_viewAsOdt"',
self.assertEqual('inline;filename="Dynamic_viewAsOdt.odt"',
response.getHeader('content-disposition'))
self._validate(response.getBody())
self.assertTrue(200, response.getStatus())
......@@ -177,7 +177,7 @@ return getattr(context, "%s_%s" % (parameter, current_language))
self.assertTrue(200, response.getStatus())
self.assertEqual('application/vnd.oasis.opendocument.text',
response.getHeader('content-type').split(';')[0])
self.assertEqual('inline;filename="Static_viewAsOdt"',
self.assertEqual('inline;filename="Static_viewAsOdt.odt"',
response.getHeader('content-disposition'))
self._validate(response.getBody())
odt_zip_file = self._create_odt_zip_file(response.getBody())
......
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