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
0
Merge Requests
0
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
Tatuya Kamada
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:
...
@@ -85,7 +85,7 @@ class DownloadableMixin:
'format'
)
'format'
)
mime
,
data
=
self
.
convert
(
format
,
**
kw
)
mime
,
data
=
self
.
convert
(
format
,
**
kw
)
output_format
=
None
output_format
=
None
if
not
format
:
if
not
format
or
format
==
'base-data'
:
# Guess the format from original mimetype
# Guess the format from original mimetype
if
mime
:
if
mime
:
mimetypes_registry
=
getToolByName
(
self
.
getPortalObject
(),
mimetypes_registry
=
getToolByName
(
self
.
getPortalObject
(),
...
@@ -98,7 +98,7 @@ class DownloadableMixin:
...
@@ -98,7 +98,7 @@ class DownloadableMixin:
elif
mimetype_object
.
globs
:
elif
mimetype_object
.
globs
:
output_format
=
mimetype_object
.
globs
.
strip
(
'*.'
)
output_format
=
mimetype_object
.
globs
.
strip
(
'*.'
)
break
break
els
e
:
if
output_format
is
Non
e
:
output_format
=
format
output_format
=
format
RESPONSE
.
setHeader
(
'Content-Length'
,
len
(
data
))
RESPONSE
.
setHeader
(
'Content-Length'
,
len
(
data
))
...
@@ -111,6 +111,9 @@ class DownloadableMixin:
...
@@ -111,6 +111,9 @@ class DownloadableMixin:
inline
=
output_format
in
(
VALID_TEXT_FORMAT_LIST
+
VALID_IMAGE_FORMAT_LIST
)
inline
=
output_format
in
(
VALID_TEXT_FORMAT_LIST
+
VALID_IMAGE_FORMAT_LIST
)
if
not
inline
:
if
not
inline
:
# need to return it as attachment
# need to return it as attachment
if
format
==
'base-data'
:
filename
=
self
.
getStandardFilename
(
format
=
output_format
)
else
:
filename
=
self
.
getStandardFilename
(
format
=
format
)
filename
=
self
.
getStandardFilename
(
format
=
format
)
RESPONSE
.
setHeader
(
'Cache-Control'
,
'Private'
)
# workaround for Internet Explorer's bug
RESPONSE
.
setHeader
(
'Cache-Control'
,
'Private'
)
# workaround for Internet Explorer's bug
# workaround for IE's bug to download files over SSL
# 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):
...
@@ -631,12 +631,14 @@ class TestDocument(TestDocumentMixin):
self
.
assertTrue
(
doc
.
hasData
())
self
.
assertTrue
(
doc
.
hasData
())
def
test_Owner_Base_download
(
self
):
def
test_Owner_Base_download
(
self
):
# tests that owners can download OOo documents, and all headers (including
# tests that owners can download original documents and OOo
# filenames) are set correctly
# documents, and all headers (including filenames) are set
# correctly
doc
=
self
.
portal
.
document_module
.
newContent
(
doc
=
self
.
portal
.
document_module
.
newContent
(
filename
=
'test.ods'
,
filename
=
'test.ods'
,
portal_type
=
'Spreadsheet'
)
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
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'member_user1'
,
'secret'
,
[
'Member'
,
'Owner'
],
[])
uf
.
_doAddUser
(
'member_user1'
,
'secret'
,
[
'Member'
,
'Owner'
],
[])
...
@@ -645,13 +647,18 @@ class TestDocument(TestDocumentMixin):
...
@@ -645,13 +647,18 @@ class TestDocument(TestDocumentMixin):
response
=
self
.
publish
(
'%s/Base_download'
%
doc
.
getPath
(),
response
=
self
.
publish
(
'%s/Base_download'
%
doc
.
getPath
(),
basic
=
'member_user1:secret'
)
basic
=
'member_user1:secret'
)
self
.
assertEqual
(
makeFileUpload
(
'
import_data_list.ods
'
).
read
(),
self
.
assertEqual
(
makeFileUpload
(
'
TEST-en-002.doc
'
).
read
(),
response
.
getBody
())
response
.
getBody
())
self
.
assertEqual
(
'application/
vnd.oasis.opendocument.spreadsheet
'
,
self
.
assertEqual
(
'application/
msword
'
,
response
.
headers
[
'content-type'
])
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'
])
response
.
headers
[
'content-disposition'
])
self
.
tic
()
def
test_Member_download_pdf_format
(
self
):
def
test_Member_download_pdf_format
(
self
):
# tests that members can download OOo documents in pdf format (at least in
# 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