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
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
ea1d391a
Commit
ea1d391a
authored
Jan 27, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt: fix export 2files
parent
649f6f87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+4
-1
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
+19
-19
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
ea1d391a
...
...
@@ -795,7 +795,10 @@ class ObjectTemplateItem(BaseTemplateItem):
return
mime
.
extensions
[
0
]
for
ext
in
mime
.
globs
:
if
ext
[
0
]
==
"*"
and
ext
.
count
(
"."
)
==
1
:
return
ext
[
2
:].
encode
(
"utf-8"
)
ext
=
ext
[
2
:]
if
six
.
PY2
:
return
ext
.
encode
(
"utf-8"
)
return
ext
# in case we could not read binary flag from mimetypes_registry then return
# '.bin' for all the Portal Types where exported_property_type is data
...
...
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
View file @
ea1d391a
...
...
@@ -121,7 +121,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
pass
file_document_path
=
document_path
+
extension
self
.
assertEqual
([
os
.
path
.
basename
(
file_document_path
)],
map
(
os
.
path
.
basename
,
exported
))
list
(
map
(
os
.
path
.
basename
,
exported
)
))
with
open
(
file_document_path
,
'rb'
)
as
test_file
:
self
.
assertEqual
(
test_file
.
read
(),
data
)
else
:
...
...
@@ -129,7 +129,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
with
open
(
xml_document_path
,
'rb'
)
as
xml_file
:
xml_file_content
=
xml_file
.
read
()
for
exported_property
in
removed_property_list
:
self
.
assertNotIn
(
'<string>'
+
exported_property
+
'</string>'
,
self
.
assertNotIn
(
(
'<string>%s</string>'
%
exported_property
).
encode
()
,
xml_file_content
)
import_template
=
self
.
_importBusinessTemplate
()
...
...
@@ -152,7 +152,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
import_template
=
self
.
_exportAndReImport
(
test_component_path
,
".py"
,
test_component_kw
[
"text_content"
],
test_component_kw
[
"text_content"
]
.
encode
()
,
[
'text_content'
])
self
.
portal
.
portal_components
.
manage_delObjects
([
test_component_id
])
...
...
@@ -242,7 +242,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
import_template
=
self
.
_exportAndReImport
(
python_script_path
,
".py"
,
python_script_kw
[
"_body"
],
python_script_kw
[
"_body"
]
.
encode
()
,
[
'_body'
,
'_code'
])
skin_folder
.
manage_delObjects
(
python_script_id
)
...
...
@@ -315,7 +315,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
self
.
_checkTwoFileImportExportForImageInImageModule
(
dict
(
title
=
"foo"
,
data
=
"malformed data"
,
data
=
b
"malformed data"
,
portal_type
=
"Image"
,
),
'.bin'
)
...
...
@@ -332,7 +332,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
file_id
)
try
:
args
=
file_document_kw
[
'data'
],
(
'data'
,)
if
extension
else
()
args
=
file_document_kw
[
'data'
],
(
b
'data'
,)
if
extension
else
()
except
KeyError
:
args
=
None
,
(
'data'
,)
import_template
=
self
.
_exportAndReImport
(
...
...
@@ -356,7 +356,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
data
=
"a test file"
,
data
=
b
"a test file"
,
content_type
=
"text/javascript"
,
portal_type
=
"File"
,
),
'.js'
)
...
...
@@ -454,7 +454,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
where extension (.xml, exported as ._xml to avoid conflict with the meta-data file)
is identified by the title
"""
file_content
=
"""<person>
file_content
=
b
"""<person>
<name>John</name>
<surname>Doe</surname>
</person>
...
...
@@ -563,7 +563,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
catalog
.
manage_delObjects
([
method_id
])
...
...
@@ -611,7 +611,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
catalog
.
manage_delObjects
([
method_id
])
...
...
@@ -657,7 +657,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
method_id
])
...
...
@@ -696,7 +696,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
page_template_path
,
".zpt"
,
page_template_kw
[
'_text'
],
page_template_kw
[
'_text'
]
.
encode
()
,
[
'_text'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
page_template_id
])
...
...
@@ -747,7 +747,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
dtml_method_path
,
".js"
,
dtml_method_kw
[
'raw'
],
dtml_method_kw
[
'raw'
]
.
encode
()
,
[
'raw'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
...
...
@@ -798,7 +798,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
dtml_method_path
,
".txt"
,
dtml_method_kw
[
'raw'
],
dtml_method_kw
[
'raw'
]
.
encode
()
,
[
'raw'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
...
...
@@ -862,7 +862,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
data
=
""
,
# XXX a dummy string
in data leads to 'NotConvertedError'
data
=
b""
,
# XXX dummy data
in data leads to 'NotConvertedError'
portal_type
=
"Spreadsheet"
,
),
'.bin'
)
...
...
@@ -873,7 +873,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
data
=
""
,
# XXX a dummy string
in data leads to 'NotConvertedError'
data
=
b""
,
# XXX dummy data
in data leads to 'NotConvertedError'
content_type
=
"application/vnd.oasis.opendocument.spreadsheet"
,
portal_type
=
"Spreadsheet"
,
),
'.ods'
)
...
...
@@ -885,7 +885,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo.xlsx"
,
data
=
""
,
# XXX a dummy string
in data leads to 'NotConvertedError'
data
=
b""
,
# XXX dummy data
in data leads to 'NotConvertedError'
portal_type
=
"Spreadsheet"
,
),
'.xlsx'
)
...
...
@@ -910,7 +910,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
test_page_document_path
,
".html"
,
test_page_data_kw
[
"text_content"
],
test_page_data_kw
[
"text_content"
]
.
encode
()
,
[
"text_content"
])
self
.
portal
.
test_page_module
.
manage_delObjects
([
test_page_id
])
...
...
@@ -954,7 +954,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
python_script_path
,
".py"
,
python_script_kw
[
"_body"
],
python_script_kw
[
"_body"
]
.
encode
()
,
[
'_body'
,
'_code'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
python_script_id
])
...
...
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