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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
645a4ece
Commit
645a4ece
authored
Apr 17, 2012
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to upload/download Files with unknown mime type
parent
48f86374
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
product/ERP5/mixin/downloadable.py
product/ERP5/mixin/downloadable.py
+11
-10
product/ERP5OOo/tests/testDms.py
product/ERP5OOo/tests/testDms.py
+13
-0
product/ERP5OOo/tests/test_document/TEST-001-en.dummy
product/ERP5OOo/tests/test_document/TEST-001-en.dummy
+1
-0
No files found.
product/ERP5/mixin/downloadable.py
View file @
645a4ece
...
...
@@ -86,16 +86,17 @@ class DownloadableMixin:
output_format
=
None
if
not
format
:
# Guess the format from original mimetype
mimetypes_registry
=
getToolByName
(
self
.
getPortalObject
(),
'mimetypes_registry'
)
mimetype_object_list
=
mimetypes_registry
.
lookup
(
mime
)
for
mimetype_object
in
mimetype_object_list
:
if
mimetype_object
.
extensions
:
output_format
=
mimetype_object
.
extensions
[
0
]
break
elif
mimetype_object
.
globs
:
output_format
=
mimetype_object
.
globs
.
strip
(
'*.'
)
break
if
mime
:
mimetypes_registry
=
getToolByName
(
self
.
getPortalObject
(),
'mimetypes_registry'
)
mimetype_object_list
=
mimetypes_registry
.
lookup
(
mime
)
for
mimetype_object
in
mimetype_object_list
:
if
mimetype_object
.
extensions
:
output_format
=
mimetype_object
.
extensions
[
0
]
break
elif
mimetype_object
.
globs
:
output_format
=
mimetype_object
.
globs
.
strip
(
'*.'
)
break
else
:
output_format
=
format
...
...
product/ERP5OOo/tests/testDms.py
View file @
645a4ece
...
...
@@ -2616,6 +2616,19 @@ return 1
self
.
assertEqual
(
'archived'
,
document_nolang_005
.
getValidationState
())
self
.
assertEqual
(
'shared_alive'
,
document_nolang_006
.
getValidationState
())
def
testFileWithNotDefinedMimeType
(
self
):
upload_file
=
makeFileUpload
(
'TEST-001-en.dummy'
)
kw
=
dict
(
file
=
upload_file
,
synchronous_metadata_discovery
=
True
,
portal_type
=
'File'
)
document
=
self
.
portal
.
Base_contribute
(
**
kw
)
document
.
setReference
(
'TEST'
)
request
=
self
.
app
.
REQUEST
download_file
=
document
.
index_html
(
REQUEST
=
request
,
format
=
None
)
self
.
assertEquals
(
download_file
,
'foo
\
n
'
)
document_format
=
None
self
.
assertEquals
(
'TEST-001-en.dummy'
,
document
.
getStandardFilename
(
document_format
))
class
TestDocumentWithSecurity
(
TestDocumentMixin
):
username
=
'yusei'
...
...
product/ERP5OOo/tests/test_document/TEST-001-en.dummy
0 → 100644
View file @
645a4ece
foo
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