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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
4cabb073
Commit
4cabb073
authored
Jan 27, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt: fix export 2files
parent
bc4a8a2e
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 @
4cabb073
...
@@ -795,7 +795,10 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -795,7 +795,10 @@ class ObjectTemplateItem(BaseTemplateItem):
return
mime
.
extensions
[
0
]
return
mime
.
extensions
[
0
]
for
ext
in
mime
.
globs
:
for
ext
in
mime
.
globs
:
if
ext
[
0
]
==
"*"
and
ext
.
count
(
"."
)
==
1
:
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
# 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
# '.bin' for all the Portal Types where exported_property_type is data
...
...
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
View file @
4cabb073
...
@@ -121,7 +121,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
...
@@ -121,7 +121,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
pass
pass
file_document_path
=
document_path
+
extension
file_document_path
=
document_path
+
extension
self
.
assertEqual
([
os
.
path
.
basename
(
file_document_path
)],
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
:
with
open
(
file_document_path
,
'rb'
)
as
test_file
:
self
.
assertEqual
(
test_file
.
read
(),
data
)
self
.
assertEqual
(
test_file
.
read
(),
data
)
else
:
else
:
...
@@ -129,7 +129,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
...
@@ -129,7 +129,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
with
open
(
xml_document_path
,
'rb'
)
as
xml_file
:
with
open
(
xml_document_path
,
'rb'
)
as
xml_file
:
xml_file_content
=
xml_file
.
read
()
xml_file_content
=
xml_file
.
read
()
for
exported_property
in
removed_property_list
:
for
exported_property
in
removed_property_list
:
self
.
assertNotIn
(
'<string>'
+
exported_property
+
'</string>'
,
self
.
assertNotIn
(
(
'<string>%s</string>'
%
exported_property
).
encode
()
,
xml_file_content
)
xml_file_content
)
import_template
=
self
.
_importBusinessTemplate
()
import_template
=
self
.
_importBusinessTemplate
()
...
@@ -152,7 +152,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
...
@@ -152,7 +152,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
test_component_path
,
test_component_path
,
".py"
,
".py"
,
test_component_kw
[
"text_content"
],
test_component_kw
[
"text_content"
]
.
encode
()
,
[
'text_content'
])
[
'text_content'
])
self
.
portal
.
portal_components
.
manage_delObjects
([
test_component_id
])
self
.
portal
.
portal_components
.
manage_delObjects
([
test_component_id
])
...
@@ -242,7 +242,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
...
@@ -242,7 +242,7 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
python_script_path
,
python_script_path
,
".py"
,
".py"
,
python_script_kw
[
"_body"
],
python_script_kw
[
"_body"
]
.
encode
()
,
[
'_body'
,
'_code'
])
[
'_body'
,
'_code'
])
skin_folder
.
manage_delObjects
(
python_script_id
)
skin_folder
.
manage_delObjects
(
python_script_id
)
...
@@ -315,7 +315,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -315,7 +315,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForImageInImageModule
(
dict
(
self
.
_checkTwoFileImportExportForImageInImageModule
(
dict
(
title
=
"foo"
,
title
=
"foo"
,
data
=
"malformed data"
,
data
=
b
"malformed data"
,
portal_type
=
"Image"
,
portal_type
=
"Image"
,
),
'.bin'
)
),
'.bin'
)
...
@@ -332,7 +332,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -332,7 +332,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
file_id
)
file_id
)
try
:
try
:
args
=
file_document_kw
[
'data'
],
(
'data'
,)
if
extension
else
()
args
=
file_document_kw
[
'data'
],
(
b
'data'
,)
if
extension
else
()
except
KeyError
:
except
KeyError
:
args
=
None
,
(
'data'
,)
args
=
None
,
(
'data'
,)
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
...
@@ -356,7 +356,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -356,7 +356,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
title
=
"foo"
,
data
=
"a test file"
,
data
=
b
"a test file"
,
content_type
=
"text/javascript"
,
content_type
=
"text/javascript"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.js'
)
),
'.js'
)
...
@@ -454,7 +454,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -454,7 +454,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
where extension (.xml, exported as ._xml to avoid conflict with the meta-data file)
where extension (.xml, exported as ._xml to avoid conflict with the meta-data file)
is identified by the title
is identified by the title
"""
"""
file_content
=
"""<person>
file_content
=
b
"""<person>
<name>John</name>
<name>John</name>
<surname>Doe</surname>
<surname>Doe</surname>
</person>
</person>
...
@@ -563,7 +563,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -563,7 +563,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
method_document_path
,
".sql"
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
[
'src'
])
catalog
.
manage_delObjects
([
method_id
])
catalog
.
manage_delObjects
([
method_id
])
...
@@ -611,7 +611,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -611,7 +611,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
method_document_path
,
".sql"
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
[
'src'
])
catalog
.
manage_delObjects
([
method_id
])
catalog
.
manage_delObjects
([
method_id
])
...
@@ -657,7 +657,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -657,7 +657,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
method_document_path
,
method_document_path
,
".sql"
,
".sql"
,
'dummy_method_template'
,
b
'dummy_method_template'
,
[
'src'
])
[
'src'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
method_id
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
method_id
])
...
@@ -696,7 +696,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -696,7 +696,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
page_template_path
,
page_template_path
,
".zpt"
,
".zpt"
,
page_template_kw
[
'_text'
],
page_template_kw
[
'_text'
]
.
encode
()
,
[
'_text'
])
[
'_text'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
page_template_id
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
page_template_id
])
...
@@ -747,7 +747,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -747,7 +747,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
dtml_method_path
,
dtml_method_path
,
".js"
,
".js"
,
dtml_method_kw
[
'raw'
],
dtml_method_kw
[
'raw'
]
.
encode
()
,
[
'raw'
])
[
'raw'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
...
@@ -798,7 +798,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -798,7 +798,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
dtml_method_path
,
dtml_method_path
,
".txt"
,
".txt"
,
dtml_method_kw
[
'raw'
],
dtml_method_kw
[
'raw'
]
.
encode
()
,
[
'raw'
])
[
'raw'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
dtml_method_id
])
...
@@ -862,7 +862,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -862,7 +862,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
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"
,
portal_type
=
"Spreadsheet"
,
),
'.bin'
)
),
'.bin'
)
...
@@ -873,7 +873,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -873,7 +873,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
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"
,
content_type
=
"application/vnd.oasis.opendocument.spreadsheet"
,
portal_type
=
"Spreadsheet"
,
portal_type
=
"Spreadsheet"
,
),
'.ods'
)
),
'.ods'
)
...
@@ -885,7 +885,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -885,7 +885,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo.xlsx"
,
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"
,
portal_type
=
"Spreadsheet"
,
),
'.xlsx'
)
),
'.xlsx'
)
...
@@ -910,7 +910,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -910,7 +910,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
test_page_document_path
,
test_page_document_path
,
".html"
,
".html"
,
test_page_data_kw
[
"text_content"
],
test_page_data_kw
[
"text_content"
]
.
encode
()
,
[
"text_content"
])
[
"text_content"
])
self
.
portal
.
test_page_module
.
manage_delObjects
([
test_page_id
])
self
.
portal
.
test_page_module
.
manage_delObjects
([
test_page_id
])
...
@@ -954,7 +954,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -954,7 +954,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
import_template
=
self
.
_exportAndReImport
(
import_template
=
self
.
_exportAndReImport
(
python_script_path
,
python_script_path
,
".py"
,
".py"
,
python_script_kw
[
"_body"
],
python_script_kw
[
"_body"
]
.
encode
()
,
[
'_body'
,
'_code'
])
[
'_body'
,
'_code'
])
self
.
portal
.
portal_skins
[
skin_folder_id
].
manage_delObjects
([
python_script_id
])
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