Commit c7bff10f authored by Ivan Tyagov's avatar Ivan Tyagov

Make sure that default view of any OOodocument will return the original filename rather than ID.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22213 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e39dd0c2
......@@ -181,18 +181,25 @@ class OOoDocument(PermanentURLMixIn, File, ConversionCacheMixin):
" in %s format" % (format or 'original'))
# Return the original file by default
if self.getSourceReference() is not None:
filename = self.getSourceReference()
else:
filename = self.getId()
if format is None:
RESPONSE.setHeader('Content-Disposition','Attachment;Filename=%s' %filename)
return File.index_html(self, REQUEST, RESPONSE)
# Make sure file is converted to base format
if not self.hasBaseData():
raise NotConvertedError
# Else try to convert the document and return it
mime, result = self.convert(format=format, display=display, **kw)
converted_filename = '%s.%s'%(filename.split('.')[0], format)
if not mime:
mime = getToolByName(self, 'mimetypes_registry').lookupExtension('name.%s' % format)
RESPONSE.setHeader('Content-Length', len(result))
RESPONSE.setHeader('Content-Type', mime)
RESPONSE.setHeader('Accept-Ranges', 'bytes')
RESPONSE.setHeader('Content-Disposition','Attachment;Filename=%s' %converted_filename)
return result
# Format conversion implementation
......
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