Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
erp5
Commits
befe4a3a
Commit
befe4a3a
authored
Feb 06, 2014
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make a valid extention for a file generated by 'Download Open Document' action.
parent
d5bc2ebd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
product/ERP5/mixin/downloadable.py
product/ERP5/mixin/downloadable.py
+6
-3
product/ERP5OOo/tests/testDms.py
product/ERP5OOo/tests/testDms.py
+14
-7
No files found.
product/ERP5/mixin/downloadable.py
View file @
befe4a3a
...
...
@@ -85,7 +85,7 @@ class DownloadableMixin:
'format'
)
mime
,
data
=
self
.
convert
(
format
,
**
kw
)
output_format
=
None
if
not
format
:
if
not
format
or
format
==
'base-data'
:
# Guess the format from original mimetype
if
mime
:
mimetypes_registry
=
getToolByName
(
self
.
getPortalObject
(),
...
...
@@ -98,7 +98,7 @@ class DownloadableMixin:
elif
mimetype_object
.
globs
:
output_format
=
mimetype_object
.
globs
.
strip
(
'*.'
)
break
els
e
:
if
output_format
is
Non
e
:
output_format
=
format
RESPONSE
.
setHeader
(
'Content-Length'
,
len
(
data
))
...
...
@@ -111,6 +111,9 @@ class DownloadableMixin:
inline
=
output_format
in
(
VALID_TEXT_FORMAT_LIST
+
VALID_IMAGE_FORMAT_LIST
)
if
not
inline
:
# need to return it as attachment
if
format
==
'base-data'
:
filename
=
self
.
getStandardFilename
(
format
=
output_format
)
else
:
filename
=
self
.
getStandardFilename
(
format
=
format
)
RESPONSE
.
setHeader
(
'Cache-Control'
,
'Private'
)
# workaround for Internet Explorer's bug
# workaround for IE's bug to download files over SSL
...
...
product/ERP5OOo/tests/testDms.py
View file @
befe4a3a
...
...
@@ -631,12 +631,14 @@ class TestDocument(TestDocumentMixin):
self
.
assertTrue
(
doc
.
hasData
())
def
test_Owner_Base_download
(
self
):
# tests that owners can download OOo documents, and all headers (including
# filenames) are set correctly
# tests that owners can download original documents and OOo
# documents, and all headers (including filenames) are set
# correctly
doc
=
self
.
portal
.
document_module
.
newContent
(
filename
=
'test.ods'
,
portal_type
=
'Spreadsheet'
)
doc
.
edit
(
file
=
makeFileUpload
(
'import_data_list.ods'
))
doc
.
edit
(
file
=
makeFileUpload
(
'TEST-en-002.doc'
))
self
.
tic
()
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'member_user1'
,
'secret'
,
[
'Member'
,
'Owner'
],
[])
...
...
@@ -645,13 +647,18 @@ class TestDocument(TestDocumentMixin):
response
=
self
.
publish
(
'%s/Base_download'
%
doc
.
getPath
(),
basic
=
'member_user1:secret'
)
self
.
assertEqual
(
makeFileUpload
(
'
import_data_list.ods
'
).
read
(),
self
.
assertEqual
(
makeFileUpload
(
'
TEST-en-002.doc
'
).
read
(),
response
.
getBody
())
self
.
assertEqual
(
'application/
vnd.oasis.opendocument.spreadsheet
'
,
self
.
assertEqual
(
'application/
msword
'
,
response
.
headers
[
'content-type'
])
self
.
assertEqual
(
'attachment; filename="import_data_list.ods"'
,
self
.
assertEqual
(
'attachment; filename="TEST-en-002.doc"'
,
response
.
headers
[
'content-disposition'
])
response
=
self
.
publish
(
'%s/OOoDocument_getOOoFile'
%
doc
.
getPath
(),
basic
=
'member_user1:secret'
)
self
.
assertEqual
(
'application/vnd.oasis.opendocument.text'
,
response
.
headers
[
'content-type'
])
self
.
assertEqual
(
'attachment; filename="TEST-en-002.odt"'
,
response
.
headers
[
'content-disposition'
])
self
.
tic
()
def
test_Member_download_pdf_format
(
self
):
# tests that members can download OOo documents in pdf format (at least in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment