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
37aeabd6
Commit
37aeabd6
authored
Mar 20, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BusinessTemplate: py3 WIP
🚧
parent
2b5ef47b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
...eItem/portal_components/test.erp5.testBusinessTemplate.py
+1
-1
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+4
-4
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
+9
-9
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testBusinessTemplate.py
View file @
37aeabd6
...
@@ -7320,7 +7320,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
...
@@ -7320,7 +7320,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
skin_folder
=
skin_tool
.
_getOb
(
sequence
.
get
(
'skin_folder_id'
))
skin_folder
=
skin_tool
.
_getOb
(
sequence
.
get
(
'skin_folder_id'
))
file_id
=
'fake_js_file'
file_id
=
'fake_js_file'
file_content
=
"""
file_content
=
b
"""
var
var
debug = [42
debug = [42
...
...
product/ERP5/Document/BusinessTemplate.py
View file @
37aeabd6
...
@@ -723,7 +723,7 @@ class ObjectTemplateItem(BaseTemplateItem):
...
@@ -723,7 +723,7 @@ class ObjectTemplateItem(BaseTemplateItem):
def
__init__
(
self
,
id_list
,
tool_id
=
None
,
**
kw
):
def
__init__
(
self
,
id_list
,
tool_id
=
None
,
**
kw
):
BaseTemplateItem
.
__init__
(
self
,
id_list
,
tool_id
=
tool_id
,
**
kw
)
BaseTemplateItem
.
__init__
(
self
,
id_list
,
tool_id
=
tool_id
,
**
kw
)
if
tool_id
is
not
None
:
if
tool_id
is
not
None
:
id_list
=
self
.
_archive
.
keys
(
)
id_list
=
ensure_list
(
self
.
_archive
.
keys
()
)
self
.
_archive
.
clear
()
self
.
_archive
.
clear
()
for
id
in
id_list
:
for
id
in
id_list
:
if
id
!=
''
:
if
id
!=
''
:
...
@@ -3510,14 +3510,14 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
...
@@ -3510,14 +3510,14 @@ class PortalTypeRolesTemplateItem(BaseTemplateItem):
prop_value
=
role
.
get
(
property
)
prop_value
=
role
.
get
(
property
)
if
prop_value
:
if
prop_value
:
if
isinstance
(
prop_value
,
str
):
if
isinstance
(
prop_value
,
str
):
prop_value
=
escape
(
prop_value
.
decode
(
'utf-8'
)
)
prop_value
=
escape
(
prop_value
)
xml_data
+=
"
\
n
<property id='%s'>%s</property>"
%
\
xml_data
+=
"
\
n
<property id='%s'>%s</property>"
%
\
(
property
,
prop_value
)
(
property
,
prop_value
)
# multi
# multi
for
property
in
(
'categories'
,
'category'
,
'base_category'
):
for
property
in
(
'categories'
,
'category'
,
'base_category'
):
for
prop_value
in
role
.
get
(
property
,
[]):
for
prop_value
in
role
.
get
(
property
,
[]):
if
isinstance
(
prop_value
,
str
):
if
isinstance
(
prop_value
,
str
):
prop_value
=
escape
(
prop_value
.
decode
(
'utf-8'
)
)
prop_value
=
escape
(
prop_value
)
xml_data
+=
"
\
n
<multi_property "
\
xml_data
+=
"
\
n
<multi_property "
\
"id='%s'>%s</multi_property>"
%
(
property
,
prop_value
)
"id='%s'>%s</multi_property>"
%
(
property
,
prop_value
)
xml_data
+=
"
\
n
</role>"
xml_data
+=
"
\
n
</role>"
...
@@ -3970,7 +3970,7 @@ class FilesystemDocumentTemplateItem(BaseTemplateItem):
...
@@ -3970,7 +3970,7 @@ class FilesystemDocumentTemplateItem(BaseTemplateItem):
if
not
file_name
.
endswith
(
'.py'
):
if
not
file_name
.
endswith
(
'.py'
):
LOG
(
'Business Template'
,
0
,
'Skipping file "%s"'
%
(
file_name
,
))
LOG
(
'Business Template'
,
0
,
'Skipping file "%s"'
%
(
file_name
,
))
return
return
text
=
file
.
read
()
text
=
file
.
read
()
.
decode
(
'utf-8'
)
self
.
_objects
[
file_name
[:
-
3
]]
=
text
self
.
_objects
[
file_name
[:
-
3
]]
=
text
class
FilesystemToZodbTemplateItem
(
FilesystemDocumentTemplateItem
,
class
FilesystemToZodbTemplateItem
(
FilesystemDocumentTemplateItem
,
...
...
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
View file @
37aeabd6
...
@@ -368,7 +368,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -368,7 +368,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
=
"application/octet-stream"
,
content_type
=
"application/octet-stream"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.bin'
)
),
'.bin'
)
...
@@ -380,7 +380,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -380,7 +380,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
=
"application/epub+zip"
,
content_type
=
"application/epub+zip"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.epub'
)
),
'.epub'
)
...
@@ -392,7 +392,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -392,7 +392,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo.js"
,
title
=
"foo.js"
,
data
=
"a test file"
,
data
=
b
"a test file"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.js'
)
),
'.js'
)
...
@@ -403,7 +403,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -403,7 +403,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""
"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo"
,
title
=
"foo"
,
data
=
"<script> ... </script>"
,
data
=
b
"<script> ... </script>"
,
default_reference
=
"foo.js"
,
default_reference
=
"foo.js"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.js'
)
),
'.js'
)
...
@@ -415,7 +415,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -415,7 +415,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
=
None
,
content_type
=
None
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.bin'
)
),
'.bin'
)
...
@@ -429,7 +429,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -429,7 +429,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
=
"video/wavelet"
,
content_type
=
"video/wavelet"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.bin'
)
),
'.bin'
)
...
@@ -443,7 +443,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -443,7 +443,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/x-uri"
,
content_type
=
"text/x-uri"
,
portal_type
=
"File"
,
portal_type
=
"File"
,
),
'.txt'
)
),
'.txt'
)
...
@@ -472,7 +472,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -472,7 +472,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>
...
@@ -524,7 +524,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
...
@@ -524,7 +524,7 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
"""Test Business Template Import And Export With A PDF Document"""
"""Test Business Template Import And Export With A PDF Document"""
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
self
.
_checkTwoFileImportExportForDocumentInDocumentModule
(
dict
(
title
=
"foo.pdf"
,
title
=
"foo.pdf"
,
data
=
"pdf content, maybe should update for base64 sample"
,
data
=
b
"pdf content, maybe should update for base64 sample"
,
portal_type
=
"PDF"
,
portal_type
=
"PDF"
,
),
'.pdf'
)
),
'.pdf'
)
...
...
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