Commit 4922dd5b authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity: display as data url for organisation logo

See merge request nexedi/erp5!1233
parents 4f9569d2 413bec0c
......@@ -26,7 +26,6 @@ if source is None:
source_person = None
source_person_list = []
source_organisation_list = []
source_set = None
# source person => override => contributor => source_decision
if override_source_person_title is not None or override_source_person_title == blank:
......@@ -102,14 +101,16 @@ if source.get("corporate_registration_code") is blank:
# 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"
source_set = True
if source_logo_url is None:
else:
source_logo_url = source.get("logo_url", blank)
if source_logo_url != blank and source_set is None:
# XXX: test environment fails if url with parameters are supplied
source_logo_url = source_logo_url + "?format=png"
if source_logo_url == blank and theme_logo_url is not None:
source_logo_url = theme_logo_url
if source_logo_url != blank:
# XXX: test environment fails if url with parameters are supplied
source_logo_url = source_logo_url + "?format=png"
#logo_url is organisation default image, which is not accessible for anounymous
source["enhanced_logo_data_url"] = source.get("logo_data_url")
elif theme_logo_url is not None:
source_logo_url = theme_logo_url
source["enhanced_logo_url"] = source_logo_url
return source
......@@ -8,7 +8,7 @@ Return local parameters that require proxy role to access
# pass_parameter (portal-) type of data to fetch
# pass_source_data followup uid or context for retrieving info
# pass_flag_site whether called from a web site (no follow-up)
from base64 import b64encode
portal_type_valid_template_list = ["Web Site", "Web Section", "Web Page", "Letter"]
portal_type_valid_report_list = ["Project", "Sale Order", "Sale Opportunity", "Requirement Document", "Person"]
portal_type = context.getPortalType()
......@@ -127,6 +127,9 @@ def populateOrganisationDict(my_organisation_list):
#output_dict["logo_url"] = organisation.getDefaultImageAbsoluteUrl() or err("logo_url")
if organisation_default_image is not None:
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])
)
else:
output_dict["logo_url"] = err("logo_url")
......
......@@ -334,7 +334,7 @@ if doc_format == "html": #or doc_format == "mhtml":
doc_theme_css_font_list=doc_theme.get("theme_css_font_list"),
doc_theme_css_url=doc_theme.get("theme_css_url"),
doc_footer_url_description=doc_theme.get("theme_logo_description"),
doc_footer_url=doc.Base_setUrl(path=doc_source.get("enhanced_logo_url"), display=None),
doc_footer_url=doc_source.get("enhanced_logo_data_url", doc.Base_setUrl(path=doc_source.get("enhanced_logo_url"), display=None)),
doc_description=doc_description,
doc_creation_year=doc_creation_year,
doc_copyright=doc_source.get("organisation_title", blank),
......@@ -372,7 +372,7 @@ if doc_format == "pdf" or doc_format == "mhtml":
doc_theme_css_font_list=doc_theme.get("theme_css_font_list"),
doc_theme_css_url=doc_theme.get("theme_css_url"),
doc_footer_url_description=doc_theme.get("theme_logo_description"),
doc_footer_url=doc.Base_setUrl(path=doc_source.get("enhanced_logo_url"), display=None),
doc_footer_url=doc_source.get("enhanced_logo_data_url", doc.Base_setUrl(path=doc_source.get("enhanced_logo_url"), display=None)),
doc_description=doc_description,
doc_creation_year=doc_creation_year,
doc_copyright=doc_source.get("organisation_title", blank),
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>9fdf281f148030d11f0f3e72c1057e10</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/x-bmp</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Template.Test.Slideshow.Slide</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Screenshot generated from template_test_slideshow_input_001_en_pdf</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>595</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_test_slideshow_for_anonymous_en_bmp</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Image</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Test Slideshow Slide</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>842</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Organisation" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>group/template_test_group</string>
</tuple>
</value>
</item>
<item>
<key> <string>corporate_name</string> </key>
<value> <string>Template Test Organisation For Slide View</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Test Organisation for template testing</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_test_organisation_for_slide_view</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Organisation</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Test Organisation For Slide View</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Address" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>city</string> </key>
<value> <string>Test City</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_address</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Address</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>street_address</string> </key>
<value> <string>Test Drive 123</string> </value>
</item>
<item>
<key> <string>zip_code</string> </key>
<value> <string>12345</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Bank Account" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>comment</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>bank_account_holder_name</string> </key>
<value> <string>Template Test</string> </value>
</item>
<item>
<key> <string>bank_account_key</string> </key>
<value> <string>Foo</string> </value>
</item>
<item>
<key> <string>bank_account_number</string> </key>
<value> <string>0190 123 456</string> </value>
</item>
<item>
<key> <string>bank_code</string> </key>
<value> <string>12345</string> </value>
</item>
<item>
<key> <string>bank_country_code</string> </key>
<value> <string>12</string> </value>
</item>
<item>
<key> <string>branch</string> </key>
<value> <string>67890</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string>Template Test</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Template Test Bank Account</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_bank_account</string> </value>
</item>
<item>
<key> <string>overdraft_facility</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Bank Account</string> </value>
</item>
<item>
<key> <string>start_date</string> </key>
<value>
<object>
<klass>
<global id="1.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>946684800.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>stop_date</string> </key>
<value>
<object>
<klass> <reference id="1.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>4102358400.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Test Bank Account</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Email" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>coordinate_text</string> </key>
<value> <string>info@test-organisation.eu</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_email</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Email</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Telephone" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>coordinate_text</string> </key>
<value> <string>+123 456 789 0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>default_telephone</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Telephone</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<section class="master">
<h1>TOC</h1>
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</section>
<section class="chapter">
<h1>A</h1>
</section>
<section>
<h1>Test PNG as PNG</h1>
<img src="Template.Test.Image.Map?format=png" alt="" />
<ul>
<li>Content</li>
<li>Content</li>
<li>Content <a href="">with link</a></li>
<li>Content</li>
<li>Content</li>
</ul>
<details open="open">
This is a sample image in png format rendered as png.
</details>
</section>
<section>
<h1>Test PNG as SVG</h1>
<img src="Template.Test.Illustration.Reach?format=svg" type="image/svg+xml" alt="" />
<details open="open">
This is a sample image in svg format, not converted.
</details>
</section>
<section>
<h1>Test SVG as PNG</h1>
<img src="Template.Test.Illustration.Stack?format=png" alt="" />
<div style="font-size:10px;margin-top:0;text-align:center;">
<span>Photo by<a target="_blank" href="">Someone</a>&nbsp;/&nbsp;<a target="_blank" href="">Source</a></span>
</div>
<details open="open">
This is a sample image in svg format, rendered as png. With Attribution
</details>
</section>
<section>
<h1>Test HTML</h1>
<div style="padding: 1em;margin-bottom:16px;background-size:cover;background-image: url(); background-color: #ffffff; background-position: center">
<div style="padding:8px 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #33A8A8">A</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #434371">B</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #1C76BB">C</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #267B87">D</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #90C3D4">E</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #A9BCC2">F</span>
</div>
<div style="padding:0 8px 0 8px;">
<span style="color:#fff;text-align:left;display: block;font-weight:bold;margin:4px;padding:4px 4px 4px 1.5em;background-color: #000000">G</span>
</div>
</div>
<ul>
<li>Content</li>
</ul>
<details open="open">This is a sample graphic generated in HTML.</details>
</section>
<section class="master">
<h1>Test Side by Side and Multiple Details</h1>
<div>
<img src="Template.Test.Image.Office?format=png&amp;display=medium" type="image/png" alt="" />
</div>
<div>
<ul style="list-style:none;display:block;">
<li>Content</li>
<li>Content</li>
<li>Content</li>
<li>Content</li>
</ul>
</div>
<details open="open">
<p>This is a side by side content slide with multiple details subslides.</p>
</details>
<details>
This is the second detail subslide.
</details>
</section>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>follow_up/organisation_module/template_test_organisation_for_slide_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Template.Test.Organisation.Logo.In.Slide.View</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>template_test_organisation_logo_in_slide_view</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Template Test Organisation Logo In Slide View</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -252,7 +252,7 @@ class TestCorporateIdentityTemplateList(ERP5TypeTestCase):
getattr(test_page, kw.get("test_method")),
**kw
)
self.login()
image_source_pdf_doc.setData(pdf_data)
_, bmp = image_source_pdf_doc.convert("bmp", frame=kw.get("page_number"))
......@@ -402,6 +402,28 @@ class TestCorporateIdentityTemplateList(ERP5TypeTestCase):
)
@changeSkin('Slide')
def test_pdfSlideShowForAnonymous(self):
"""
Test for anonymous:
- Web Page as Slideshow
- without follow up
- without contributor
- export as pdf
"""
self.logout()
self.tic()
self.runPdfTestPattern(
"template_test_organisation_logo_in_slide_view",
"template_test_slideshow_for_anonymous_en_bmp",
"template_test_image_source_pdf",
**dict(
page_number=0,
use_skin="Slide",
test_method="WebPage_exportAsSlideshow",
format="pdf"
)
)
@changeSkin('Slide')
def test_pdfSlideshowNotes(self):
"""
Test:
......
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