Commit 53b1792a authored by Sven Franck's avatar Sven Franck

erp5_corporate_identity: use portal-catalog for finding the magical missing image

parent 084ef66c
"""
================================================================================
Create a theme dict for filling templates
================================================================================
=====================================r===========================================
"""
# parameters:
# ------------------------------------------------------------------------------
......@@ -20,39 +20,31 @@ font = "default_theme_font_css_url_list"
param = "?format=png"
theme_logo_alt = "Default Logo"
theme_logo = None
theme_logo_url = None
theme_logo_relative_url = None
theme_logo_description = blank
theme_logo_list = []
theme_logo_dict = {}
theme_reference = None
theme = (
context.Base_getCustomTemplateProxyParameter("theme") or
context.Base_getCustomTemplateParameter("theme") or
context.Base_getCustomTemplateParameter("default_company_title")
)
if theme is not None:
logo_prefix = context.Base_getCustomTemplateParameter("default_logo_prefix")
theme = theme.lower()
if logo_prefix:
theme_logo_url = logo_prefix + theme.capitalize()
try:
theme_logo = context.restrictedTraverse(theme_logo_url)
theme_logo_relative_url = theme_logo_url
# XXX does not work in test-environment
#theme_logo_relative_url = theme_logo.getRelativeUrl()
theme_logo_description = theme_logo.getDescription()
except LookupError:
#__traceback_info__ = "theme_logo_url: %r" % (theme_logo_url,)
#raise Exception("%s and context: %r" % (theme_logo_url, context.restrictedTraverse(theme_logo_url),))
theme_logo = None
theme_logo_prefix = context.Base_getCustomTemplateParameter("default_logo_prefix")
if theme_logo_prefix:
theme_reference = theme_logo_prefix + theme.capitalize()
theme_logo_list = context.Base_getCustomTemplateProxyParameter("logo", theme_reference)
if len(theme_logo_list) > 0:
theme_logo_dict = theme_logo_list[0]
if theme is None:
theme = "default"
theme_dict = {}
theme_dict["theme"] = theme
theme_dict["theme_logo_description"] = theme_logo_description
theme_dict["theme_logo_url"] = (theme_logo_relative_url + param) if theme_logo_relative_url is not None else context.Base_getCustomTemplateParameter("fallback_image")
theme_dict["theme_logo_description"] = theme_logo_dict.get("description", blank)
theme_dict["theme_logo_url"] = context.Base_getCustomTemplateParameter("fallback_image")
if theme_logo_dict.get("relative_url", None) is not 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.Base_getCustomTemplateParameter("fallback_image") or blank
theme_dict["theme_css_font_list"] = context.Base_getCustomTemplateParameter(font) or []
......
......@@ -8,6 +8,8 @@ portal_type_valid_template_list = ["Web Site", "Web Section", "Web Page", "Lette
portal_type_valid_report_list = ["Project", "Sale Order", "Sale Opportunity"]
portal_type = context.getPortalType()
portal_object = context.getPortalObject()
validation_state = ('released', 'released_alive', 'published', 'published_alive',
'shared', 'shared_alive', 'public', 'validated')
if REQUEST is not None:
return None
......@@ -40,6 +42,16 @@ def populateProductDict(my_product_list):
result_list.append(output_dict)
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)
return result_list
def populateBankDict(my_bank_list):
result_list = []
for bank in my_bank_list:
......@@ -243,6 +255,15 @@ if pass_parameter is not None and pass_source_data is not None:
uid=pass_source_data
))
# ------------------ Theme Logo (Prefix + Theme) -----------------------------
# returns [{logo_dict}] used in themes
if pass_parameter == "logo":
return populateImageDict(portal_object.portal_catalog(
portal_type="Image",
validation_state=validation_state,
reference=pass_source_data
))
# ------------------------- Product (Website) --------------------------------
if pass_parameter == "product":
if pass_flag_site == True:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment