Commit c5da4558 authored by Sven Franck's avatar Sven Franck

erp5_corporate_identity: update to using preferences

parent 0c223280
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Default parameters (theme, css-files, js-files) for template configuration.</string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>corporate_identity_style_preferences</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>51.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Defaults</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Preference_viewCorporateIdentityStyle</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>List of 3 color swatches to be used in (Gantt) report generation.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_corporate_identity_template_css_color_swatch_property</string> </value>
</item>
<item>
<key> <string>multivalued</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -36,9 +36,7 @@
</item>
<item>
<key> <string>property_default</string> </key>
<value>
<none/>
</value>
<value> <string>python: []</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -10,7 +10,7 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
......@@ -36,9 +36,7 @@
</item>
<item>
<key> <string>property_default</string> </key>
<value>
<none/>
</value>
<value> <string>python: []</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_corporate_identity_template_site_registration_miibeian_id_property</string> </value>
<value> <string>preferred_corporate_identity_template_site_registration_id_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -20,7 +20,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_corporate_identity_template_site_registration_miibeian_url_property</string> </value>
<value> <string>preferred_corporate_identity_template_site_registration_url_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
......
......@@ -16,11 +16,12 @@ from Products.PythonScripts.standard import html_quote
# ------------------------------- Set Source ----------------------------------
source_logo_url = None
default_bank_account_relative_url=context.Base_getTemplateParameter("default_bank_account_relative_url")
source_organisation = None
pref = context.getPortalObject().portal_preferences
default_bank_account_relative_url=pref.getPreferredCorporateIdentityTemplateDefaultBankAccountRelativeUrl()
if source is None:
default_company_relative_url=context.Base_getTemplateParameter("default_company_relative_url")
default_company_relative_url=pref.getPreferredCorporateIdentityTemplateDefaultOrganisationRelativeUrl()
contributor_title_string = blank
source_person = None
source_person_list = []
......@@ -80,21 +81,23 @@ if default_bank_account_relative_url is not None:
source["bic"] = override_bank_account.get("bic")
source["iban"] = override_bank_account.get("iban")
# social media
# social media, used for website (WIP)
if source_organisation is not None:
source["social_media_handle_facebook"] = context.Base_getTemplateParameter('social_media_handle_facebook')
source["social_media_handle_twitter"] = context.Base_getTemplateParameter('social_media_handle_twitter')
source["social_media_handle_google"] = context.Base_getTemplateParameter('social_media_handle_google')
source["social_media_handle_facebook"] = pref.getPreferredCorporateIdentityTemplateSocialMediaHandleFacebook()
source["social_media_handle_twitter"] = pref.getPreferredCorporateIdentityTemplateSocialMediaHandleTwitter()
source["social_media_handle_google"] = pref.getPreferredCorporateIdentityTemplateSocialMediaHandleGoogle()
source["site_registration_url"] = pref.getPreferredCorporateIdentityTemplateSiteRegistrationUrl()
source["site_registration_id"] = pref.getPreferredCorporateIdentityTemplateSiteRegistrationId()
# social capital currency and registered court fallbacks
if source.get("social_capital_currency") is blank:
currency_short_title = None
currency_relative_url = context.Base_getTemplateParameter("default_source_company_capital_currency_relative_url")
currency_relative_url = pref.getPreferredCorporateIdentityTemplateDefaultCurrencyRelativeUrl()
if currency_relative_url:
currency_short_title = context.restrictedTraverse(currency_relative_url).getShortTitle()
source["social_capital_currency"] = currency_short_title or ""
if source.get("corporate_registration_code") is blank:
source["corporate_registration_code"] = context.Base_getTemplateParameter("default_source_registered_court")
source["corporate_registration_code"] = pref.getPreferredCorporateIdentityTemplateDefaultOrganisationRegisteredCourt()
# XXX images stored on organisation (as do images in skin folders)
if override_logo_reference:
......
"""
================================================================================
Return template parameters from portal-preferences (all calls go through here)
================================================================================
"""
# parameters:
# ------------------------------------------------------------------------------
# parameter Parameter to lookup
pref = context.getPortalObject().portal_preferences
if parameter == "default_company_relative_url":
return pref.getPreferredCorporateIdentityTemplateDefaultOrganisationRelativeUrl()
if parameter == "default_theme":
return pref.getPreferredCorporateIdentityTemplateDefaultTheme()
if parameter == "default_theme_css_url":
return pref.getPreferredCorporateIdentityTemplateThemeCssRelativeUrl()
if parameter == "fallback_image":
return pref.getPreferredCorporateIdentityTemplateFallbackLogoRelativeUrl()
<?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>parameter=None, source_data=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTemplateParameter</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -290,11 +290,19 @@ if pass_parameter is not None and pass_source_data is not None:
return populateBankDict([context.restrictedTraverse(pass_source_data)])
# ------------------ Theme Logo (Prefix + Theme) -----------------------------
# returns [{logo_dict}] used in themes
# returns [{logo_dict}] used in themes, needs to be language-agnostic, but not
# all contexts (eg sale-order) have language
# XXX improve
if pass_parameter == "logo":
try:
use_language = context.getLanguage() or "en"
except AttributeError:
use_language = "en"
return populateImageDict(portal_object.portal_catalog(
portal_type="Image",
language=context.getLanguage() or 'en',
language=use_language,
validation_state=validation_state,
reference=pass_source_data
))
......
......@@ -14,9 +14,7 @@ blank = ''
# XXX images in portal_skins folders don't convert with ?params. Only format
# is kept in Base_convertHtmlToSingleFile
pdf = ".pdf.css" if doc_format == "pdf" else ".css"
css = "default_theme_css_url"
font = "default_theme_font_css_url_list"
param = "?format=png"
pref = context.getPortalObject().portal_preferences
# theme content might not be visible on the default View
lookup_skin = blank
......@@ -28,32 +26,38 @@ theme_logo_dict = {}
theme_reference = None
theme = (
context.Base_getTemplateProxyParameter(parameter="theme", source_data=None) or
context.Base_getTemplateParameter("default_theme")
pref.getPreferredCorporateIdentityTemplateDefaultTheme()
)
if theme is not None:
theme = theme.lower()
theme_logo_prefix = context.Base_getTemplateParameter("default_logo_prefix")
theme_logo_prefix = pref.getPreferredCorporateIdentityTemplateDefaultLogoPrefix()
if theme_logo_prefix:
theme_reference = theme_logo_prefix + theme.capitalize()
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()
theme_dict["theme"] = theme
theme_dict["theme_logo_description"] = theme_logo_dict.get("description", blank)
theme_dict["theme_logo_url"] = context.Base_getTemplateParameter("fallback_image")
theme_dict["theme_logo_url"] = theme_logo_url
# 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:
theme_dict["theme_logo_url"] = theme_logo_dict.get("relative_url") + param
theme_dict["theme_logo_url"] = theme_logo_dict.get("relative_url") + "?format=png"
theme_dict["template_css_url"] = css_path + pdf
theme_dict["fallback_img_url"] = context.Base_getTemplateParameter("fallback_image") or blank
theme_dict["fallback_img_url"] = theme_logo_url or blank
theme_dict["theme_css_font_list"] = []
theme_font_list = context.Base_getTemplateParameter(font) or []
theme_font_list = pref.getPreferredCorporateIdentityTemplateDefaultThemeFontList() or []
for font in theme_font_list:
theme_dict["theme_css_font_list"].append(font + pdf)
theme_css_url = context.Base_getTemplateParameter(css)
theme_css_url = pref.getPreferredCorporateIdentityTemplateThemeCssRelativeUrl()
if theme_css_url:
theme_dict["theme_css_url"] = context.Base_getTemplateParameter(css) + lookup_skin
theme_dict["theme_css_url"] = theme_css_url + lookup_skin
else:
theme_dict["theme_css_url"] = blank
return theme_dict
......@@ -30,6 +30,7 @@ import re
from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
# -------------------------- Setup ---------------------------------------------
letter = context
......@@ -50,7 +51,7 @@ override_batch_mode = kw.get('batch_mode', None)
# -------------------------- Document Parameters ------------------------------
letter_portal_type = letter.getPortalType()
letter_relative_url = letter.getRelativeUrl()
letter_prefix = "Letter."
letter_prefix = pref.getPreferredCorporateIdentityTemplateLetterDocumentPrefix() or "Letter."
# letter can be Web Page or Event created in Ticket module
if letter_portal_type == "Web Page":
......
......@@ -39,12 +39,15 @@ from Products.PythonScripts.standard import html_quote
from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
# ------------------ HTML cleanup/converter methods ----------------------------
def translateText(snip):
return doc_localiser.erp5_ui.gettext(snip, lang=doc_language).encode('utf-8').strip()
# -------------------------- Setup ---------------------------------------------
doc = context
doc_prefix = pref.getPreferredCorporateIdentityTemplateReportDocumentPrefix() or "Report."
doc_download = None #XXX not yet implemented
doc_save = int(kw.get('document_save') or 0)
doc_display_header = int(kw.get('display_header') or 0)
......@@ -124,7 +127,7 @@ if doc_language is not None:
if doc_language is None:
doc_language = blank
if doc_reference == blank:
doc_reference = "Report." + doc_title.replace(" ", ".")
doc_reference = doc_prefix + doc_title.replace(" ", ".")
doc_full_reference = '-'.join([doc_reference, doc_version, doc_language])
doc_short_date = doc_modification_date.strftime('%Y-%m-%d')
......@@ -154,8 +157,8 @@ if doc_format == "html":
book_template_css_url=doc_theme.get("template_css_url"),
book_logo_url=doc.Base_setUrl(path=doc_source.get("enhanced_logo_url"), display=None),
book_logo_title=doc_source.get("theme_logo_description"),
book_report_css_list=doc.Base_getTemplateParameter("report_css_list") or [],
book_report_js_list=doc.Base_getTemplateParameter("report_js_list") or [],
book_report_css_list=pref.getPreferredCorporateIdentityTemplateReportCssList() or [],
book_report_js_list=pref.getPreferredCorporateIdentityTemplateReportJsList() or [],
book_short_title=doc_short_title,
book_reference=doc_reference,
book_revision=doc_revision,
......@@ -190,8 +193,8 @@ if doc_format == "pdf":
book_theme_css_font_list=doc_theme.get("theme_css_font_list"),
book_theme_css_url=doc_theme.get("theme_css_url"),
book_template_css_url=doc_theme.get("template_css_url"),
book_report_css_list=doc.Base_getTemplateParameter("report_css_list") or [],
book_report_js_list=doc.Base_getTemplateParameter("report_js_list") or [],
book_report_css_list=pref.getPreferredCorporateIdentityTemplateReportCssList() or [],
book_report_js_list=pref.getPreferredCorporateIdentityTemplateReportJsList() or [],
book_content=doc_content,
)
......
......@@ -38,6 +38,7 @@ from Products.PythonScripts.standard import html_quote
from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
# ------------------ HTML cleanup/converter methods ----------------------------
def translateText(snip):
......@@ -69,7 +70,7 @@ override_batch_mode = kw.get('batch_mode')
# -------------------------- Document Parameters ------------------------------
book_localiser = book.getPortalObject().Localizer
book_relative_url = book.getRelativeUrl()
book_prefix = "Book."
book_prefix = pref.getPreferredCorporateIdentityTemplateBookDocumentPrefix() or "Book."
book_rendering_fix = book.WebPage_getPdfOutputRenderingFix() or blank
book_content = book.getTextContent()
book_aggregate_list = []
......@@ -143,8 +144,8 @@ if book_include_linked_content:
# embed reports
if book_include_report_content:
book_report_css_list = book.Base_getTemplateParameter("report_css_list") or []
book_report_js_list = book.Base_getTemplateParameter("report_js_list") or []
book_report_css_list = pref.getPreferredCorporateIdentityTemplateReportCssList() or []
book_report_js_list = pref.getPreferredCorporateIdentityTemplateReportJsList() or []
book_content = book.WebPage_embedReportDocumentList(doc_content=book_content, doc_language=book_language, doc_format=book_format)
# table of links
......
......@@ -27,6 +27,7 @@ from Products.PythonScripts.standard import html_quote
from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
# ------------------ HTML cleanup/converter methods ----------------------------
def removeLegalesePlaceholders(content):
......@@ -36,7 +37,7 @@ def removeLegalesePlaceholders(content):
# -------------------------- Setup ---------------------------------------------
leaflet = context
leaflet_prefix = "Leaflet."
leaflet_prefix = pref.getPreferredCorporateIdentityTemplateLeafletDocumentPrefix() or "Leaflet."
leaflet_format = kw.get('format') or 'html'
leaflet_display_svg = kw.get('display_svg') or "png"
leaflet_download = int(kw.get('document_download') or 0)
......
......@@ -24,6 +24,7 @@ import re
from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
re_tag = re.compile(r'<[^>]+>')
# ------------------ HTML cleanup/converter methods ----------------------------
......@@ -38,7 +39,7 @@ def removeHardcodedAbout(my_content):
# -------------------------- Setup ---------------------------------------------
release = context
release_prefix = "Release."
release_prefix = pref.getPreferredCorporateIdentityTemplateReleaseDocumentPrefix() or "Release."
release_format = kw.get('format') or 'html'
release_display_about = int(kw.get('display_about') or 0)
release_display_svg = kw.get('display_svg') or "png"
......
......@@ -29,6 +29,7 @@ from base64 import b64encode
blank = ''
details_separator = '</section><section class="ci-notes-continue"><section><h1>cont.</h1></section>'
pref = context.getPortalObject().portal_preferences
# ------------------ HTML cleanup/converter methods ----------------------------
def getSlideList(my_content):
......@@ -148,7 +149,7 @@ def sortContent(my_page_list):
# -------------------------- Setup ---------------------------------------------
doc = context
doc_prefix = "Slideshow."
doc_prefix = pref.getPreferredCorporateIdentityTemplateSlideDocumentPrefix() or "Slideshow."
doc_converted_content = None
doc_format = kw.get('format') or 'html'
doc_display_notes = int(kw.get('display_note') or 0)
......
Preference | corporate_identity_style_preferences
Web Page | export_book
Web Page | export_leaflet
Web Page | export_letter
......
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