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
72155b6c
Commit
72155b6c
authored
Apr 15, 2024
by
Carlos Ramos Carreño
Browse files
Options
Browse Files
Download
Plain Diff
Fix TestCorporateIdentityTemplateList in Python 2.
See merge request
nexedi/erp5!1917
parents
75e75866
c3a41e3c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
63 additions
and
53 deletions
+63
-53
bt5/erp5_corporate_identity/ExtensionTemplateItem/portal_components/extension.erp5.TemplateDocumentConversion.py
...l_components/extension.erp5.TemplateDocumentConversion.py
+2
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.py
...erp5_corporate_identity/Base_getTemplateProxyParameter.py
+2
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
...portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
+6
-5
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
...portal_skins/erp5_corporate_identity/Base_viewAsReport.py
+5
-5
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Presentation_viewAsSlideshow.py
...s/erp5_corporate_identity/Presentation_viewAsSlideshow.py
+2
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
...ortal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
+11
-10
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsContract.py
...l_skins/erp5_corporate_identity/WebPage_viewAsContract.py
+10
-9
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
...al_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
+6
-5
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
...al_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
+6
-5
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
..._skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
+9
-8
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_convertHtmlToSingleFile.py
...tem/portal_skins/erp5_web/Base_convertHtmlToSingleFile.py
+2
-0
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
...plateItem/portal_components/document.erp5.TextDocument.py
+2
-3
No files found.
bt5/erp5_corporate_identity/ExtensionTemplateItem/portal_components/extension.erp5.TemplateDocumentConversion.py
View file @
72155b6c
...
...
@@ -31,6 +31,7 @@
from
erp5.component.document.Document
import
DocumentConversionServerProxy
from
base64
import
b64encode
,
b64decode
from
zExceptions
import
Unauthorized
from
Products.ERP5Type.Utils
import
bytes2str
def
convertDocumentByConversionServer
(
self
,
...
...
@@ -48,7 +49,7 @@ def convertDocumentByConversionServer(
proxy
=
DocumentConversionServerProxy
(
self
)
return
b64decode
(
proxy
.
convertFile
(
b
64encode
(
data
).
decode
(
),
b
ytes2str
(
b64encode
(
data
)
),
source_mimetype
,
destination_mimetype
,
zip
,
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.py
View file @
72155b6c
...
...
@@ -9,6 +9,7 @@ Return local parameters that require proxy role to access
# pass_source_data followup uid or context for retrieving info
# pass_flag_site whether called from a web site (no follow-up)
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
bytes2str
portal_type_valid_template_list
=
[
"Web Site"
,
"Web Section"
,
"Web Page"
,
"Letter"
,
"Test Page"
]
portal_type_valid_report_list
=
[
"Project"
,
"Sale Order"
,
"Sale Opportunity"
,
"Requirement Document"
,
"Person"
]
portal_type
=
context
.
getPortalType
()
...
...
@@ -128,7 +129,7 @@ def populateOrganisationDict(my_organisation_list):
if
organisation_default_image
:
output_dict
[
"logo_url"
]
=
organisation_default_image
.
getRelativeUrl
()
output_dict
[
"logo_data_url"
]
=
'data:image/png;;base64,%s'
%
(
b
64encode
(
organisation_default_image
.
convert
(
format
=
"png"
,
display
=
"thumbnail"
)[
1
]).
decode
(
)
b
ytes2str
(
b64encode
(
organisation_default_image
.
convert
(
format
=
"png"
,
display
=
"thumbnail"
)[
1
])
)
)
else
:
output_dict
[
"logo_url"
]
=
err
(
"logo_url"
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
View file @
72155b6c
...
...
@@ -28,6 +28,7 @@ MAIN FILE: generate letter in different output formats
import
re
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
str2bytes
,
bytes2str
blank
=
''
pref
=
context
.
getPortalObject
().
portal_preferences
...
...
@@ -256,9 +257,9 @@ if letter_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_content
,
allow_script
=
True
).
encode
(
'utf-8'
)
header_embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_head
,
allow_script
=
True
).
encode
(
'utf-8'
)
footer_embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_foot
,
allow_script
=
True
).
encode
(
'utf-8'
)
embedded_html_data
=
str2bytes
(
letter
.
Base_convertHtmlToSingleFile
(
letter_content
,
allow_script
=
True
)
)
header_embedded_html_data
=
str2bytes
(
letter
.
Base_convertHtmlToSingleFile
(
letter_head
,
allow_script
=
True
)
)
footer_embedded_html_data
=
str2bytes
(
letter
.
Base_convertHtmlToSingleFile
(
letter_foot
,
allow_script
=
True
)
)
pdf_file
=
letter
.
Base_cloudoooDocumentConvert
(
embedded_html_data
,
"html"
,
"pdf"
,
conversion_kw
=
dict
(
encoding
=
"utf8"
,
margin_top
=
letter_header_margin_to_top
,
...
...
@@ -266,8 +267,8 @@ if letter_format == "pdf":
margin_left
=
0
,
margin_right
=
0
,
header_spacing
=
1
,
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
View file @
72155b6c
...
...
@@ -36,7 +36,7 @@ MAIN FILE: generate report (book header/footer and report content)
# report_title report title
# report_header custom report header
from
Products.ERP5Type.Utils
import
str2bytes
from
Products.ERP5Type.Utils
import
str2bytes
,
bytes2str
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
...
...
@@ -261,7 +261,7 @@ if doc_format == "pdf":
# ================ encode and build cloudoo elements =========================
header_embedded_html_data
=
str2bytes
(
doc
.
Base_convertHtmlToSingleFile
(
doc_head
,
allow_script
=
True
))
before_toc_data_list
=
[]
xsl_style_sheet_data
=
blank
.
encode
(
)
xsl_style_sheet_data
=
str2bytes
(
blank
)
embedded_html_data
=
str2bytes
(
doc
.
Base_convertHtmlToSingleFile
(
doc_content
,
allow_script
=
True
))
footer_embedded_html_data
=
str2bytes
(
doc
.
Base_convertHtmlToSingleFile
(
doc_foot
,
allow_script
=
True
))
default_conversion_kw
=
dict
(
...
...
@@ -270,10 +270,10 @@ if doc_format == "pdf":
margin_bottom
=
20
,
toc
=
False
,
before_toc_data_list
=
before_toc_data_list
,
xsl_style_sheet_data
=
b
64encode
(
xsl_style_sheet_data
).
decode
(
),
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
xsl_style_sheet_data
=
b
ytes2str
(
b64encode
(
xsl_style_sheet_data
)
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
header_spacing
=
10
,
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
footer_spacing
=
3
,
)
default_conversion_kw
.
update
(
conversion_dict
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Presentation_viewAsSlideshow.py
View file @
72155b6c
...
...
@@ -13,6 +13,7 @@ Try to convert old OpenOffice presentations into slideshows
import
re
from
io
import
BytesIO
from
zipfile
import
ZipFile
from
Products.ERP5Type.Utils
import
bytes2str
blank
=
''
flags
=
re
.
MULTILINE
|
re
.
DOTALL
|
re
.
IGNORECASE
...
...
@@ -32,7 +33,7 @@ def getSlideList(zip_content):
name
.
replace
(
'img'
,
''
).
replace
(
'text'
,
''
))):
if
name
.
endswith
(
'.html'
):
slide_list
.
extend
(
re
.
findall
(
r'<html>(.*?)</html>'
,
zf
.
read
(
name
).
decode
(
'utf-8'
),
flags
=
flags
)
re
.
findall
(
r'<html>(.*?)</html>'
,
bytes2str
(
zf
.
read
(
name
)
),
flags
=
flags
)
)
return
slide_list
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
View file @
72155b6c
...
...
@@ -36,6 +36,7 @@ import re
import
six
from
Products.PythonScripts.standard
import
html_quote
from
Products.ERP5Type.Utils
import
str2bytes
,
bytes2str
from
base64
import
b64encode
blank
=
''
...
...
@@ -359,22 +360,22 @@ elif book_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
header_embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_head
,
allow_script
=
True
).
encode
(
'utf-8'
)
header_embedded_html_data
=
str2bytes
(
book
.
Base_convertHtmlToSingleFile
(
book_head
,
allow_script
=
True
)
)
before_toc_data_list
=
[
b
64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_cover
,
allow_script
=
True
).
encode
(
'utf-8'
)).
decode
(
),
b
ytes2str
(
b64encode
(
str2bytes
(
book
.
Base_convertHtmlToSingleFile
(
book_cover
,
allow_script
=
True
)))
),
]
after_toc_data_list
=
[]
if
book_include_history_table
:
before_toc_data_list
.
append
(
b
64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_history
,
allow_script
=
True
).
encode
(
'utf-8'
)).
decode
(
)
b
ytes2str
(
b64encode
(
str2bytes
(
book
.
Base_convertHtmlToSingleFile
(
book_history
,
allow_script
=
True
)))
)
)
#if book_include_reference_table:
# after_toc_data_list.append(
# b64encode(
book.Base_convertHtmlToSingleFile(book_references, allow_script=True).encode('utf-8'
)).decode()
# b64encode(
str2bytes(book.Base_convertHtmlToSingleFile(book_references, allow_script=True)
)).decode()
# )
xsl_style_sheet_data
=
book_table_of_content
.
encode
(
'utf-8'
)
embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_content
,
allow_script
=
True
).
encode
(
'utf-8'
)
footer_embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_foot
,
allow_script
=
True
).
encode
(
'utf-8'
)
xsl_style_sheet_data
=
str2bytes
(
book_table_of_content
)
embedded_html_data
=
str2bytes
(
book
.
Base_convertHtmlToSingleFile
(
book_content
,
allow_script
=
True
)
)
footer_embedded_html_data
=
str2bytes
(
book
.
Base_convertHtmlToSingleFile
(
book_foot
,
allow_script
=
True
)
)
if
margin_15mm
:
margin_top
=
50
margin_bottom
=
25
...
...
@@ -387,11 +388,11 @@ elif book_format == "pdf":
margin_bottom
=
margin_bottom
,
toc
=
True
if
book_include_content_table
else
False
,
before_toc_data_list
=
before_toc_data_list
,
xsl_style_sheet_data
=
b
64encode
(
xsl_style_sheet_data
).
decode
(
),
xsl_style_sheet_data
=
b
ytes2str
(
b64encode
(
xsl_style_sheet_data
)
),
after_toc_data_list
=
after_toc_data_list
,
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
header_spacing
=
10
,
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
footer_spacing
=
3
,
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsContract.py
View file @
72155b6c
...
...
@@ -2,6 +2,7 @@ import re
import
six
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
blank
=
b''
pref
=
context
.
getPortalObject
().
portal_preferences
...
...
@@ -290,22 +291,22 @@ elif contract_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
header_embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_head
,
allow_script
=
True
).
encode
(
'utf-8'
)
header_embedded_html_data
=
str2bytes
(
context
.
Base_convertHtmlToSingleFile
(
contract_head
,
allow_script
=
True
)
)
before_toc_data_list
=
[
b
64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_cover
,
allow_script
=
True
).
encode
(
'utf-8'
)).
decode
(
),
b
ytes2str
(
b64encode
(
str2bytes
(
context
.
Base_convertHtmlToSingleFile
(
contract_cover
,
allow_script
=
True
)))
),
]
after_toc_data_list
=
[]
if
contract_include_history_table
:
before_toc_data_list
.
append
(
b
64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_history
,
allow_script
=
True
).
encode
(
'utf-8'
)).
decode
(
)
b
ytes2str
(
b64encode
(
str2bytes
(
context
.
Base_convertHtmlToSingleFile
(
contract_history
,
allow_script
=
True
)))
)
)
#if contract_include_reference_table:
# after_toc_data_list.append(
# b
64encode(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True)).decode(
)
# b
ytes2str(b64encode(str2bytes(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True)))
)
# )
xsl_style_sheet_data
=
contract_table_of_content
embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_content
,
allow_script
=
True
).
encode
(
'utf-8'
)
footer_embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_foot
,
allow_script
=
True
).
encode
(
'utf-8'
)
embedded_html_data
=
str2bytes
(
context
.
Base_convertHtmlToSingleFile
(
contract_content
,
allow_script
=
True
)
)
footer_embedded_html_data
=
str2bytes
(
context
.
Base_convertHtmlToSingleFile
(
contract_foot
,
allow_script
=
True
)
)
margin_top
=
40
margin_bottom
=
20
pdf_file
=
context
.
Base_cloudoooDocumentConvert
(
embedded_html_data
,
"html"
,
"pdf"
,
conversion_kw
=
dict
(
...
...
@@ -314,11 +315,11 @@ elif contract_format == "pdf":
margin_bottom
=
margin_bottom
,
toc
=
True
if
contract_include_content_table
else
False
,
before_toc_data_list
=
before_toc_data_list
,
xsl_style_sheet_data
=
b
64encode
(
xsl_style_sheet_data
).
decode
(
),
xsl_style_sheet_data
=
b
ytes2str
(
b64encode
(
xsl_style_sheet_data
)
),
after_toc_data_list
=
after_toc_data_list
,
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
header_spacing
=
10
,
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
footer_spacing
=
3
,
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
View file @
72155b6c
...
...
@@ -26,6 +26,7 @@ import six
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
blank
=
''
pref
=
context
.
getPortalObject
().
portal_preferences
...
...
@@ -257,9 +258,9 @@ if leaflet_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
embedded_html_data
=
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_content
,
allow_script
=
True
).
encode
(
'utf-8'
)
header_embedded_html_data
=
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_head
,
allow_script
=
True
).
encode
(
'utf-8'
)
footer_embedded_html_data
=
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_foot
,
allow_script
=
True
).
encode
(
'utf-8'
)
embedded_html_data
=
str2bytes
(
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_content
,
allow_script
=
True
)
)
header_embedded_html_data
=
str2bytes
(
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_head
,
allow_script
=
True
)
)
footer_embedded_html_data
=
str2bytes
(
leaflet
.
Base_convertHtmlToSingleFile
(
leaflet_foot
,
allow_script
=
True
)
)
pdf_file
=
leaflet
.
Base_cloudoooDocumentConvert
(
embedded_html_data
,
"html"
,
"pdf"
,
conversion_kw
=
dict
(
encoding
=
"utf8"
,
orientation
=
"portrait"
,
...
...
@@ -267,9 +268,9 @@ if leaflet_format == "pdf":
margin_bottom
=
20
,
margin_left
=
0
,
margin_right
=
0
,
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
header_spacing
=
10
,
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
footer_spacing
=
3
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
View file @
72155b6c
...
...
@@ -23,6 +23,7 @@ MAIN FILE: render press release in different output formats
import
re
import
six
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
blank
=
''
pref
=
context
.
getPortalObject
().
portal_preferences
...
...
@@ -228,9 +229,9 @@ if release_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
embedded_html_data
=
release
.
Base_convertHtmlToSingleFile
(
release_content
,
allow_script
=
True
).
encode
(
'utf-8'
)
header_embedded_html_data
=
release
.
Base_convertHtmlToSingleFile
(
release_head
,
allow_script
=
True
).
encode
(
'utf-8'
)
footer_embedded_html_data
=
release
.
Base_convertHtmlToSingleFile
(
release_foot
,
allow_script
=
True
).
encode
(
'utf-8'
)
embedded_html_data
=
str2bytes
(
release
.
Base_convertHtmlToSingleFile
(
release_content
,
allow_script
=
True
)
)
header_embedded_html_data
=
str2bytes
(
release
.
Base_convertHtmlToSingleFile
(
release_head
,
allow_script
=
True
)
)
footer_embedded_html_data
=
str2bytes
(
release
.
Base_convertHtmlToSingleFile
(
release_foot
,
allow_script
=
True
)
)
pdf_file
=
release
.
Base_cloudoooDocumentConvert
(
embedded_html_data
,
"html"
,
"pdf"
,
conversion_kw
=
dict
(
encoding
=
"utf8"
,
orientation
=
"portrait"
,
...
...
@@ -238,9 +239,9 @@ if release_format == "pdf":
margin_bottom
=
20
,
margin_left
=
0
,
margin_right
=
0
,
header_html_data
=
b
64encode
(
header_embedded_html_data
).
decode
(
),
header_html_data
=
b
ytes2str
(
b64encode
(
header_embedded_html_data
)
),
header_spacing
=
10
,
footer_html_data
=
b
64encode
(
footer_embedded_html_data
).
decode
(
),
footer_html_data
=
b
ytes2str
(
b64encode
(
footer_embedded_html_data
)
),
footer_spacing
=
3
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
View file @
72155b6c
...
...
@@ -27,6 +27,7 @@ import re
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
blank
=
''
flags
=
re
.
MULTILINE
|
re
.
DOTALL
|
re
.
IGNORECASE
...
...
@@ -420,23 +421,23 @@ if doc_format == "pdf" or doc_format == "mhtml":
)
# ================ encode and build cloudoo elements =========================
footer_embedded_html_data =
doc.Base_convertHtmlToSingleFile(doc_slideshow_footer, allow_script=True).encode('utf-8'
)
#embedded_html_data =
doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True).encode('utf-8'
)
cover =
doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True).encode('utf-8'
)
footer_embedded_html_data =
str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_footer, allow_script=True)
)
#embedded_html_data =
str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True)
)
cover =
str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
)
before_body_data_list = [
b
64encode(cover).decode(
),
b
ytes2str(b64encode(cover)
),
]
if doc_format == "
mhtml
":
context.REQUEST.RESPONSE.setHeader("
Content
-
Type
", "
text
/
html
;
")
return doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
if doc_display_notes:
#after_body_data_list = [
# b
64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True).encode('utf-8')).decode(
),
# b
ytes2str(b64encode(str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)))
),
#]
embedded_html_data =
doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True).encode('utf-8'
)
embedded_html_data =
str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)
)
after_body_data_list = []
else:
embedded_html_data =
doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True).encode('utf-8'
)
embedded_html_data =
str2bytes(doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True)
)
after_body_data_list = []
#after_body_data_list = []
pdf_file = doc.Base_cloudoooDocumentConvert(embedded_html_data, "
html
", "
pdf
", conversion_kw=dict(
...
...
@@ -447,7 +448,7 @@ if doc_format == "pdf" or doc_format == "mhtml":
before_body_data_list=before_body_data_list,
after_body_data_list=after_body_data_list,
header_spacing=10,
footer_html_data=b
64encode(footer_embedded_html_data).decode(
),
footer_html_data=b
ytes2str(b64encode(footer_embedded_html_data)
),
footer_spacing=3
)
)
...
...
bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/Base_convertHtmlToSingleFile.py
View file @
72155b6c
...
...
@@ -28,6 +28,8 @@ mhtml_message = {
}
def
main
(
data
):
# type: (str) -> str
# Preserves input type (unicode or bytes)
if
isinstance
(
data
,
bytes
):
data
=
data
.
decode
(
"utf-8"
)
data
=
u""
.
join
([
fn
(
p
)
for
fn
,
p
in
handleHtmlPartList
(
parseHtml
(
data
))])
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.TextDocument.py
View file @
72155b6c
...
...
@@ -42,7 +42,7 @@ from string import Template
from
erp5.component.mixin.CachedConvertableMixin
import
CachedConvertableMixin
from
erp5.component.mixin.BaseConvertableFileMixin
import
BaseConvertableFileMixin
from
Products.ERP5Type.mixin.text_content_history
import
TextContentHistoryMixin
from
Products.ERP5Type.Utils
import
guessEncodingFromText
,
bytes2str
from
Products.ERP5Type.Utils
import
guessEncodingFromText
,
bytes2str
,
str2bytes
from
lxml
import
html
as
etree_html
from
lxml
import
etree
...
...
@@ -428,8 +428,7 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin, TextContent
data
=
self
.
_baseGetTextContent
()
else
:
data
=
self
.
_baseGetTextContent
(
default
)
if
not
isinstance
(
data
,
bytes
):
return
data
.
encode
(
'utf-8'
)
return
str2bytes
(
data
)
else
:
if
default
is
_MARKER
:
return
File
.
getData
(
self
)
...
...
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