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
732896c4
Commit
732896c4
authored
Jan 22, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corporate_identity: py3
parent
aa0101bf
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
53 deletions
+66
-53
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
...portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
+2
-2
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
...portal_skins/erp5_corporate_identity/Base_viewAsReport.py
+3
-3
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_createTableOfContent.py
...s/erp5_corporate_identity/WebPage_createTableOfContent.py
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_embedReportDocumentList.py
...rp5_corporate_identity/WebPage_embedReportDocumentList.py
+9
-4
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
...ortal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
+14
-12
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsContract.py
...l_skins/erp5_corporate_identity/WebPage_viewAsContract.py
+12
-11
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
...al_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
+8
-6
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
...al_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
+8
-6
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
..._skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
+6
-5
bt5/erp5_corporate_identity_test/SkinTemplateItem/portal_skins/erp5_corporate_identity_test/Base_generateCorporareIdentityTestReport.py
...identity_test/Base_generateCorporareIdentityTestReport.py
+1
-1
bt5/erp5_corporate_identity_test/TestTemplateItem/portal_components/test.erp5.testCorporateIdentityMethod.py
...ortal_components/test.erp5.testCorporateIdentityMethod.py
+2
-2
No files found.
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
View file @
732896c4
...
...
@@ -266,8 +266,8 @@ if letter_format == "pdf":
margin_left
=
0
,
margin_right
=
0
,
header_spacing
=
1
,
header_html_data
=
b64encode
(
header_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
View file @
732896c4
...
...
@@ -269,10 +269,10 @@ if doc_format == "pdf":
margin_bottom
=
20
,
toc
=
False
,
before_toc_data_list
=
before_toc_data_list
,
xsl_style_sheet_data
=
b64encode
(
xsl_style_sheet_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
),
xsl_style_sheet_data
=
b64encode
(
xsl_style_sheet_data
)
.
decode
()
,
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
header_spacing
=
10
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
footer_spacing
=
3
,
)
default_conversion_kw
.
update
(
conversion_dict
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_createTableOfContent.py
View file @
732896c4
...
...
@@ -15,7 +15,7 @@ import re
from
Products.PythonScripts.standard
import
html_quote
blank
=
""
header_current
=
1
header_current
=
'0'
header_initial
=
None
table_of_content
=
blank
index
=
0
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_embedReportDocumentList.py
View file @
732896c4
...
...
@@ -10,6 +10,7 @@ Insert reports linked to in a document (including backcompat handling)
# doc_format output format being generated
import
re
import
six
document
=
context
...
...
@@ -28,10 +29,14 @@ def getReportViaFancyName(my_report_name, follow_up):
if
method_call
is
not
None
:
# extra curl: Coverage report requires parameter details (1|0)
if
coverage_name
:
return
method_call
(
display_comment
=
True
)[
0
].
encode
(
encoding
=
'UTF-8'
)
if
detail_name
:
return
method_call
(
format
=
'detailed'
,
display_detail
=
1
)[
0
].
encode
(
encoding
=
'UTF-8'
)
return
method_call
(
display_comment
=
True
)[
0
].
encode
(
encoding
=
'UTF-8'
)
result
=
method_call
(
display_comment
=
True
)[
0
]
elif
detail_name
:
result
=
method_call
(
format
=
'detailed'
,
display_detail
=
1
)[
0
]
else
:
result
=
method_call
(
display_comment
=
True
)[
0
]
if
six
.
PY2
:
result
=
result
.
encode
(
encoding
=
'UTF-8'
)
return
result
if
doc_content
.
find
(
'${WebPage_'
)
!=
-
1
:
document_required_follow_up_list
=
[
x
.
getObject
()
for
x
in
document
.
portal_catalog
(
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
View file @
732896c4
...
...
@@ -33,6 +33,7 @@ MAIN FILE: generate book in different output formats
# display_svg format for svg images (svg, png*)
import
re
import
six
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
...
...
@@ -83,8 +84,7 @@ book_version = html_quote(override_document_version) if override_document_versio
book_description
=
html_quote
(
override_document_description
)
if
override_document_description
else
book
.
getDescription
()
book_title
=
html_quote
(
override_document_title
)
if
override_document_title
else
book
.
getTitle
()
# unicode
if
isinstance
(
book_content
,
unicode
):
if
six
.
PY2
and
isinstance
(
book_content
,
unicode
):
book_content
=
book_content
.
encode
(
"UTF-8"
)
# backcompat
...
...
@@ -197,7 +197,9 @@ if book_include_reference_table:
#else:
# book_content = book_content.replace("${WebPage_insertTableOfReferences}", book_references.encode('UTF-8').strip())
book_references
=
book
.
Base_unescape
(
book_references
)
book_content
=
book_content
.
replace
(
"${WebPage_insertTableOfReferences}"
,
book_references
.
encode
(
'UTF-8'
).
strip
())
if
six
.
PY2
:
book_references
=
book_references
.
encode
(
'utf-8'
)
book_content
=
book_content
.
replace
(
"${WebPage_insertTableOfReferences}"
,
book_references
.
strip
())
else
:
book_content
=
book_content
.
replace
(
"${WebPage_insertTableOfReferences}"
,
blank
)
...
...
@@ -357,22 +359,22 @@ elif book_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
header_embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_head
,
allow_script
=
True
)
header_embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_head
,
allow_script
=
True
)
.
encode
(
'utf-8'
)
before_toc_data_list
=
[
b64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_cover
,
allow_script
=
True
)),
b64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_cover
,
allow_script
=
True
)
.
encode
(
'utf-8'
)).
decode
(
),
]
after_toc_data_list
=
[]
if
book_include_history_table
:
before_toc_data_list
.
append
(
b64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_history
,
allow_script
=
True
))
b64encode
(
book
.
Base_convertHtmlToSingleFile
(
book_history
,
allow_script
=
True
)
.
encode
(
'utf-8'
)).
decode
(
)
)
#if book_include_reference_table:
# after_toc_data_list.append(
# b64encode(book.Base_convertHtmlToSingleFile(book_references, allow_script=True))
# b64encode(book.Base_convertHtmlToSingleFile(book_references, allow_script=True)
.encode('utf-8')).decode(
)
# )
xsl_style_sheet_data
=
book_table_of_content
embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_content
,
allow_script
=
True
)
footer_embedded_html_data
=
book
.
Base_convertHtmlToSingleFile
(
book_foot
,
allow_script
=
True
)
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'
)
if
margin_15mm
:
margin_top
=
50
margin_bottom
=
25
...
...
@@ -385,11 +387,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
=
b64encode
(
xsl_style_sheet_data
),
xsl_style_sheet_data
=
b64encode
(
xsl_style_sheet_data
)
.
decode
()
,
after_toc_data_list
=
after_toc_data_list
,
header_html_data
=
b64encode
(
header_embedded_html_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
header_spacing
=
10
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
footer_spacing
=
3
,
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsContract.py
View file @
732896c4
import
re
import
six
from
base64
import
b64encode
blank
=
''
blank
=
b
''
pref
=
context
.
getPortalObject
().
portal_preferences
contract_format
=
kw
.
get
(
'format'
)
or
'html'
...
...
@@ -35,7 +36,7 @@ contract_version = context.getVersion() or "001"
contract_description
=
context
.
getDescription
()
contract_title
=
context
.
getTitle
()
if
isinstance
(
contract_content
,
unicode
):
if
six
.
PY2
and
isinstance
(
contract_content
,
unicode
):
contract_content
=
contract_content
.
encode
(
"UTF-8"
)
contract_history_section_list
=
re
.
findall
(
'<section.+?>.+?</section>'
,
contract_content
,
re
.
S
)
...
...
@@ -289,22 +290,22 @@ elif contract_format == "pdf":
)
# ================ encode and build cloudoo elements =========================
header_embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_head
,
allow_script
=
True
)
header_embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_head
,
allow_script
=
True
)
.
encode
(
'utf-8'
)
before_toc_data_list
=
[
b64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_cover
,
allow_script
=
True
)),
b64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_cover
,
allow_script
=
True
)
.
encode
(
'utf-8'
)).
decode
(
),
]
after_toc_data_list
=
[]
if
contract_include_history_table
:
before_toc_data_list
.
append
(
b64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_history
,
allow_script
=
True
))
b64encode
(
context
.
Base_convertHtmlToSingleFile
(
contract_history
,
allow_script
=
True
)
.
encode
(
'utf-8'
)).
decode
(
)
)
#if contract_include_reference_table:
# after_toc_data_list.append(
# b64encode(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True))
# b64encode(context.Base_convertHtmlToSingleFile(contract_references, allow_script=True))
.decode()
# )
xsl_style_sheet_data
=
contract_table_of_content
embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_content
,
allow_script
=
True
)
footer_embedded_html_data
=
context
.
Base_convertHtmlToSingleFile
(
contract_foot
,
allow_script
=
True
)
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'
)
margin_top
=
40
margin_bottom
=
20
pdf_file
=
context
.
Base_cloudoooDocumentConvert
(
embedded_html_data
,
"html"
,
"pdf"
,
conversion_kw
=
dict
(
...
...
@@ -313,11 +314,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
=
b64encode
(
xsl_style_sheet_data
),
xsl_style_sheet_data
=
b64encode
(
xsl_style_sheet_data
)
.
decode
()
,
after_toc_data_list
=
after_toc_data_list
,
header_html_data
=
b64encode
(
header_embedded_html_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
header_spacing
=
10
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
footer_spacing
=
3
,
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLeaflet.py
View file @
732896c4
...
...
@@ -22,6 +22,7 @@ MAIN FILE: render two pager in different output formats
# document_save: save file in document module (default None)
import
re
import
six
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
...
...
@@ -146,10 +147,11 @@ if leaflet_display_side:
)
#leaflet_content = leaflet_legalese.decode() + leaflet_content.decode()
if
isinstance
(
leaflet_legalese
,
unicode
):
leaflet_legalese
=
leaflet_legalese
.
encode
(
"UTF-8"
)
if
isinstance
(
leaflet_content
,
unicode
):
leaflet_content
=
leaflet_content
.
encode
(
"UTF-8"
)
if
six
.
PY2
:
if
isinstance
(
leaflet_legalese
,
unicode
):
leaflet_legalese
=
leaflet_legalese
.
encode
(
"UTF-8"
)
if
isinstance
(
leaflet_content
,
unicode
):
leaflet_content
=
leaflet_content
.
encode
(
"UTF-8"
)
leaflet_content
=
leaflet_legalese
+
leaflet_content
...
...
@@ -265,9 +267,9 @@ if leaflet_format == "pdf":
margin_bottom
=
20
,
margin_left
=
0
,
margin_right
=
0
,
header_html_data
=
b64encode
(
header_embedded_html_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
header_spacing
=
10
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
footer_spacing
=
3
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsRelease.py
View file @
732896c4
...
...
@@ -21,6 +21,7 @@ MAIN FILE: render press release in different output formats
# document_save: save file in document module (default None)
import
re
import
six
from
base64
import
b64encode
blank
=
''
...
...
@@ -137,10 +138,11 @@ if release_display_about:
release_relative_url
=
release_relative_url
,
)
#release_content = release_content.decode() + release_about.decode()
if
isinstance
(
release_content
,
unicode
):
release_content
=
release_content
.
encode
(
"UTF-8"
)
if
isinstance
(
release_about
,
unicode
):
release_about
=
release_about
.
encode
(
"UTF-8"
)
if
six
.
PY2
:
if
isinstance
(
release_content
,
unicode
):
release_content
=
release_content
.
encode
(
"UTF-8"
)
if
isinstance
(
release_about
,
unicode
):
release_about
=
release_about
.
encode
(
"UTF-8"
)
release_content
=
release_content
+
release_about
...
...
@@ -236,9 +238,9 @@ if release_format == "pdf":
margin_bottom
=
20
,
margin_left
=
0
,
margin_right
=
0
,
header_html_data
=
b64encode
(
header_embedded_html_data
),
header_html_data
=
b64encode
(
header_embedded_html_data
)
.
decode
()
,
header_spacing
=
10
,
footer_html_data
=
b64encode
(
footer_embedded_html_data
),
footer_html_data
=
b64encode
(
footer_embedded_html_data
)
.
decode
()
,
footer_spacing
=
3
)
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsSlideshow.py
View file @
732896c4
...
...
@@ -24,11 +24,12 @@ MAIN FILE: generate presentation in different output formats
# remote_content: convert legacy odp, sxi formats (not active)
import
re
import
six
from
Products.PythonScripts.standard
import
html_quote
from
base64
import
b64encode
blank
=
''
blank
=
b
''
flags
=
re
.
MULTILINE
|
re
.
DOTALL
|
re
.
IGNORECASE
details_separator
=
'</section><section class="ci-notes-continue"><section><h1>cont.</h1></section>'
pref
=
context
.
getPortalObject
().
portal_preferences
...
...
@@ -422,15 +423,16 @@ 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)
#embedded_html_data = doc.Base_convertHtmlToSingleFile(doc_slideshow_content, allow_script=True)
cover = doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
before_body_data_list = [
b64encode(
doc.Base_convertHtmlToSingleFile(doc_slideshow_cover, allow_script=True)
),
b64encode(
cover).decode(
),
]
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 = [
# b64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)),
# b64encode(doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True))
.decode()
,
#]
embedded_html_data = doc.Base_convertHtmlToSingleFile(doc_slideshow_notes, allow_script=True)
after_body_data_list = []
...
...
@@ -438,7 +440,6 @@ if doc_format == "pdf" or doc_format == "mhtml":
embedded_html_data = 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(
encoding="
utf8
",
orientation= "
portrait
" if doc_display_notes else "
landscape
",
...
...
@@ -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=b64encode(footer_embedded_html_data),
footer_html_data=b64encode(footer_embedded_html_data)
.decode()
,
footer_spacing=3
)
)
...
...
bt5/erp5_corporate_identity_test/SkinTemplateItem/portal_skins/erp5_corporate_identity_test/Base_generateCorporareIdentityTestReport.py
View file @
732896c4
import
json
return
[
'test report %s'
%
json
.
dumps
(
kw
)]
return
[
'test report %s'
%
json
.
dumps
(
kw
,
sort_keys
=
True
)]
bt5/erp5_corporate_identity_test/TestTemplateItem/portal_components/test.erp5.testCorporateIdentityMethod.py
View file @
732896c4
...
...
@@ -206,11 +206,11 @@ class TestCorporateIdentityMethod(ERP5TypeTestCase):
# it has no matter with/without follow up
doc_content
=
'<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&test=23"></a> </div>'
output
=
web_page_with_follow_up
.
WebPage_embedReportDocumentList
(
doc_content
)
self
.
assertEqual
(
output
,
'<div> test report {"
test": "23", "document_language": null, "format": null
} </div>'
)
self
.
assertEqual
(
output
,
'<div> test report {"
document_language": null, "format": null, "test": "23"
} </div>'
)
doc_content
=
'<div> <a href="sale_opportunity_module/template_test_embed_sale_opportunity?report=Base_generateCorporareIdentityTestReport&test=23"></a> </div>'
output
=
web_page_no_follow_up
.
WebPage_embedReportDocumentList
(
doc_content
)
self
.
assertEqual
(
output
,
'<div> test report {"
test": "23", "document_language": null, "format": null
} </div>'
)
self
.
assertEqual
(
output
,
'<div> test report {"
document_language": null, "format": null, "test": "23"
} </div>'
)
def
test_getTemplateProxyParameter_override_person
(
self
):
output_dict_list
=
self
.
test_person
.
Base_getTemplateProxyParameter
(
...
...
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