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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
7ce94186
Commit
7ce94186
authored
Aug 20, 2020
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_corporate_identity: make code more readable
parent
246d3c85
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
80 deletions
+78
-80
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getDestinationDict.py
..._skins/erp5_corporate_identity/Base_getDestinationDict.py
+10
-10
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getSourceDict.py
...ortal_skins/erp5_corporate_identity/Base_getSourceDict.py
+21
-18
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.py
...erp5_corporate_identity/Base_getTemplateProxyParameter.py
+37
-37
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getThemeDict.py
...portal_skins/erp5_corporate_identity/Base_getThemeDict.py
+10
-15
No files found.
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getDestinationDict.py
View file @
7ce94186
...
...
@@ -8,9 +8,6 @@ Create a destination dict for filling templates
# destination: Can be set if called from Event
# override_destination_person_title: Title of person to use
# override_destination_organisation_title: Title of organisation to use
blank
=
''
# ---------------------------- Set Destination --------------------------------
# destination => Web Page = follow-up Organisation or Person, Event
if
destination
is
None
:
...
...
@@ -21,21 +18,24 @@ if destination is None:
destination_uid
=
None
# destination person
if
override_destination_person_title
is
not
None
or
override_destination_person_title
==
blank
:
if
override_destination_person_title
:
destination_person_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"override_person"
,
source_data
=
override_destination_person_title
)
if
len
(
destination_person_list
)
==
0
:
if
not
destination_person_list
:
# follow up
destination_person_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"person"
,
source_data
=
None
)
if
len
(
destination_person_list
)
>
0
:
if
destination_person_list
:
destination_person
=
destination_person_list
[
0
]
# destination organisation
if
override_destination_organisation_title
is
not
None
or
override_destination_organisation_title
==
blank
:
if
override_destination_organisation_title
:
destination_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"override_organisation"
,
source_data
=
override_destination_organisation_title
)
if
len
(
destination_organisation_list
)
==
0
:
if
not
destination_organisation_list
:
#follow up value
destination_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"organisation"
,
source_data
=
None
)
if
len
(
destination_organisation_list
)
==
0
and
destination_person
is
not
None
:
if
not
destination_organisation_list
and
destination_person
:
# person 's Career Subordination or itself if no career subordination
destination_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
destination_person
.
get
(
"uid"
))
or
[]
if
len
(
destination_organisation_list
)
>
0
:
if
destination_organisation_list
:
destination_organisation
=
destination_organisation_list
[
0
]
destination
=
{}
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getSourceDict.py
View file @
7ce94186
...
...
@@ -15,7 +15,6 @@ blank = ''
from
Products.PythonScripts.standard
import
html_quote
# ------------------------------- Set Source ----------------------------------
source_logo_url
=
None
source_organisation
=
None
pref
=
context
.
getPortalObject
().
portal_preferences
default_bank_account_relative_url
=
pref
.
getPreferredCorporateIdentityTemplateDefaultBankAccountRelativeUrl
()
...
...
@@ -27,38 +26,42 @@ if source is None:
source_person_list
=
[]
source_organisation_list
=
[]
#
source person => override => contributor
=> source_decision
if
override_source_person_title
is
not
None
or
override_source_person_title
==
blank
:
#
override => author(contributor)
=> source_decision
if
override_source_person_title
:
source_person_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"override_person"
,
source_data
=
override_source_person_title
)
if
len
(
source_person_list
)
==
0
:
if
not
source_person_list
:
source_person_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"author"
,
source_data
=
None
)
or
[]
if
len
(
source_person_list
)
==
0
and
getattr
(
context
,
'getSourceDecisionValue'
,
None
)
is
not
None
:
if
not
source_person_list
and
getattr
(
context
,
'getSourceDecisionValue'
,
None
)
:
source_person_candidate
=
context
.
getSourceDecisionValue
()
if
source_person_candidate
and
source_person_candidate
.
getPortalType
()
==
"Person"
:
if
source_person_candidate
.
getPortalType
()
==
"Person"
:
source_person_list
=
[
source_person_candidate
]
if
len
(
source_person_list
)
>
0
:
if
source_person_list
:
source_person
=
source_person_list
[
0
]
contributor_title_string
=
', '
.
join
(
x
.
get
(
"name"
,
blank
)
for
x
in
source_person_list
)
# source organisation
# order: override => follow-up => default_organisation_uid => default_company_relative_url => source_person career subordinate => source decision
if
override_source_organisation_title
is
not
None
or
override_source_organisation_title
==
blank
:
# override
if
override_source_organisation_title
:
source_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"override_organisation"
,
source_data
=
override_source_organisation_title
)
if
len
(
source_organisation_list
)
==
0
:
if
not
source_organisation_list
:
# follow up
source_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"organisation"
,
source_data
=
None
)
or
[]
if
len
(
source_organisation_list
)
==
0
and
default_company_relative_url
:
if
not
source_organisation_list
and
default_company_relative_url
:
# default company
source_organisation_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"override_organisation_relative_url"
,
source_data
=
default_company_relative_url
)
or
[]
if
len
(
source_organisation_list
)
==
0
and
source_person
is
not
None
:
for
organisation_candidate
in
source_person_list
:
organisation_candidate_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
organisation_candidate
.
get
(
"uid"
))
or
[]
if
len
(
organisation_candidate_list
)
>
0
:
if
not
source_organisation_list
and
source_person_list
:
for
source_person
in
source_person_list
:
# person 's Career Subordination Value
organisation_candidate_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"source"
,
source_data
=
source_person
.
get
(
"uid"
))
or
[]
if
organisation_candidate_list
:
source_organisation_list
=
organisation_candidate_list
break
if
len
(
source_organisation_list
)
==
0
and
getattr
(
context
,
'getSourceDecisionValue'
,
None
)
is
not
None
:
if
not
source_organisation_list
and
getattr
(
context
,
'getSourceDecisionValue'
,
None
)
:
source_organisation_candidate
=
context
.
getSourceDecisionValue
()
if
source_organisation_candidate
and
source_organisation_candidate
.
getPortalType
()
==
"Organisation"
:
if
source_organisation_candidate
.
getPortalType
()
==
"Organisation"
:
source_organisation_list
=
[
source_organisation_candidate
]
if
len
(
source_organisation_list
)
>
0
:
if
source_organisation_list
:
source_organisation
=
source_organisation_list
[
0
]
source
=
{}
...
...
@@ -74,7 +77,7 @@ else:
# override specific bank account (no default to pick correct one if multiple exist)
if
default_bank_account_relative_url
is
not
None
:
override_bank_account_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"bank"
,
source_data
=
default_bank_account_relative_url
)
or
[]
if
len
(
override_bank_account_list
)
>
0
:
if
override_bank_account_list
:
override_bank_account
=
override_bank_account_list
[
0
]
source
[
"bank"
]
=
override_bank_account
.
get
(
"bank"
)
source
[
"bic"
]
=
override_bank_account
.
get
(
"bic"
)
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getTemplateProxyParameter.py
View file @
7ce94186
...
...
@@ -42,29 +42,29 @@ def populateProductDictFromCategoryList(my_category_list):
def
populateProductDict
(
my_product_list
):
result_list
=
[]
for
product
in
my_product_list
:
output_dict
=
{}
output_dict
[
"title"
]
=
product
.
getTitle
()
or
err
(
"product software"
)
result_list
.
append
(
output_dict
)
result_list
.
append
({
"title"
:
product
.
getTitle
()
or
err
(
"product software"
)
}
)
return
result_list
def
populateImageDict
(
my_image_list
):
result_list
=
[]
for
image
in
my_image_list
:
output_dict
=
{}
output_dict
[
"relative_url"
]
=
image
.
getRelativeUrl
()
output_dict
[
"reference"
]
=
image
.
getReference
()
or
err
(
"reference"
)
output_dict
[
"description"
]
=
image
.
getDescription
()
or
err
(
"description"
)
result_list
.
append
(
output_dict
)
result_list
.
append
({
"relative_url"
:
image
.
getRelativeUrl
(),
"reference"
:
image
.
getReference
()
or
err
(
"reference"
),
"description"
:
image
.
getDescription
()
or
err
(
"description"
)
}
)
return
result_list
def
populateBankDict
(
my_bank_list
):
result_list
=
[]
for
bank
in
my_bank_list
:
output_dict
=
{}
output_dict
[
"bank"
]
=
bank
.
getTitle
()
or
err
(
"bank account title"
)
output_dict
[
"iban"
]
=
bank
.
getIban
()
or
err
(
"iban"
)
output_dict
[
"bic"
]
=
bank
.
getBicCode
()
or
err
(
"bic"
)
result_list
.
append
(
output_dict
)
result_list
.
append
({
"bank"
:
bank
.
getTitle
()
or
err
(
"bank account title"
),
"iban"
:
bank
.
getIban
()
or
err
(
"iban"
),
"bic"
:
bank
.
getBicCode
()
or
err
(
"bic"
)
}
)
return
result_list
def
populatePersonDict
(
my_person_list
):
...
...
@@ -80,7 +80,7 @@ def populatePersonDict(my_person_list):
output_dict
[
"name"
]
=
person
.
getTitle
()
or
err
(
"title"
)
output_dict
[
"title"
]
=
person
.
getFunctionTitle
()
or
err
(
"function title"
)
output_dict
[
"uid"
]
=
person
.
getUid
()
or
err
(
"uid"
)
if
person
.
getDefaultAddress
()
is
not
None
:
if
person
_address
:
output_dict
[
"address"
]
=
person_address
.
getStreetAddress
()
or
err
(
"street address"
)
output_dict
[
"postal_code"
]
=
person_address
.
getZipCode
()
or
err
(
"postal code"
)
output_dict
[
"city"
]
=
person_address
.
getCity
()
or
err
(
"city"
)
...
...
@@ -88,17 +88,17 @@ def populatePersonDict(my_person_list):
output_dict
[
"address"
]
=
err
(
"street_adress"
)
output_dict
[
"postal_code"
]
=
err
(
"postal_code"
)
output_dict
[
"city"
]
=
err
(
"city"
)
if
person_region
is
not
None
:
if
person_region
:
output_dict
[
"country"
]
=
person_region
.
getTitle
()
or
err
(
"country"
)
output_dict
[
"codification"
]
=
person_region
.
getCodification
()
or
err
(
"country code"
)
else
:
output_dict
[
"country"
]
=
err
(
"country"
)
output_dict
[
"codification"
]
=
err
(
"country code"
)
if
person_default_telephone
is
not
None
:
if
person_default_telephone
:
output_dict
[
"phone"
]
=
person_default_telephone
.
getCoordinateText
()
or
err
(
"phone"
)
else
:
output_dict
[
"phone"
]
=
err
(
"phone"
)
if
person_default_mail
is
not
None
:
if
person_default_mail
:
output_dict
[
"email"
]
=
person_default_mail
.
getUrlString
()
or
err
(
"email"
)
else
:
output_dict
[
"email"
]
=
err
(
"email"
)
...
...
@@ -125,7 +125,7 @@ def populateOrganisationDict(my_organisation_list):
output_dict
[
"activity_code"
]
=
organisation
.
getActivityCode
()
or
err
(
"activitiy code"
)
#output_dict["logo_url"] = organisation.getDefaultImageAbsoluteUrl() or err("logo_url")
if
organisation_default_image
is
not
None
:
if
organisation_default_image
:
output_dict
[
"logo_url"
]
=
organisation_default_image
.
getRelativeUrl
()
output_dict
[
"logo_data_url"
]
=
'data:image/png;;base64,%s'
%
(
b64encode
(
organisation_default_image
.
convert
(
format
=
"png"
,
display
=
"thumbnail"
)[
1
])
...
...
@@ -140,7 +140,7 @@ def populateOrganisationDict(my_organisation_list):
output_dict
[
"vat"
]
=
organisation
.
getVatCode
()
or
err
(
"vat"
)
output_dict
[
"corporate_registration"
]
=
organisation
.
getCorporateRegistrationCode
()
or
err
(
"corporate_registration"
)
output_dict
[
"email"
]
=
organisation
.
getDefaultEmailText
()
or
err
(
"email"
)
if
organisation
.
getDefaultAddress
()
is
not
None
:
if
organisation
_address
:
output_dict
[
"address"
]
=
organisation_address
.
getStreetAddress
()
or
err
(
"street address"
)
output_dict
[
"postal_code"
]
=
organisation_address
.
getZipCode
()
or
err
(
"postal code"
)
output_dict
[
"city"
]
=
organisation_address
.
getCity
()
or
err
(
"city"
)
...
...
@@ -148,25 +148,26 @@ def populateOrganisationDict(my_organisation_list):
output_dict
[
"address"
]
=
err
(
"street address"
)
output_dict
[
"postal_code"
]
=
err
(
"postal code"
)
output_dict
[
"city"
]
=
err
(
"city"
)
if
organisation_region
is
not
None
:
if
organisation_region
:
output_dict
[
"country"
]
=
organisation_region
.
getTitle
()
or
err
(
"country"
)
output_dict
[
"codification"
]
=
organisation_region
.
getCodification
()
or
err
(
"country code"
)
else
:
output_dict
[
"country"
]
=
err
(
"country"
)
output_dict
[
"codification"
]
=
err
(
"country code"
)
if
organisation_phone
is
not
None
:
if
organisation_phone
:
output_dict
[
"phone"
]
=
organisation_phone
.
getCoordinateText
()
or
err
(
"phone"
)
else
:
output_dict
[
"phone"
]
=
err
(
"phone"
)
if
organisation_fax
is
not
None
:
if
organisation_fax
:
output_dict
[
"fax"
]
=
organisation_fax
.
getCoordinateText
()
or
err
(
"fax"
)
else
:
output_dict
[
"fax"
]
=
err
(
"fax"
)
if
len
(
organisation_link_list
)
==
1
:
#XXXX only 1 ?
output_dict
[
"website"
]
=
organisation_link_list
[
0
].
getUrlString
()
or
err
(
"Website"
)
else
:
output_dict
[
"website"
]
=
err
(
"web site"
)
if
len
(
organisation_bank_list
)
>
0
:
if
organisation_bank_list
:
output_dict
[
"bank"
]
=
organisation_bank_list
[
0
].
getTitle
()
or
err
(
"bank account title"
)
output_dict
[
"iban"
]
=
organisation_bank_list
[
0
].
getIban
()
or
err
(
"iban"
)
output_dict
[
"bic"
]
=
organisation_bank_list
[
0
].
getBicCode
()
or
err
(
"bic"
)
...
...
@@ -219,10 +220,12 @@ if pass_parameter is not None and pass_source_data is not None:
# ---------------------- Override Person -------------------------------------
# returns [{person_dict}]
if
pass_parameter
==
"override_person"
:
return
populatePersonDict
(
portal_object
.
portal_catalog
(
person_list
=
portal_object
.
portal_catalog
(
portal_type
=
"Person"
,
title
=
pass_source_data
))
)
person_list
=
[
x
for
x
in
person_list
if
x
.
getTitle
()
==
pass_source_data
]
return
populatePersonDict
(
person_list
)
# -------------------------- Contributor -------------------------------------
# returns [{person_dict}, {person_dict...}]
...
...
@@ -251,22 +254,19 @@ if pass_parameter is not None and pass_source_data is not None:
# -------------- Source/Destination (Person => Organisation) -----------------
# returns [{organisation_dict}]
if
pass_parameter
==
"source"
or
pass_parameter
==
"destination"
:
person_candidate_list
=
portal_object
.
person_module
.
searchFolder
(
uid
=
pass_source_data
)
organisation_candidate_list
=
portal_object
.
organisation_module
.
searchFolder
(
uid
=
pass_source_data
)
candidate
=
portal_object
.
portal_catalog
.
getResultValue
(
portal_type
=
(
'Person'
,
'Organisation'
),
uid
=
pass_source_data
)
if
len
(
person_candidate_list
)
>
0
:
for
c
in
person_candidate_list
:
organisation
=
c
.
getCareerSubordinationValue
()
if
candidate
:
if
candidate
.
getPortalType
()
==
'Person'
:
organisation
=
c
andidate
.
getCareerSubordinationValue
()
if
organisation
is
not
None
:
return
populateOrganisationDict
([
organisation
])
else
:
return
populatePersonDict
([
c
])
return
populatePersonDict
([
candidate
])
# events might pass organisation as sender/recipient
if
len
(
organisation_candidate_list
)
>
0
:
organisation_candidate_list
=
portal_object
.
organisation_module
.
searchFolder
(
uid
=
pass_source_data
)
for
o
in
organisation_candidate_list
:
return
populateOrganisationDict
([
o
])
return
populateOrganisationDict
([
candidate
])
return
[]
...
...
bt5/erp5_corporate_identity/SkinTemplateItem/portal_skins/erp5_corporate_identity/Base_getThemeDict.py
View file @
7ce94186
...
...
@@ -21,14 +21,11 @@ lookup_skin = blank
if
skin
:
lookup_skin
=
"?portal_skin="
+
skin
theme_logo_list
=
[]
theme_logo_dict
=
{}
theme_reference
=
None
theme
=
(
context
.
Base_getTemplateProxyParameter
(
parameter
=
"theme"
,
source_data
=
None
)
or
pref
.
getPreferredCorporateIdentityTemplateDefaultTheme
()
)
if
theme
is
not
None
:
theme
=
theme
.
lower
()
theme_logo_prefix
=
pref
.
getPreferredCorporateIdentityTemplateDefaultLogoPrefix
()
...
...
@@ -37,24 +34,22 @@ if theme is not None:
theme_logo_list
=
context
.
Base_getTemplateProxyParameter
(
parameter
=
"logo"
,
source_data
=
theme_reference
)
or
[]
if
len
(
theme_logo_list
)
>
0
:
theme_logo_dict
=
theme_logo_list
[
0
]
theme_dict
=
{}
theme_logo_url
=
pref
.
getPreferredCorporateIdentityTemplateFallbackLogoRelativeUrl
()
+
"?format=png"
theme_dict
[
"theme"
]
=
theme
theme_dict
[
"theme_logo_description"
]
=
theme_logo_dict
.
get
(
"description"
,
blank
)
theme_dict
[
"theme_logo_url"
]
=
theme_logo_url
theme_dict
=
{
"theme"
:
theme
,
"theme_logo_description"
:
theme_logo_dict
.
get
(
"description"
,
blank
)
}
fallback_logo_url
=
pref
.
getPreferredCorporateIdentityTemplateFallbackLogoRelativeUrl
()
+
"?format=png"
# if a theme logo is available, use it instead and add format=png (note, image
# conversion doesn't seem to work with files loaded from skins folders)
if
theme_logo_dict
.
get
(
"relative_url"
,
None
)
is
not
None
:
if
theme_logo_dict
.
get
(
"relative_url"
,
None
):
theme_dict
[
"theme_logo_url"
]
=
theme_logo_dict
.
get
(
"relative_url"
)
+
"?format=png"
else
:
theme_dict
[
"theme_logo_url"
]
=
fallback_logo_url
theme_dict
[
"template_css_url"
]
=
css_path
+
pdf
theme_dict
[
"fallback_img_url"
]
=
theme_logo_url
or
blank
theme_dict
[
"theme_css_font_list"
]
=
[]
theme_font_list
=
pref
.
getPreferredCorporateIdentityTemplateDefaultThemeFontList
()
or
[]
for
font
in
theme_font_list
:
theme_dict
[
"theme_css_font_list"
].
append
(
font
+
pdf
)
theme_dict
[
"fallback_img_url"
]
=
fallback_logo_url
or
blank
theme_dict
[
"theme_css_font_list"
]
=
[
x
+
pdf
for
x
in
pref
.
getPreferredCorporateIdentityTemplateDefaultThemeFontList
()
or
[]]
theme_css_url
=
pref
.
getPreferredCorporateIdentityTemplateThemeCssRelativeUrl
()
if
theme_css_url
:
theme_dict
[
"theme_css_url"
]
=
theme_css_url
+
lookup_skin
...
...
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