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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
a927c92b
Commit
a927c92b
authored
Jan 11, 2018
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_corporate_identity: rename parameter getters and add letter preview
parent
71e32c0a
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
711 additions
and
319 deletions
+711
-319
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getCustomTemplateProxyParameter.py
...orporate_identity/Base_getCustomTemplateProxyParameter.py
+0
-14
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getDestinationDict.py
..._skins/erp5_corporate_identity/Base_getDestinationDict.py
+6
-6
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getSourceDict.py
...ortal_skins/erp5_corporate_identity/Base_getSourceDict.py
+18
-12
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateParameter.py
...kins/erp5_corporate_identity/Base_getTemplateParameter.py
+0
-0
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateParameter.xml
...ins/erp5_corporate_identity/Base_getTemplateParameter.xml
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.py
...erp5_corporate_identity/Base_getTemplateProxyParameter.py
+2
-2
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.xml
...rp5_corporate_identity/Base_getTemplateProxyParameter.xml
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getThemeDict.py
...portal_skins/erp5_corporate_identity/Base_getThemeDict.py
+9
-9
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
...portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
+279
-0
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.xml
...ortal_skins/erp5_corporate_identity/Base_viewAsLetter.xml
+2
-2
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
...portal_skins/erp5_corporate_identity/Base_viewAsReport.py
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewAsLetter.py
...rtal_skins/erp5_corporate_identity/Letter_viewAsLetter.py
+26
-264
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewAsLetter.xml
...tal_skins/erp5_corporate_identity/Letter_viewAsLetter.xml
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewPreview/content.xml
...ns/erp5_corporate_identity/Letter_viewPreview/content.xml
+145
-0
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewPreview/document_title.xml
..._corporate_identity/Letter_viewPreview/document_title.xml
+111
-0
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_exportAsLetter.py
...l_skins/erp5_corporate_identity/WebPage_exportAsLetter.py
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_printAsLetter.py
...al_skins/erp5_corporate_identity/WebPage_printAsLetter.py
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py
...al_skins/erp5_corporate_identity/WebPage_validateImage.py
+3
-3
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
...ortal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
+1
-1
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLetter.py
...tal_skins/erp5_corporate_identity/WebPage_viewAsLetter.py
+41
-0
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLetter.xml
...al_skins/erp5_corporate_identity/WebPage_viewAsLetter.xml
+62
-0
No files found.
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getCustomTemplateProxyParameter.py
deleted
100644 → 0
View file @
71e32c0a
"""
================================================================================
Lookup a (hardcoded) custom parameter (default image, css-path etc)
================================================================================
"""
# parameters:
# ------------------------------------------------------------------------------
# parameter Parameter to lookup
# override_data Portal Type or relative url passed along
customProxyHandler
=
getattr
(
context
,
"WebPage_getCustomProxyParameter"
,
None
)
if
customProxyHandler
!=
None
:
source_data
=
override_data
or
context
.
getUid
()
return
customProxyHandler
(
parameter
=
parameter
,
source_data
=
source_data
)
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getDestinationDict.py
View file @
a927c92b
...
...
@@ -22,19 +22,19 @@ if destination == None:
# destination person
if
override_destination_person_title
!=
None
or
override_destination_person_title
==
blank
:
destination_person_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"override_person"
,
override_destination_person_title
)
destination_person_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"override_person"
,
source_data
=
override_destination_person_title
)
if
len
(
destination_person_list
)
==
0
:
destination_person_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"person"
,
None
)
destination_person_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"person"
,
source_data
=
None
)
if
len
(
destination_person_list
)
>
0
:
destination_person
=
destination_person_list
[
0
]
# destination organisation
if
override_destination_organisation_title
!=
None
or
override_destination_organisation_title
==
blank
:
destination_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"override_organisation"
,
override_destination_organisation_title
)
destination_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"override_organisation"
,
source_data
=
override_destination_organisation_title
)
if
len
(
destination_organisation_list
)
==
0
:
destination_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"organisation"
,
None
)
destination_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"organisation"
,
source_data
=
None
)
if
len
(
destination_organisation_list
)
==
0
and
destination_person
!=
None
:
destination_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"source"
,
destination_person
.
get
(
"uid"
))
or
[]
destination_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
destination_person
.
get
(
"uid"
))
or
[]
if
len
(
destination_organisation_list
)
>
0
:
destination_organisation
=
destination_organisation_list
[
0
]
...
...
@@ -45,6 +45,6 @@ if destination == None:
# destination => event
else
:
destination_uid
=
context
.
restrictedTraverse
(
destination
).
getUid
()
destination
=
context
.
Base_get
CustomTemplateProxyParameter
(
"destination"
,
destination_uid
)[
0
]
destination
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"destination"
,
source_data
=
destination_uid
)[
0
]
return
destination
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getSourceDict.py
View file @
a927c92b
...
...
@@ -16,10 +16,10 @@ from Products.PythonScripts.standard import html_quote
# ------------------------------- Set Source ----------------------------------
source_logo_url
=
None
default_bank_account_uid
=
context
.
WebPage_getCustom
Parameter
(
"default_bank_account_uid"
)
default_bank_account_uid
=
context
.
Base_getTemplate
Parameter
(
"default_bank_account_uid"
)
if
source
==
None
:
default_company_title
=
context
.
WebPage_getCustom
Parameter
(
"default_company_title"
)
default_company_title
=
context
.
Base_getTemplate
Parameter
(
"default_company_title"
)
contributor_title_string
=
blank
source_person
=
None
source_person_list
=
[]
...
...
@@ -30,9 +30,9 @@ if source == None:
# source person
if
override_source_person_title
!=
None
or
override_source_person_title
==
blank
:
source_person_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"override_person"
,
override_source_person_title
)
source_person_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"override_person"
,
source_data
=
override_source_person_title
)
if
len
(
source_person_list
)
==
0
:
source_person_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"author"
,
None
)
or
[]
source_person_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"author"
,
source_data
=
None
)
or
[]
if
len
(
source_person_list
)
>
0
:
source_person
=
source_person_list
[
0
]
contributor_title_string
=
', '
.
join
(
x
.
get
(
"name"
,
blank
)
for
x
in
source_person_list
)
...
...
@@ -40,18 +40,18 @@ if source == None:
# source organisation
# order: override => follow-up => default_organisation_uid => default_company_title => source_person career subordinate
if
override_source_organisation_title
!=
None
or
override_source_organisation_title
==
blank
:
source_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"override_organisation"
,
override_source_organisation_title
)
source_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"override_organisation"
,
source_data
=
override_source_organisation_title
)
if
len
(
source_organisation_list
)
==
0
:
source_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"organisation"
)
source_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"organisation"
,
source_data
=
None
)
if
len
(
source_organisation_list
)
==
0
:
source_organisation_uid
=
context
.
WebPage_getCustom
Parameter
(
"default_source_organisation_uid"
)
source_organisation_uid
=
context
.
Base_getTemplate
Parameter
(
"default_source_organisation_uid"
)
if
source_organisation_uid
:
source_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"sender"
,
source_organisation_uid
)
or
[]
source_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"sender"
,
source_data
=
source_organisation_uid
)
or
[]
if
len
(
source_organisation_list
)
==
0
and
default_company_title
:
source_organisation_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"override_organisation"
,
default_company_title
)
or
[]
source_organisation_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"override_organisation"
,
source_data
=
default_company_title
)
or
[]
if
len
(
source_organisation_list
)
==
0
and
source_person
!=
None
:
for
organisation_candidate
in
source_person_list
:
organisation_candidate_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"source"
,
organisation_candidate
.
get
(
"uid"
))
or
[]
organisation_candidate_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
organisation_candidate
.
get
(
"uid"
))
or
[]
if
len
(
organisation_candidate_list
)
>
0
:
source_organisation_list
=
organisation_candidate_list
break
...
...
@@ -66,17 +66,23 @@ if source == None:
# source => event
else
:
source_uid
=
context
.
restrictedTraverse
(
source
).
getUid
()
source
=
context
.
Base_get
CustomTemplateProxyParameter
(
"source"
,
source_uid
)[
0
]
source
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
source_uid
)[
0
]
# override specific bank account (no default to pick correct one if multiple exist)
if
default_bank_account_uid
!=
None
:
override_bank_account_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"bank"
,
default_bank_account_uid
)
or
[]
override_bank_account_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"bank"
,
source_data
=
default_bank_account_uid
)
or
[]
if
len
(
override_bank_account_list
)
>
0
:
override_bank_account
=
override_bank_account_list
[
0
]
source
[
"bank"
]
=
override_bank_account
.
get
(
"bank"
)
source
[
"bic"
]
=
override_bank_account
.
get
(
"bic"
)
source
[
"iban"
]
=
override_bank_account
.
get
(
"iban"
)
# social capital currency and registered court fallbacks
if
source
.
get
(
"social_capital_currency"
)
is
blank
:
source
[
"social_capital_currency"
]
=
context
.
Base_getTemplateParameter
(
"default_source_company_capital_currency"
)
if
source
.
get
(
"corporate_registration_code"
)
is
blank
:
source
[
"corporate_registration_code"
]
=
context
.
Base_getTemplateParameter
(
"default_source_registered_court"
)
# XXX images stored on organisation (as do images in skin folders)
if
override_logo_reference
:
source_logo_url
=
html_quote
(
override_logo_reference
)
+
"?format=png"
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
WebPage_getCustom
Parameter.py
→
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
Base_getTemplate
Parameter.py
View file @
a927c92b
File moved
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
WebPage_getCustom
Parameter.xml
→
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
Base_getTemplate
Parameter.xml
View file @
a927c92b
...
...
@@ -54,7 +54,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebPage_getCustom
Parameter
</string>
</value>
<value>
<string>
Base_getTemplate
Parameter
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
WebPage_getCustom
ProxyParameter.py
→
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
Base_getTemplate
ProxyParameter.py
View file @
a927c92b
...
...
@@ -178,14 +178,14 @@ def getSubstringFromProduct(my_candidate, my_as_is):
return
software_title
.
split
(
software_match_string
)[
0
].
lower
()
def
callSelf
(
my_parameter
,
my_source_id
,
my_flag_site
):
return
context
.
WebPage_getCustom
ProxyParameter
(
return
context
.
Base_getTemplate
ProxyParameter
(
parameter
=
my_parameter
,
source_uid
=
my_source_id
,
flag_site
=
my_flag_site
)
pass_parameter
=
kw
.
get
(
"parameter"
,
None
)
pass_source_data
=
kw
.
get
(
"source_data"
,
None
)
pass_source_data
=
kw
.
get
(
"source_data"
,
None
)
or
context
.
getUid
()
pass_flag_site
=
kw
.
get
(
"flag_site"
,
None
)
if
pass_parameter
!=
None
and
pass_source_data
!=
None
:
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
WebPage_getCustom
ProxyParameter.xml
→
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/
Base_getTemplate
ProxyParameter.xml
View file @
a927c92b
...
...
@@ -62,7 +62,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebPage_getCustom
ProxyParameter
</string>
</value>
<value>
<string>
Base_getTemplate
ProxyParameter
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getThemeDict.py
View file @
a927c92b
...
...
@@ -22,16 +22,16 @@ theme_logo_list = []
theme_logo_dict
=
{}
theme_reference
=
None
theme
=
(
context
.
Base_get
CustomTemplateProxyParameter
(
"theme"
)
or
context
.
WebPage_getCustom
Parameter
(
"theme"
)
or
context
.
WebPage_getCustom
Parameter
(
"default_company_title"
)
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"theme"
,
source_data
=
None
)
or
context
.
Base_getTemplate
Parameter
(
"theme"
)
or
context
.
Base_getTemplate
Parameter
(
"default_company_title"
)
)
if
theme
!=
None
:
theme
=
theme
.
lower
()
theme_logo_prefix
=
context
.
WebPage_getCustom
Parameter
(
"default_logo_prefix"
)
theme_logo_prefix
=
context
.
Base_getTemplate
Parameter
(
"default_logo_prefix"
)
if
theme_logo_prefix
:
theme_reference
=
theme_logo_prefix
+
theme
.
capitalize
()
theme_logo_list
=
context
.
Base_get
CustomTemplateProxyParameter
(
"logo"
,
theme_reference
)
theme_logo_list
=
context
.
Base_get
TemplateProxyParameter
(
parameter
=
"logo"
,
source_data
=
theme_reference
)
if
len
(
theme_logo_list
)
>
0
:
theme_logo_dict
=
theme_logo_list
[
0
]
if
theme
==
None
:
...
...
@@ -40,11 +40,11 @@ if theme == None:
theme_dict
=
{}
theme_dict
[
"theme"
]
=
theme
theme_dict
[
"theme_logo_description"
]
=
theme_logo_dict
.
get
(
"description"
,
blank
)
theme_dict
[
"theme_logo_url"
]
=
context
.
WebPage_getCustom
Parameter
(
"fallback_image"
)
theme_dict
[
"theme_logo_url"
]
=
context
.
Base_getTemplate
Parameter
(
"fallback_image"
)
if
theme_logo_dict
.
get
(
"relative_url"
,
None
)
!=
None
:
theme_dict
[
"theme_logo_url"
]
=
theme_logo_dict
.
get
(
"relative_url"
)
+
param
theme_dict
[
"template_css_url"
]
=
css_path
+
pdf
+
".css"
theme_dict
[
"fallback_img_url"
]
=
context
.
WebPage_getCustom
Parameter
(
"fallback_image"
)
or
blank
theme_dict
[
"theme_css_font_list"
]
=
context
.
WebPage_getCustom
Parameter
(
font
)
or
[]
theme_dict
[
"theme_css_url"
]
=
context
.
WebPage_getCustomParameter
(
css
)
or
context
.
WebPage_getCustom
Parameter
(
css
)
or
blank
theme_dict
[
"fallback_img_url"
]
=
context
.
Base_getTemplate
Parameter
(
"fallback_image"
)
or
blank
theme_dict
[
"theme_css_font_list"
]
=
context
.
Base_getTemplate
Parameter
(
font
)
or
[]
theme_dict
[
"theme_css_url"
]
=
context
.
Base_getTemplateParameter
(
css
)
or
context
.
Base_getTemplate
Parameter
(
css
)
or
blank
return
theme_dict
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsLetter.py
0 → 100644
View file @
a927c92b
"""
================================================================================
MAIN FILE: generate letter in different output formats
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# kw-parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
# transformation: convert content into nothing*, book
# ------
# override_source_person: to use instead of the underlying document creator
# override_source_organisation: to use instead of document creator organisation
# override_destination_person: to use instead of event destination/null
# override_destination_organisation: to use instead of event destination/null
# override_date to use instead of current date
# override_batch_mode used for tests
# ------
# document_download: download file directly (default None)
# document_save: save file in document module (default None)
# ------
# display_head: display letter adress head (1)* or not (0)
# display_svg display images in svg or png*
# display_source_address display source adress in adress field
import
re
from
base64
import
b64encode
blank
=
''
# -------------------------- Setup ---------------------------------------------
letter
=
context
letter_format
=
kw
.
get
(
'format'
,
'html'
)
letter_display_source_adress
=
kw
.
get
(
'letter_display_source_adress'
,
None
)
letter_display_head
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'dislay_head'
,
1
))
letter_display_svg
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'display_svg'
,
'png'
))
letter_download
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'document_download'
,
None
))
letter_save
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'document_save'
,
None
))
override_source_person_title
=
kw
.
get
(
'override_source_person_title'
,
None
)
override_source_organisation_title
=
kw
.
get
(
"override_source_organisation_title"
,
None
)
override_destination_person_title
=
kw
.
get
(
"override_destination_person_title"
,
None
)
override_destination_organisation_title
=
kw
.
get
(
"override_destination_organisation_title"
,
None
)
override_date
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
"override_date"
,
None
))
override_batch_mode
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'batch_mode'
,
None
))
# -------------------------- Document Parameters ------------------------------
letter_portal_type
=
letter
.
getPortalType
()
letter_relative_url
=
letter
.
getRelativeUrl
()
letter_prefix
=
"Letter."
# letter can be Web Page or Event created in Ticket module
if
letter_portal_type
==
"Web Page"
:
letter_title
=
letter
.
getTitle
()
letter_modification_date
=
DateTime
(
override_date
)
if
override_date
else
letter
.
getCreationDate
()
letter_content
=
letter
.
getTextContent
()
letter_language
=
letter
.
Base_setToNone
(
param
=
letter
.
getLanguage
())
letter_aggregate_list
=
[]
letter_source
=
None
letter_destination
=
None
letter_reference
=
letter
.
getReference
()
letter_version
=
letter
.
getVersion
()
or
"001"
else
:
letter_format
=
'pdf'
letter_save
=
letter_save
or
True
letter_modification_date
=
letter
.
getStartDate
()
or
letter
.
getCreationDate
()
letter_title
=
letter
.
getTitle
()
letter_content
=
letter
.
getTextContent
()
letter_aggregate_list
=
letter
.
getAggregateList
()
letter_language
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'select_language'
))
letter_source
=
letter
.
getSource
()
letter_destination
=
letter
.
getDestination
()
# cut corner to retrieve path to css files
letter_version
=
"001"
letter_reference
=
letter
.
getReference
()
# overrides for tests
if
override_batch_mode
!=
None
:
letter_modification_date
=
DateTime
(
"1976-11-04"
)
if
letter_language
!=
None
:
#and letter_format == "pdf":
letter
.
REQUEST
[
'AcceptLanguage'
].
set
(
letter_language
,
10
)
if
letter_language
==
None
:
letter_language
=
blank
if
letter_reference
==
None
:
letter_reference
=
letter_prefix
+
letter_title
.
replace
(
" "
,
"."
)
letter_full_reference
=
'-'
.
join
([
letter_reference
,
letter_version
,
letter_language
])
# --------------------------- Layout Parameters --------------------------------
letter_theme
=
letter
.
Base_getThemeDict
(
doc_format
=
letter_format
,
css_path
=
"template_css/letter"
)
# --------------------------- Source/Destination -------------------------------
letter_source
=
letter
.
Base_getSourceDict
(
source
=
letter_source
,
override_source_person_title
=
override_source_person_title
,
override_source_organisation_title
=
override_source_organisation_title
,
override_logo_reference
=
None
,
theme_logo_url
=
letter_theme
.
get
(
"theme_logo_url"
,
None
)
)
letter_destination
=
letter
.
Base_getDestinationDict
(
destination
=
letter_destination
,
override_destination_person_title
=
override_destination_person_title
,
override_destination_organisation_title
=
override_destination_organisation_title
,
)
# ========================= TRANSFORMATION: book ===============================
# --------------------------- Content Upgrades ---------------------------------
for
image
in
re
.
findall
(
'(<img.*?/>)'
,
letter_content
):
letter_content
=
letter_content
.
replace
(
image
,
letter
.
WebPage_validateImage
(
img_string
=
image
,
img_svg_format
=
letter_display_svg
)
)
# ============================= Format: html ===================================
if
letter_format
==
"html"
:
letter_output
=
letter
.
Letter_createLetter
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_destination_company
=
letter_destination
.
get
(
"organisation_title"
,
blank
),
letter_destination_person
=
letter_destination
.
get
(
"name"
,
blank
),
letter_destination_address
=
letter_destination
.
get
(
"address"
,
blank
),
letter_destination_postal_code
=
letter_destination
.
get
(
"postal_code"
,
blank
),
letter_destination_city
=
letter_destination
.
get
(
"city"
,
blank
),
letter_destination_country
=
letter_destination
.
get
(
"country"
,
blank
),
letter_source_company
=
letter_source
.
get
(
"corporate_name"
,
letter_source
.
get
(
"organisation_title"
,
blank
)),
letter_source_company_corporate_name
=
letter_source
.
get
(
"corporate_name"
,
blank
),
letter_source_company_capital
=
letter_source
.
get
(
"social_capital"
,
blank
),
letter_source_company_capital_currency
=
letter_source
.
get
(
"social_capital_currency"
,
blank
),
letter_source_registered_court
=
letter_source
.
get
(
"registered_court"
,
blank
),
letter_source_ape_code
=
letter_source
.
get
(
"activity_code"
,
blank
),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country_code
=
letter_source
.
get
(
"codification"
,
blank
),
letter_content
=
letter_content
,
letter_display_source_adress
=
letter_display_source_adress
,
letter_source_vat
=
letter_source
.
get
(
"vat"
,
blank
),
letter_source_corporate_registration
=
letter_source
.
get
(
"corporate_registration"
,
blank
),
letter_source_phone
=
letter_source
.
get
(
"phone"
,
blank
),
letter_source_fax
=
letter_source
.
get
(
"fax"
,
blank
),
letter_source_mail
=
letter_source
.
get
(
"email"
,
blank
),
letter_source_website
=
letter_source
.
get
(
"website"
,
blank
),
letter_source_bank
=
letter_source
.
get
(
"bank"
,
blank
),
letter_source_bic
=
letter_source
.
get
(
"bic"
,
blank
),
letter_source_iban
=
letter_source
.
get
(
"iban"
,
blank
)
)
return
letter
.
Base_finishWebPageCreation
(
doc_download
=
letter_download
,
doc_save
=
letter_save
,
doc_version
=
letter_version
,
doc_title
=
letter_title
,
doc_relative_url
=
letter_relative_url
,
doc_aggregate_list
=
letter_aggregate_list
,
doc_language
=
letter_language
,
doc_modification_date
=
letter_modification_date
,
doc_reference
=
letter_reference
,
doc_full_reference
=
letter_full_reference
,
doc_html_file
=
letter_output
)
# ============================= Format: pdf ====================================
if
letter_format
==
"pdf"
:
letter_head
=
letter
.
Letter_createLetterHeader
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
)
)
letter_content
=
letter
.
Letter_createLetterContent
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_destination_company
=
letter_destination
.
get
(
"organisation_title"
,
blank
),
letter_destination_person
=
letter_destination
.
get
(
"name"
,
blank
),
letter_destination_address
=
letter_destination
.
get
(
"address"
,
blank
),
letter_destination_postal_code
=
letter_destination
.
get
(
"postal_code"
,
blank
),
letter_destination_city
=
letter_destination
.
get
(
"city"
,
blank
),
letter_destination_country
=
letter_destination
.
get
(
"country"
,
blank
),
letter_source_company
=
letter_source
.
get
(
"corporate_name"
,
letter_source
.
get
(
"organisation_title"
,
blank
)),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country_code
=
letter_source
.
get
(
"codification"
,
blank
),
letter_display_source_adress
=
letter_display_source_adress
,
letter_content
=
letter_content
)
letter_foot
=
letter
.
Letter_createLetterFooter
(
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_source_company
=
letter_source
.
get
(
"organisation_title"
,
blank
),
letter_source_company_corporate_name
=
letter_source
.
get
(
"corporate_name"
,
blank
),
letter_source_company_capital
=
letter_source
.
get
(
"social_capital"
,
blank
),
letter_source_company_capital_currency
=
letter_source
.
get
(
"social_capital_currency"
,
blank
),
letter_source_registered_court
=
letter_source
.
get
(
"registered_court"
,
blank
),
letter_source_ape_code
=
letter_source
.
get
(
"activity_code"
,
blank
),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country
=
letter_source
.
get
(
"country"
,
blank
),
letter_source_vat
=
letter_source
.
get
(
"vat"
,
blank
),
letter_source_corporate_registration
=
letter_source
.
get
(
"corporate_registration"
,
blank
),
letter_source_phone
=
letter_source
.
get
(
"phone"
,
blank
),
letter_source_fax
=
letter_source
.
get
(
"fax"
,
blank
),
letter_source_mail
=
letter_source
.
get
(
"email"
,
blank
),
letter_source_website
=
letter_source
.
get
(
"website"
,
blank
),
letter_source_bank
=
letter_source
.
get
(
"bank"
,
blank
),
letter_source_bic
=
letter_source
.
get
(
"bic"
,
blank
),
letter_source_iban
=
letter_source
.
get
(
"iban"
,
blank
),
)
# ================ encode and build cloudoo elements =========================
embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_content
,
allow_script
=
True
)
header_embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_head
,
allow_script
=
True
)
footer_embedded_html_data
=
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
=
26
,
margin_bottom
=
30
,
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
),
)
)
# return file for comparison in portal-component tests
if
override_batch_mode
!=
None
:
if
letter_portal_type
!=
"Web Page"
:
return
pdf_file
return
letter
.
WebPage_finishPdfCreation
(
doc_download
=
letter_download
,
doc_save
=
letter_save
,
doc_version
=
letter_version
,
doc_title
=
letter_title
,
doc_relative_url
=
letter_relative_url
,
doc_aggregate_list
=
letter_aggregate_list
,
doc_language
=
letter_language
,
doc_modification_date
=
letter_modification_date
,
doc_reference
=
letter_reference
,
doc_full_reference
=
letter_full_reference
,
doc_pdf_file
=
pdf_file
)
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_
getCustomTemplateProxyParame
ter.xml
→
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_
viewAsLet
ter.xml
View file @
a927c92b
...
...
@@ -50,11 +50,11 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
parameter=None, override_data=None
</string>
</value>
<value>
<string>
*args,**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_
getCustomTemplateProxyParame
ter
</string>
</value>
<value>
<string>
Base_
viewAsLet
ter
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_viewAsReport.py
View file @
a927c92b
...
...
@@ -59,7 +59,7 @@ doc_requirement_relative_url = kw.get('requirement_relative_url', None)
# -------------------------- Document Parameters ------------------------------
doc_localiser
=
doc
.
getPortalObject
().
Localizer
doc_relative_url
=
doc
.
getRelativeUrl
()
doc_rendering_fix
=
doc
.
WebPage_getCustom
Parameter
(
'wkhtmltopdf_rendering_fix'
)
or
blank
doc_rendering_fix
=
doc
.
Base_getTemplate
Parameter
(
'wkhtmltopdf_rendering_fix'
)
or
blank
doc_report
=
getattr
(
doc
,
doc_report_name
)
doc_aggregate_list
=
[]
doc_revision
=
"1"
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewAsLetter.py
View file @
a927c92b
"""
================================================================================
MAIN FILE: generate letter in different output formats
View a Letter in the defined output format
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
#
kw-parameters (*
default)
#
parameters (*
default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
# transformation: convert content into nothing*, book
# ------
# override_source_person: to use instead of the underlying document creator
# override_source_organisation: to use instead of document creator organisation
# override_destination_person: to use instead of event destination/null
# override_destination_organisation: to use instead of event destination/null
# override_date to use instead of current date
# override_batch_mode used for tests
# ------
# document_download: download file directly (default None)
# document_save: save file in document module (default None)
# ------
# display_head: display letter adress head (1)* or not (0)
# display_svg display images in svg or png*
# display_source_address display source adress in adress field
import
re
from
base64
import
b64encode
blank
=
''
# -------------------------- Setup ---------------------------------------------
letter
=
context
letter_format
=
kw
.
get
(
'format'
,
'html'
)
letter_display_source_adress
=
kw
.
get
(
'letter_display_source_adress'
,
None
)
letter_display_head
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'dislay_head'
,
1
))
letter_display_svg
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'display_svg'
,
'png'
))
letter_download
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'document_download'
,
None
))
letter_save
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'document_save'
,
None
))
# format: output format
# batch_mode: used for tests
override_source_person_title
=
kw
.
get
(
'override_source_person_title'
,
None
)
override_source_organisation_title
=
kw
.
get
(
"override_source_organisation_title"
,
None
)
override_destination_person_title
=
kw
.
get
(
"override_destination_person_title"
,
None
)
override_destination_organisation_title
=
kw
.
get
(
"override_destination_organisation_title"
,
None
)
override_date
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
"override_date"
,
None
))
override_batch_mode
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'batch_mode'
,
None
))
# -------------------------- Document Parameters ------------------------------
letter_portal_type
=
letter
.
getPortalType
()
letter_relative_url
=
letter
.
getRelativeUrl
()
letter_prefix
=
"Letter."
# letter can be Web Page or Event created in Ticket module
if
letter_portal_type
==
"Web Page"
:
letter_title
=
letter
.
getTitle
()
letter_modification_date
=
DateTime
(
override_date
)
if
override_date
else
letter
.
getCreationDate
()
letter_content
=
letter
.
getTextContent
()
letter_language
=
letter
.
Base_setToNone
(
param
=
letter
.
getLanguage
())
letter_aggregate_list
=
[]
letter_source
=
None
letter_destination
=
None
letter_reference
=
letter
.
getReference
()
letter_version
=
letter
.
getVersion
()
or
"001"
else
:
letter_format
=
'pdf'
letter_save
=
letter_save
or
True
letter_modification_date
=
letter
.
getStartDate
()
or
letter
.
getCreationDate
()
letter_title
=
letter
.
getTitle
()
letter_content
=
letter
.
getTextContent
()
letter_aggregate_list
=
letter
.
getAggregateList
()
letter_language
=
letter
.
Base_setToNone
(
param
=
kw
.
get
(
'select_language'
))
letter_source
=
letter
.
getSource
()
letter_destination
=
letter
.
getDestination
()
# cut corner to retrieve path to css files
letter_version
=
"001"
letter_reference
=
letter
.
getReference
()
# overrides for tests
if
override_batch_mode
!=
None
:
letter_modification_date
=
DateTime
(
"1976-11-04"
)
# display_source_address display source (!) adress in adress field or not*
# display_svg display images in svg or png*
# display_head display letter adress head (1)* or not (0)
if
letter_language
!=
None
:
#and letter_format == "pdf":
letter
.
REQUEST
[
'AcceptLanguage'
].
set
(
letter_language
,
10
)
if
letter_language
==
None
:
letter_language
=
blank
if
letter_reference
==
None
:
letter_reference
=
letter_prefix
+
letter_title
.
replace
(
" "
,
"."
)
letter_full_reference
=
'-'
.
join
([
letter_reference
,
letter_version
,
letter_language
])
# document_download: download file directly (default None)
# document_save: save file in document module (default None)
# --------------------------- Layout Parameters --------------------------------
letter_theme
=
letter
.
Base_getThemeDict
(
doc_format
=
letter_format
,
css_path
=
"template_css/letter"
)
# override_source_organisation_title: override event sender career subordinate
# override_source_person_title: override event sender title
# override_destination_organisation_title: override event recipient subordinate
# override_destination_person_title: overide event recipient
# override_date to use instead of current date
# --------------------------- Source/Destination -------------------------------
letter_source
=
letter
.
Base_getSourceDict
(
source
=
letter_source
,
override_source_person_title
=
override_source_person_title
,
return
context
.
Base_viewAsLetter
(
format
=
format
,
display_head
=
display_head
,
display_svg
=
display_svg
,
display_source_address
=
display_source_address
,
override_source_organisation_title
=
override_source_organisation_title
,
override_logo_reference
=
None
,
theme_logo_url
=
letter_theme
.
get
(
"theme_logo_url"
,
None
)
)
letter_destination
=
letter
.
Base_getDestinationDict
(
destination
=
letter_destination
,
override_destination_person_title
=
override_destination_person_title
,
override_source_person_title
=
override_source_person_title
,
override_destination_organisation_title
=
override_destination_organisation_title
,
override_destination_person_title
=
override_destination_person_title
,
override_date
=
override_date
,
document_save
=
document_save
,
document_download
=
document_download
,
batch_mode
=
batch_mode
,
**
kw
)
# ========================= TRANSFORMATION: book ===============================
# --------------------------- Content Upgrades ---------------------------------
for
image
in
re
.
findall
(
'(<img.*?/>)'
,
letter_content
):
letter_content
=
letter_content
.
replace
(
image
,
letter
.
WebPage_validateImage
(
img_string
=
image
,
img_svg_format
=
letter_display_svg
)
)
# ============================= Format: html ===================================
if
letter_format
==
"html"
:
letter_output
=
letter
.
Letter_createLetter
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_destination_company
=
letter_destination
.
get
(
"organisation_title"
,
blank
),
letter_destination_person
=
letter_destination
.
get
(
"name"
,
blank
),
letter_destination_address
=
letter_destination
.
get
(
"address"
,
blank
),
letter_destination_postal_code
=
letter_destination
.
get
(
"postal_code"
,
blank
),
letter_destination_city
=
letter_destination
.
get
(
"city"
,
blank
),
letter_destination_country
=
letter_destination
.
get
(
"country"
,
blank
),
letter_source_company
=
letter_source
.
get
(
"corporate_name"
,
letter_source
.
get
(
"organisation_title"
,
blank
)),
letter_source_company_corporate_name
=
letter_source
.
get
(
"corporate_name"
,
blank
),
letter_source_company_capital
=
letter_source
.
get
(
"social_capital"
,
blank
),
letter_source_company_capital_currency
=
letter_source
.
get
(
"social_capital_currency"
,
letter
.
WebPage_getCustomParameter
(
"default_source_company_capital_currency"
)),
letter_source_registered_court
=
letter_source
.
get
(
"registered_court"
,
letter
.
WebPage_getCustomParameter
(
"default_source_registered_court"
)),
letter_source_ape_code
=
letter_source
.
get
(
"activity_code"
,
blank
),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country_code
=
letter_source
.
get
(
"codification"
,
blank
),
letter_content
=
letter_content
,
letter_display_source_adress
=
letter_display_source_adress
,
letter_source_vat
=
letter_source
.
get
(
"vat"
,
blank
),
letter_source_corporate_registration
=
letter_source
.
get
(
"corporate_registration"
,
blank
),
letter_source_phone
=
letter_source
.
get
(
"phone"
,
blank
),
letter_source_fax
=
letter_source
.
get
(
"fax"
,
blank
),
letter_source_mail
=
letter_source
.
get
(
"email"
,
blank
),
letter_source_website
=
letter_source
.
get
(
"website"
,
blank
),
letter_source_bank
=
letter_source
.
get
(
"bank"
,
blank
),
letter_source_bic
=
letter_source
.
get
(
"bic"
,
blank
),
letter_source_iban
=
letter_source
.
get
(
"iban"
,
blank
)
)
return
letter
.
Base_finishWebPageCreation
(
doc_download
=
letter_download
,
doc_save
=
letter_save
,
doc_version
=
letter_version
,
doc_title
=
letter_title
,
doc_relative_url
=
letter_relative_url
,
doc_aggregate_list
=
letter_aggregate_list
,
doc_language
=
letter_language
,
doc_modification_date
=
letter_modification_date
,
doc_reference
=
letter_reference
,
doc_full_reference
=
letter_full_reference
,
doc_html_file
=
letter_output
)
# ============================= Format: pdf ====================================
if
letter_format
==
"pdf"
:
letter_head
=
letter
.
Letter_createLetterHeader
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
)
)
letter_content
=
letter
.
Letter_createLetterContent
(
letter_display_head
=
letter_display_head
,
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_theme_logo_url
=
letter
.
Base_setUrl
(
path
=
letter_source
.
get
(
"enhanced_logo_url"
),
display
=
None
),
letter_theme_logo_alt
=
letter_theme
.
get
(
"theme_logo_description"
),
letter_timestamp
=
letter_modification_date
.
strftime
(
'%Y-%m-%d'
),
letter_destination_company
=
letter_destination
.
get
(
"organisation_title"
,
blank
),
letter_destination_person
=
letter_destination
.
get
(
"name"
,
blank
),
letter_destination_address
=
letter_destination
.
get
(
"address"
,
blank
),
letter_destination_postal_code
=
letter_destination
.
get
(
"postal_code"
,
blank
),
letter_destination_city
=
letter_destination
.
get
(
"city"
,
blank
),
letter_destination_country
=
letter_destination
.
get
(
"country"
,
blank
),
letter_source_company
=
letter_source
.
get
(
"corporate_name"
,
letter_source
.
get
(
"organisation_title"
,
blank
)),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country_code
=
letter_source
.
get
(
"codification"
,
blank
),
letter_display_source_adress
=
letter_display_source_adress
,
letter_content
=
letter_content
)
letter_foot
=
letter
.
Letter_createLetterFooter
(
letter_theme
=
letter_theme
.
get
(
"theme"
),
letter_title
=
letter_title
,
letter_language
=
letter_language
,
letter_theme_css_font_list
=
letter_theme
.
get
(
"theme_css_font_list"
),
letter_theme_css_url
=
letter_theme
.
get
(
"theme_css_url"
),
letter_template_css_url
=
letter_theme
.
get
(
"template_css_url"
),
letter_source_company
=
letter_source
.
get
(
"organisation_title"
,
blank
),
letter_source_company_corporate_name
=
letter_source
.
get
(
"corporate_name"
,
blank
),
letter_source_company_capital
=
letter_source
.
get
(
"social_capital"
,
blank
),
letter_source_company_capital_currency
=
letter_source
.
get
(
"social_capital_currency"
,
letter
.
WebPage_getCustomParameter
(
"default_source_company_capital_currency"
)),
letter_source_registered_court
=
letter_source
.
get
(
"registered_court"
,
letter
.
WebPage_getCustomParameter
(
"default_source_registered_court"
)),
letter_source_ape_code
=
letter_source
.
get
(
"activity_code"
,
blank
),
letter_source_address
=
letter_source
.
get
(
"address"
,
blank
),
letter_source_postal_code
=
letter_source
.
get
(
"postal_code"
,
blank
),
letter_source_city
=
letter_source
.
get
(
"city"
,
blank
),
letter_source_country
=
letter_source
.
get
(
"country"
,
blank
),
letter_source_vat
=
letter_source
.
get
(
"vat"
,
blank
),
letter_source_corporate_registration
=
letter_source
.
get
(
"corporate_registration"
,
blank
),
letter_source_phone
=
letter_source
.
get
(
"phone"
,
blank
),
letter_source_fax
=
letter_source
.
get
(
"fax"
,
blank
),
letter_source_mail
=
letter_source
.
get
(
"email"
,
blank
),
letter_source_website
=
letter_source
.
get
(
"website"
,
blank
),
letter_source_bank
=
letter_source
.
get
(
"bank"
,
blank
),
letter_source_bic
=
letter_source
.
get
(
"bic"
,
blank
),
letter_source_iban
=
letter_source
.
get
(
"iban"
,
blank
),
)
# ================ encode and build cloudoo elements =========================
embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_content
,
allow_script
=
True
)
header_embedded_html_data
=
letter
.
Base_convertHtmlToSingleFile
(
letter_head
,
allow_script
=
True
)
footer_embedded_html_data
=
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
=
26
,
margin_bottom
=
30
,
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
),
)
)
# return file for comparison in portal-component tests
if
override_batch_mode
!=
None
:
if
letter_portal_type
!=
"Web Page"
:
return
pdf_file
return
letter
.
WebPage_finishPdfCreation
(
doc_download
=
letter_download
,
doc_save
=
letter_save
,
doc_version
=
letter_version
,
doc_title
=
letter_title
,
doc_relative_url
=
letter_relative_url
,
doc_aggregate_list
=
letter_aggregate_list
,
doc_language
=
letter_language
,
doc_modification_date
=
letter_modification_date
,
doc_reference
=
letter_reference
,
doc_full_reference
=
letter_full_reference
,
doc_pdf_file
=
pdf_file
)
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewAsLetter.xml
View file @
a927c92b
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
*args
,**kw
</string>
</value>
<value>
<string>
format=None, display_source_address=None, display_head=None, display_svg=None, batch_mode=False, document_download=None, document_save=None, override_source_organisation_title=None,override_source_person_title=None,override_destination_organisation_title=None,override_destination_person_title=None,override_date=None
,**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewPreview/content.xml
0 → 100644
View file @
a927c92b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
default
</string>
<string>
description
</string>
<string>
gadget_url
</string>
<string>
title
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
content
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
gadget_url
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_iframe_gadget_field
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
gadget_url
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Content
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: context.Base_getRelevantContext(context_url=context.getRelativeUrl()).getData().encode("base64")
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: field.restrictedTraverse(\'pdf_js/pdfjs.gadget.html\').absolute_url() + "?auto_focus=1"
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Letter_viewPreview/document_title.xml
0 → 100644
View file @
a927c92b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
css_class
</string>
<string>
description
</string>
<string>
display_width
</string>
<string>
editable
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
document_title
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
css_class
</string>
</key>
<value>
<string>
headline
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
The title is display as main content title and page title.
</string>
</value>
</item>
<item>
<key>
<string>
display_width
</string>
</key>
<value>
<int>
40
</int>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_event_title
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewCRMFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string>
Click to edit the target
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_exportAsLetter.py
View file @
a927c92b
...
...
@@ -25,7 +25,7 @@ Export this web page as letter in specified format
# override_destination_person_title: overide event recipient
# override_date to use instead of current date
return
context
.
Letter
_viewAsLetter
(
return
context
.
WebPage
_viewAsLetter
(
format
=
format
,
display_head
=
display_head
,
display_svg
=
display_svg
,
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_printAsLetter.py
View file @
a927c92b
...
...
@@ -24,7 +24,7 @@ Print letter in any of the supported formats
# override_destination_person_title: overide event recipient
# override_date to use instead of current date
return
context
.
Letter
_viewAsLetter
(
return
context
.
WebPage
_viewAsLetter
(
format
=
format
,
display_head
=
display_head
,
display_svg
=
display_svg
,
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_validateImage.py
View file @
a927c92b
...
...
@@ -12,17 +12,17 @@ Upgrade image for the specific type of display
# img_svg_format display image as svg (default png/None)
import
re
from
OFS.Traversable
import
NotFound
from
zExceptions
import
NotFound
if
img_string
==
None
or
img_string
==
""
:
return
img_string
img_src
=
re
.
findall
(
"src=['
\
"
](.*?)['
\
"
]"
,
img_string
)[
0
]
img_obj
=
context
.
restrictedTraverse
(
img_src
.
split
(
"?"
)[
0
])
img_obj
=
context
.
restrictedTraverse
(
img_src
.
split
(
"?"
)[
0
]
,
None
)
img_type
=
img_obj
.
getContentType
()
# flag broken link until further notice
if
img_obj
is
None
:
if
img_obj
==
None
:
raise
NotFound
(
'The following image could not be found in erp5: %s'
%
(
img_src
.
split
(
"?"
)[
0
]))
# ensure alt attributes are set
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsBook.py
View file @
a927c92b
...
...
@@ -75,7 +75,7 @@ override_batch_mode = book.Base_setToNone(param=kw.get('batch_mode', None))
book_localiser
=
book
.
getPortalObject
().
Localizer
book_relative_url
=
book
.
getRelativeUrl
()
book_prefix
=
"Book."
book_rendering_fix
=
book
.
WebPage_getCustom
Parameter
(
'wkhtmltopdf_rendering_fix'
)
or
blank
book_rendering_fix
=
book
.
Base_getTemplate
Parameter
(
'wkhtmltopdf_rendering_fix'
)
or
blank
book_content
=
book
.
getTextContent
()
book_aggregate_list
=
[]
book_revision
=
book
.
getRevision
()
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLetter.py
0 → 100644
View file @
a927c92b
"""
================================================================================
View a WebPage as Letter in the defined output format
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (*default)
# ------------------------------------------------------------------------------
# format: output format
# batch_mode: used for tests
# display_source_address display source (!) adress in adress field or not*
# display_svg display images in svg or png*
# display_head display letter adress head (1)* or not (0)
# document_download: download file directly (default None)
# document_save: save file in document module (default None)
# override_source_organisation_title: override event sender career subordinate
# override_source_person_title: override event sender title
# override_destination_organisation_title: override event recipient subordinate
# override_destination_person_title: overide event recipient
# override_date to use instead of current date
return
context
.
Base_viewAsLetter
(
format
=
format
,
display_head
=
display_head
,
display_svg
=
display_svg
,
display_source_address
=
display_source_address
,
override_source_organisation_title
=
override_source_organisation_title
,
override_source_person_title
=
override_source_person_title
,
override_destination_organisation_title
=
override_destination_organisation_title
,
override_destination_person_title
=
override_destination_person_title
,
override_date
=
override_date
,
document_save
=
document_save
,
document_download
=
document_download
,
batch_mode
=
batch_mode
,
**
kw
)
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/WebPage_viewAsLetter.xml
0 → 100644
View file @
a927c92b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
format=None, display_source_address=None, display_head=None, display_svg=None, batch_mode=False, document_download=None, document_save=None, override_source_organisation_title=None,override_source_person_title=None,override_destination_organisation_title=None,override_destination_person_title=None,override_date=None,**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebPage_viewAsLetter
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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