Commit 7e00cdf8 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_corporate_identity: code improvement

1. set 0 as default value, otherwise leaflet_display_side will always be true
2. show message instead of crash
3. correct parameters
4. clean code
parent 65dc3807
......@@ -35,8 +35,7 @@ pref = context.getPortalObject().portal_preferences
# -------------------------- Setup ---------------------------------------------
letter = context
letter_format = kw.get('format') or 'html'
letter_display_source_adress = kw.get('letter_display_source_adress', None)
letter_display_head = int(kw.get('dislay_head') or 1)
letter_display_head = int(kw.get('display_head') or 0)
letter_display_svg = kw.get('display_svg') or 'png'
letter_download = int(kw.get('document_download') or 0)
letter_save = int(kw.get('document_save') or 0)
......@@ -155,7 +154,6 @@ if letter_format == "html":
letter_source_country_code=letter_source.get("codification", blank),
letter_source_country=letter_source.get("country", blank),
letter_content = letter_content,
letter_display_source_adress=letter_display_source_adress,
letter_display_sender_company_above_recipient = display_sender_company_above_recipient,
letter_source_vat=letter_source.get("vat", blank),
letter_source_corporate_registration=letter_source.get("corporate_registration", blank),
......@@ -221,7 +219,6 @@ if letter_format == "pdf":
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_display_sender_company_above_recipient = display_sender_company_above_recipient,
letter_content = letter_content
)
......
......@@ -16,18 +16,27 @@ Generates the complete letter
letter_template_css_url python: options.get('letter_template_css_url');
letter_timestamp python: options.get('letter_timestamp');
letter_source_company python: options.get('letter_source_company');
letter_source_company_corporate_name python: options.get('letter_source_company_corporate_name');
letter_source_company python: options.get('letter_source_company');
letter_source_company_capital python: options.get('letter_source_company_capital');
letter_source_company_capital_currency python: options.get('letter_source_company_capital_currency');
letter_source_registered_court python: options.get('letter_source_registered_court');
letter_source_ape_code python: options.get('letter_source_ape_code');
letter_source_address python: options.get('letter_source_address');
letter_source_country_code python: options.get('letter_source_country_code');
letter_source_postal_code python: options.get('letter_source_postal_code');
letter_source_city python: options.get('letter_source_city');
letter_source_country python: options.get('letter_source_country');
letter_source_vat python: options.get('letter_source_vat');
letter_source_corporate_registration python: options.get('letter_source_corporate_registration');
letter_source_phone python: options.get('letter_source_phone');
letter_source_fax python: options.get('letter_source_fax');
letter_source_mail python: options.get('letter_source_mail');
letter_source_website python: options.get('letter_source_website');
letter_source_bank python: options.get('letter_source_bank');
letter_source_bic python: options.get('letter_source_bic');
letter_source_iban python: options.get('letter_source_iban');
letter_destination_company python: options.get('letter_destination_company');
letter_destination_person python: options.get('letter_destination_person');
letter_destination_address python: options.get('letter_destination_address');
......@@ -38,23 +47,7 @@ Generates the complete letter
letter_destination_position_padding_left python: options.get('letter_destination_position_padding_left');
letter_content python: options.get('letter_content');
letter_display_source_address python: options.get('letter_display_source_address');
letter_display_sender_company_above_recipient python: options.get('letter_display_sender_company_above_recipient');
letter_source_company python: options.get('letter_source_company');
letter_source_address python: options.get('letter_source_address');
letter_source_postal_code python: options.get('letter_source_postal_code');
letter_source_city python: options.get('letter_source_city');
letter_source_country python: options.get('letter_source_country');
letter_source_vat python: options.get('letter_source_vat');
letter_source_corporate_registration python: options.get('letter_source_corporate_registration');
letter_source_phone python: options.get('letter_source_phone');
letter_source_fax python: options.get('letter_source_fax');
letter_source_mail python: options.get('letter_source_mail');
letter_source_website python: options.get('letter_source_website');
letter_source_bank python: options.get('letter_source_bank');
letter_source_bic python: options.get('letter_source_bic');
letter_source_iban python: options.get('letter_source_iban');">
letter_display_sender_company_above_recipient python: options.get('letter_display_sender_company_above_recipient');">
<!DOCTYPE html>
<html tal:attributes="class python: ''.join(['ci-', letter_theme, ' ci-', letter_language])">
<head>
......
......@@ -27,7 +27,6 @@ Generates the letter Content
letter_destination_postal_code python: options.get('letter_destination_postal_code');
letter_destination_city python: options.get('letter_destination_city');
letter_destination_country python: options.get('letter_destination_country');
letter_display_source_address python: options.get('letter_display_source_address');
letter_display_sender_company_above_recipient python: options.get('letter_display_sender_company_above_recipient');
letter_destination_position python: options.get('letter_destination_position');
letter_destination_position_padding_left python: options.get('letter_destination_position_padding_left');
......@@ -79,21 +78,7 @@ Generates the letter Content
<tal:block tal:condition="python: int(letter_display_head)">
<tr>
<td></td>
<td class="ci-letter-source">
<tal:block tal:condition="python: letter_display_source_address is not None">
<tal:block tal:condition="python: letter_source_company">
<span tal:content="letter_source_company"></span><span class="ci-letter-separator">-</span>
</tal:block>
<tal:block tal:condition="python: letter_source_address">
<span tal:content="letter_source_address"></span><span class="ci-letter-separator">-</span>
</tal:block>
<tal:block tal:condition="python: letter_source_country_code">
<span tal:content="letter_source_country_code"></span><span class="ci-letter-separator">-</span>
</tal:block>
<span tal:content="letter_source_postal_code"></span>&nbsp;
<span tal:content="letter_source_city"></span>
</tal:block>
</td>
<td class="ci-letter-source"></td>
<td></td>
</tr>
<tr>
......
......@@ -30,7 +30,6 @@ return context.Letter_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,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, format="pdf", portal_skin=None, batch_mode=False, display_source_address=None, display_svg=None, display_head=1 ,document_download=None, document_save=1, 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>
<value> <string>REQUEST=None, format="pdf", portal_skin=None, batch_mode=False, display_svg=None, display_head=1 ,document_download=None, document_save=1, 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>
......
......@@ -28,7 +28,6 @@ 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,
......
......@@ -50,7 +50,7 @@
</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,destination_position_in_letter=\'right\', display_sender_company_above_recipient=0,destination_position_padding_left=\'100px\',**kw</string> </value>
<value> <string>format=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,destination_position_in_letter=\'right\', display_sender_company_above_recipient=0,destination_position_padding_left=\'100px\',**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -78,10 +78,9 @@ if context.getPortalType() in ["Presentation"]:
# slideshow will contain <header>, <content>, <header>, <content>...
# so we need to go through it two-slides at a time to assemble
# slides
slide_iter = iter(slideshow)
for slide in slide_iter:
slide_1st = slide
slide_2nd = next(slide_iter)
for index in range(0, len(slideshow),2):
slide_1st = slideshow[index]
slide_2nd = slideshow[index+1]
# we don't know whether header is on first or second position
if '<h1' not in slide_1st[1]:
......@@ -97,4 +96,4 @@ if context.getPortalType() in ["Presentation"]:
output = output + section_start + go_1st + go_2nd + section_end
kw["remote_content"] = output
return context.WebPage_viewAsSlideshowWIP(*args, **kw)
return context.WebPage_viewAsSlideshow(*args, **kw)
......@@ -27,6 +27,7 @@ def digestCaption(my_caption, my_caption_title, my_count, my_shift):
if match_doubles.get(my_caption_title, None) is None:
match_doubles[my_caption_title] = my_count
caption_relevant_count = my_count
my_count += 1
else:
caption_relevant_count = match_doubles[my_caption_title]
caption_id = caption_abbreviation + "-" + str(caption_relevant_count)
......@@ -41,7 +42,6 @@ def digestCaption(my_caption, my_caption_title, my_count, my_shift):
my_shift
)
caption_list.append(caption_dict)
my_count = my_count + 1
return my_count
# XXX single quotes?
......
......@@ -12,22 +12,16 @@ import re
blank = ""
for link in re.findall('([^[]<a.*?</a>[^]])', doc_content or blank):
link_reference_list = re.findall('href=\"(.*?)\"', link)
if len(link_reference_list) == 0:
link_reference = re.findall("href=\'(.*?)\'", link)
if len(link_reference_list) == 0:
link_reference = None
else:
if link_reference_list:
link_reference = link_reference_list[0]
if link_reference.find("report=") > -1:
link_reference = None
# only internal references can be embedded
if link_reference is not None and link_reference.find("http") == -1:
try:
link_doc = context.restrictedTraverse(link_reference.split("?")[0])
doc_content = doc_content.replace(link, link_doc.asStrippedHTML())
except LookupError:
raise LookupError(link_reference)
if link_reference.find("report=") == -1:
# only internal references can be embedded
if link_reference.lower().find("http") == -1:
try:
link_doc = context.restrictedTraverse(link_reference.split("?")[0])
doc_content = doc_content.replace(link, link_doc.asStrippedHTML())
except LookupError:
raise LookupError(link_reference)
doc_content = doc_content.replace("${related_subject_list}", blank)
doc_content = doc_content.replace("${table_of_content", blank)
......
......@@ -13,45 +13,40 @@ import re
document = context
# backcompat
def getReportViaFancyName(my_report_name):
for follow_up in document_required_follow_up_list:
#report_name = follow_up.split("insertFollowUp").pop().split("Report")[0]
report_name = my_report_name.split("insertFollowUp").pop().split("Report")[0]
detail_name = "Detail" in report_name
coverage_name = "Coverage" in report_name
# extra curl: CostEffortReport requires format (base|detailed)
# backcompat, example: WebPage_insertFollowUpCostEffortReport
def getReportViaFancyName(my_report_name, follow_up):
#report_name = follow_up.split("insertFollowUp").pop().split("Report")[0]
report_name = my_report_name.split("insertFollowUp").pop().split("Report")[0]
detail_name = "Detail" in report_name
coverage_name = "Coverage" in report_name
# extra curl: CostEffortReport requires format (base|detailed)
if detail_name:
report_name = report_name.replace("Detail", "")
#method_name = ''.join(['Base_render', report_name, 'TextDocumentReportAsHtml'])
method_name = ''.join(['Base_generate', report_name, 'Report'])
method_call = getattr(follow_up, method_name)
if method_call is not None:
# extra curl: Coverage report requires parameter details (1|0)
if coverage_name:
return method_call(comment_visibility=True)[0].encode(encoding='UTF-8')
if detail_name:
report_name = report_name.replace("Detail", "")
#method_name = ''.join(['Base_render', report_name, 'TextDocumentReportAsHtml'])
method_name = ''.join(['Base_generate', report_name, 'Report'])
method_call = getattr(follow_up, method_name)
if method_call is not None:
# extra curl: Coverage report requires parameter details (1|0)
if coverage_name:
return method_call(comment_visibility=True)[0].encode(encoding='UTF-8')
elif detail_name:
return method_call(format='detailed',display_detail = 1)[0].encode(encoding='UTF-8')
else:
return method_call()[0].encode(encoding='UTF-8')
return method_call(format='detailed',display_detail = 1)[0].encode(encoding='UTF-8')
return method_call()[0].encode(encoding='UTF-8')
if (doc_content.find('${WebPage_')):
document_allowed_portal_type_list = ["Project", "Sale Opportunity", "Sale Order"]
if doc_content.find('${WebPage_') != -1:
document_required_follow_up_list = [x.getObject() for x in document.portal_catalog(
portal_type=document_allowed_portal_type_list,
portal_type=["Project", "Sale Opportunity", "Sale Order"],
follow_up_related_uid=document.getUid(),
limit=1
)]
substitution_list = re.findall(r'\${WebPage_(.*)}', doc_content)
for substitution_report in substitution_list:
if substitution_report == 'insertTableOfReferences':
continue
placeholder = ''.join(['${WebPage_', substitution_report, '}'])
substitution_content = getReportViaFancyName(substitution_report)
doc_content = doc_content.replace(placeholder, substitution_content)
if document_required_follow_up_list:
substitution_list = re.findall(r'\${WebPage_(.*)}', doc_content)
for substitution_report in substitution_list:
if substitution_report == 'insertTableOfReferences':
continue
substitution_content = getReportViaFancyName(substitution_report, document_required_follow_up_list[0])
if substitution_content:
doc_content = doc_content.replace('${WebPage_%s}' % substitution_report, substitution_content)
# new handler
# fetch reports same way as embedding documents = via links, like:
......@@ -60,41 +55,34 @@ if (doc_content.find('${WebPage_')):
# call it with the parameters provided
for link in re.findall('([^[]<a.*?</a>[^]])', doc_content):
link_reference = None
link_reference_list = re.findall('href=\"(.*?)\"', link)
if len(link_reference_list) == 0:
link_reference = re.findall("href=\'(.*?)\'", link)
if len(link_reference_list) == 0:
link_reference = None
if len(link_reference_list) > 0:
if link_reference_list:
link_reference = link_reference_list[0]
if link_reference is not None and link_reference.find("report=") > -1:
# url for report, check if report can be found.
report_name = None
link_split = link_reference.split("?")
if len(link_split) > 1:
link_relative_url = link_split[0]
link_param_list = link_split[1].replace("&amp;", "&").split("&")
link_param_dict = {}
link_param_dict["document_language"] = doc_language
link_param_dict["format"] = doc_format
for param in link_param_list:
param_key, param_value = param.split("=")
if param_key == "report":
report_name = param_value
else:
link_param_dict[param_key] = param_value
if link_reference is not None and link_reference.find("report=") > -1:
# url for report, check if report can be found.
report_name = None
link_split = link_reference.split("?")
if len(link_split) > 1:
link_relative_url = link_split[0]
link_param_list = link_split[1].replace("&amp;", "&").split("&")
link_param_dict = {}
link_param_dict["document_language"] = doc_language
link_param_dict["format"] = doc_format
for param in link_param_list:
param_key, param_value = param.split("=")
if param_key == "report":
report_name = param_value
else:
link_param_dict[param_key] = param_value
# XXX report must be callable directly and generate the full output
if report_name is not None:
target_context = document.restrictedTraverse(link_relative_url, None)
if target_context is not None:
target_caller = getattr(target_context, report_name, None)
if target_caller is not None:
substitution_content = target_caller(**link_param_dict)
# Note: switched to report returning a tuple with (content, header-title, header-subtitle)
doc_content = doc_content.replace(link, substitution_content[0].encode("utf-8").strip())
# XXX report must be callable directly and generate the full output
if report_name is not None:
target_context = document.restrictedTraverse(link_relative_url, None)
if target_context is not None:
target_caller = getattr(target_context, report_name, None)
if target_caller is not None:
substitution_content = target_caller(**link_param_dict)
# Note: switched to report returning a tuple with (content, header-title, header-subtitle)
doc_content = doc_content.replace(link, substitution_content[0].encode("utf-8").strip())
return doc_content
......@@ -28,7 +28,6 @@ return context.WebPage_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,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>format="html", display_source_address=None, display_head=1, 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, destination_position_in_letter = \'right\', display_sender_company_above_recipient=0, destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,**kw</string> </value>
<value> <string>format="html", display_head=1, 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, destination_position_in_letter = \'right\', display_sender_company_above_recipient=0, destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -42,7 +42,6 @@ if dialog_id is not None:
format=format,
display_head=display_head,
display_svg=display_svg,
display_source_address=display_source_address,
document_download=document_download,
document_save=document_save,
destination_position_in_letter = destination_position_in_letter,
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>override_source_organisation_title=None, display_source_address=None, display_svg=None,document_download=None, document_save=None, dialog_id=None, cancel_url=None, portal_skin=None,display_head=None, format=None, override_date=None, override_destination_person_title=None, override_source_person_title=None,override_destination_organisation_title=None, destination_position_in_letter = \'right\', display_sender_company_above_recipient=None,destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,*args,**kw</string> </value>
<value> <string>override_source_organisation_title=None, display_svg=None,document_download=None, document_save=None, dialog_id=None, cancel_url=None, portal_skin=None,display_head=None, format=None, override_date=None, override_destination_person_title=None, override_source_person_title=None,override_destination_organisation_title=None, destination_position_in_letter = \'right\', display_sender_company_above_recipient=None,destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,*args,**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -12,7 +12,6 @@ Upgrade image for the specific type of display
# img_svg_format display image as svg (default png/None)
import re
from zExceptions import NotFound
if img_string is None or img_string == "":
return img_string
......@@ -25,32 +24,26 @@ img_src = img_src[0]
if img_src.startswith('data:image/'):
return img_string
img_type = None
# START user ignoring guidelines:
validation_freebie = None
new_src = None
# Guideline: no relative links. we cover
if img_src.startswith("./"):
new_src = img_src.replace("./", "")
img_string = img_string.replace(img_src, new_src)
img_src = new_src
# Guideline: include format. we cover
img_src = new_src or img_src
if img_src.find("format=") == -1:
if img_src.find("?") == -1:
new_src = img_src + "?format="
else:
new_src = img_src + "&amp;format="
img_string = img_string.replace(img_src, new_src)
img_src = new_src
# Guideline: images must be stored locally, don't complain if your pdf breaks
img_src = new_src or img_src
if img_src.startswith("http"):
validation_freebie = True
if validation_freebie is None:
if not img_src.lower().startswith("http"):
#END user ignoring guidelines
if img_src[0] == '/':
img_src = img_src[1:]
......@@ -58,21 +51,20 @@ if validation_freebie is None:
# flag broken link until further notice
if img_obj is None:
raise NotFound('The following image could not be found in erp5 OR is not following guidelines for links (eg no ./ prefix): %s' % (img_src.split("?")[0]))
img_type = img_obj.getContentType()
return '<p style="color:red">The following image could not be found in erp5 OR is not following guidelines for links (eg no ./ prefix): <span style="font-weight:bold">%s</span></p>' % (img_src.split("?")[0])
# ensure alt attributes are set
if img_string.find('alt=') == -1:
img_string.replace ("src=", 'alt="%s" src=' % img_caption or img_obj.getTitle())
img_type = img_obj.getContentType()
# force svg display as svg or png
if img_type == "image/svg+xml":
if img_svg_format == "png" or img_svg_format is None:
if img_svg_format == "png":
img_string = img_string.replace('type="image/svg+xml"', '')
img_string = img_string.replace("type='image/svg+xml'", '')
img_string = img_string.replace('format=svg', 'format=png')
if img_svg_format == "svg":
elif img_svg_format == "svg":
img_string = img_string.replace('src=', 'type="image/svg+xml" src=')
img_string = img_string.replace('src=', "type='image/svg+xml' src=")
img_string = img_string.replace('format=png', 'format=svg')
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>img_string=None, img_wrap=None, img_svg_format=None, img_fullscreen_link=None, img_caption=None</string> </value>
<value> <string>img_string=None, img_wrap=None, img_svg_format="png", img_fullscreen_link=None, img_caption=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -40,10 +40,6 @@ from base64 import b64encode
blank = ''
pref = context.getPortalObject().portal_preferences
# ------------------ HTML cleanup/converter methods ----------------------------
def translateText(snip):
return book_localiser.erp5_ui.gettext(snip, lang=book_language).encode('UTF-8').strip()
# -------------------------- Setup ---------------------------------------------
book = context
book_format = kw.get('format') or 'html'
......@@ -51,7 +47,7 @@ book_download = int(kw.get('document_download') or 0)
book_save = int(kw.get('document_save') or 0)
book_display_svg = kw.get('display_svg') or 'png'
book_include_content_table = int(kw.get('include_content_table') or 1)
book_include_content_table = int(kw.get('include_content_table') or 0)
book_include_history_table = int(kw.get('include_history_table') or 0)
book_include_reference_table = int(kw.get('include_reference_table') or 0)
book_include_linked_content = int(kw.get('include_linked_content') or 0)
......@@ -69,7 +65,6 @@ override_logo_reference = kw.get('override_logo_reference')
override_batch_mode = kw.get('batch_mode')
# -------------------------- Document Parameters ------------------------------
book_localiser = book.getPortalObject().Localizer
book_relative_url = book.getRelativeUrl()
book_prefix = pref.getPreferredCorporateIdentityTemplateBookDocumentPrefix() or "Book."
book_rendering_fix = book.WebPage_getPdfOutputRenderingFix() or blank
......@@ -96,11 +91,12 @@ if override_batch_mode:
book_revision = "1"
book_short_date = book_modification_date.strftime('%Y-%m-%d')
if book_language and book_language != blank:
if book_language:
book.REQUEST['AcceptLanguage'].set(book_language, 10)
else:
book_language = blank
if book_reference is None:
if not book_reference:
book_reference = book_prefix + book_title.replace(" ", ".")
book_full_reference = '-'.join([book_reference, book_version, book_language])
......@@ -136,11 +132,11 @@ if book_include_history_table:
book_version_list = []
book_distribution_list = []
# old generate book
# old generate book, this embed link like <a href="Template.Test.Book.Embeddable.Document">This link should be embedded</a>
if book_include_linked_content:
book_content = book.WebPage_embedLinkedDocumentList(doc_content=book_content)
# embed reports
# embed reports, link like <a href="project_module/1234?report=bam>, which has report=
if book_include_report_content:
book_report_css_list = pref.getPreferredCorporateIdentityTemplateReportCssList() or []
book_report_js_list = pref.getPreferredCorporateIdentityTemplateReportJsList() or []
......@@ -153,19 +149,19 @@ if book_include_reference_table:
image_link_list = book.WebPage_createImageOverview(book_content)
for referenced_document in book_link_list.get("reference_list", []):
book_reference_list.append(referenced_document.get("item"))
book_content = book_content.replace(referenced_document.get("input"), referenced_document.get("output"))
book_content = book_content.replace(referenced_document.get("input"), referenced_document.get("output"),1)
for applicable_document in book_link_list.get("applicable_list", []):
book_applicable_document_list.append(applicable_document.get("item"))
book_content = book_content.replace(applicable_document.get("input"), applicable_document.get("output"))
book_content = book_content.replace(applicable_document.get("input"), applicable_document.get("output"),1)
for abbreviation in book_link_list.get("abbreviation_list", []):
book_abbreviation_list.append(abbreviation.get("item"))
book_content = book_content.replace(abbreviation.get("input"), abbreviation.get("output"))
book_content = book_content.replace(abbreviation.get("input"), abbreviation.get("output"),1)
for figure in image_link_list.get("figure_list", []):
book_image_list.append(figure.get("item"))
book_content = book_content.replace(figure.get("input"), figure.get("output"))
book_content = book_content.replace(figure.get("input"), figure.get("output"), 1)
for table in table_link_list.get("table_list", []):
book_table_list.append(table.get("item"))
book_content = book_content.replace(table.get("input"), table.get("output"))
book_content = book_content.replace(table.get("input"), table.get("output"), 1)
# in order for the reference tables to be in the table of content, they must
# be added beforehand to content
......@@ -193,6 +189,7 @@ if book_include_reference_table:
# book_content = book_content.replace(book_history_section_list[-1], (book_history_section_list[-1] + book_references.encode('UTF-8').strip()))
#else:
# book_content = book_content.replace("${WebPage_insertTableOfReferences}", book_references.encode('UTF-8').strip())
book_references = book.Base_unescape(book_references)
book_content = book_content.replace("${WebPage_insertTableOfReferences}", book_references.encode('UTF-8').strip())
else:
book_content = book_content.replace("${WebPage_insertTableOfReferences}", blank)
......@@ -200,7 +197,7 @@ else:
# table of content has to be created manually to run over everything that
# should be indexed in the toc
if book_include_content_table:
book_translated_toc_title = translateText("Table of Contents")
book_translated_toc_title = context.Base_translateString("Table of Contents", lang=book_language)
if book_format == "pdf":
book_table_of_content = book.WebPage_createBookXslTableOfContent(
book_toc_title=book_translated_toc_title,
......@@ -270,11 +267,10 @@ if book_format == "html" or book_format == "mhtml":
doc_html_file=book_output
)
if book_format == "mhtml":
return book.Base_convertHtmlToSingleFile(book_output, allow_script=True)
return book.Base_convertHtmlToSingleFile(book_output, allow_script=True)
# ============================= Format: pdf ====================================
if book_format == "pdf":
elif book_format == "pdf":
book_cover = book.WebPage_createBookCover(
book_theme=book_theme.get("theme"),
book_title=book_title,
......
......@@ -42,7 +42,7 @@ 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)
leaflet_save = int(kw.get('document_save') or 0)
leaflet_display_side = int(kw.get('display_side') or 1)
leaflet_display_side = int(kw.get('display_side') or 0)
override_leaflet_header_title = kw.get('override_leaflet_header_title')
override_source_person_title = kw.get('override_source_person_title', None)
......
......@@ -28,7 +28,6 @@ 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,
......
......@@ -50,7 +50,7 @@
</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,destination_position_in_letter = \'right\',display_sender_company_above_recipient=0,destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,**kw</string> </value>
<value> <string>format=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,destination_position_in_letter = \'right\',display_sender_company_above_recipient=0,destination_position_padding_left=\'100px\',letter_header_margin_to_top=26,**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -105,13 +105,8 @@ def removeLineBreaks(my_content):
def splitMultipleDetails(my_content):
for slide in getSlideDetailsList(my_content):
detail_list = getDetailsList(slide)
detail_list_len = len(detail_list)
if detail_list_len > 1:
counter = 0
for detail in detail_list:
counter += 1
if counter < (detail_list_len):
my_content = my_content.replace(detail, ''.join([detail, details_separator]))
for detail in detail_list[:-1]:
my_content = my_content.replace(detail, ''.join([detail, details_separator]))
return my_content
#def removeSlidesWithoutDetailsFromNotes(my_content):
......@@ -143,11 +138,12 @@ def removeEmptyDetails(my_content):
return content
def addLastSlide(my_last_slide):
# XXXX This condition is not accurate
if my_last_slide.count("<div") != 2:
last_slide_relative_url = pref.getPreferredCorporateIdentityTemplateSlideLastSlideRelativeUrl() or None
last_slide_relative_url = pref.getPreferredCorporateIdentityTemplateSlideLastSlideRelativeUrl()
if last_slide_relative_url:
# try:
last_slide = doc.restrictedTraverse(last_slide_relative_url) or None
last_slide = doc.restrictedTraverse(last_slide_relative_url)
if last_slide is not None:
return last_slide.getTextContent()
#except AttributeError:
......@@ -183,8 +179,6 @@ if doc_is_slideshow is None:
doc_upgraded_content = setH1AndH2AsSlideHeaders(doc_upgraded_content)
doc_upgraded_content = removeLineBreaks(doc_upgraded_content)
doc_content = blank
last_slide_content = blank
section_start = '<section>'
details_start = '<details open="open">'
details_end = '</details>'
......@@ -204,6 +198,7 @@ if doc_is_slideshow is None:
# fake_slide_list will be <h1>,<content>,<h1>,<content> so we need to go
# over two items at a time
doc_slide_iter = iter(fake_slide_list)
doc_content = blank
for x in doc_slide_iter:
slide_header = x
......@@ -323,8 +318,8 @@ if getDetails(doc_content) > -1:
# XXX split content above 1600 chars into multiple details tags?
doc_content = doc_content.replace(slide, details)
# ======================== Format: html/mhtml ==================================
if doc_format == "html": #or doc_format == "mhtml":
# ======================== Format: html ==================================
if doc_format == "html":
doc_output = doc.WebPage_createSlideshow(
doc_format=doc_format,
doc_theme=doc_theme.get("theme"),
......@@ -343,25 +338,21 @@ if doc_format == "html": #or doc_format == "mhtml":
doc_content=doc_content
)
if doc_format == "html":
return doc.Base_finishWebPageCreation(
doc_download=doc_download,
doc_save=doc_save,
doc_version=doc_version,
doc_title=doc_title,
doc_relative_url=doc_relative_url,
doc_aggregate_list=doc_aggregate_list,
doc_language=doc_language,
doc_modification_date=doc_modification_date,
doc_reference=doc_reference,
doc_full_reference=doc_full_reference,
doc_html_file=doc_output
)
if doc_format == "mhtml":
context.REQUEST.RESPONSE.setHeader("Content-Type", "text/html;")
return doc.Base_convertHtmlToSingleFile(doc_output, allow_script=True)
return doc.Base_finishWebPageCreation(
doc_download=doc_download,
doc_save=doc_save,
doc_version=doc_version,
doc_title=doc_title,
doc_relative_url=doc_relative_url,
doc_aggregate_list=doc_aggregate_list,
doc_language=doc_language,
doc_modification_date=doc_modification_date,
doc_reference=doc_reference,
doc_full_reference=doc_full_reference,
doc_html_file=doc_output
)
# ============================= Format: pdf ====================================
# ============================= Format: pdf/mhtml ====================================
if doc_format == "pdf" or doc_format == "mhtml":
doc_slideshow_footer = doc.WebPage_createSlideshowFooter(
doc_format=doc_format,
......@@ -390,20 +381,9 @@ if doc_format == "pdf" or doc_format == "mhtml":
doc_css=doc_css,
doc_orientation="ci-orientation-portrait" if doc_display_notes else "ci-corientation-landscape"
)
# outputting just the content requires to drop wrapping <divs> (reveal/slides)
# and add extra css to recreate the same layout. so a separate output=content
# instead of defaulting to None
# doc_slideshow_content = doc.WebPage_createSlideshowContent(
# doc_format=doc_format,
# doc_theme=doc_theme.get("theme"),
# doc_title=doc_title,
# doc_language=doc_language,
# doc_template_css_url=doc_theme.get("template_css_url"),
# doc_theme_css_font_list=doc_theme.get("theme_css_font_list"),
# doc_theme_css_url=doc_theme.get("theme_css_url"),
# doc_content=doc_content
#)
if doc_display_notes:
doc_slideshow_notes = doc.WebPage_createSlideshowNotes(
doc_format=doc_format,
......
......@@ -78,7 +78,6 @@
<string>portal_skin</string>
<string>display_head</string>
<string>letter_header_margin_to_top</string>
<string>display_source_address</string>
<string>display_sender_company_above_recipient</string>
<string>display_svg</string>
<string>document_save</string>
......
......@@ -301,7 +301,7 @@
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
python: \'<iframe width="100%%" height="500" style="background-color:#FFFFFF;box-sizing:border-box;-wekbit-box-sizing:border-box;" src="%s/WebPage_viewAsWeb?portal_skin=Letter&amp;override_source_person_title=%s&amp;override_source_organisation_title=%s&amp;override_destination_person_title=%s&amp;override_destination_organisation_title=%s&amp;display_head=%s&amp;override_date=%s&amp;display_source_address=%s&amp;display_svg=%s&amp;destination_position_in_letter=%s&amp;display_sender_company_above_recipient=%s&amp;destination_position_padding_left=%s" name="default_version"></iframe>\' % (context.absolute_url(), context.REQUEST.get("override_source_person_title", ""), context.REQUEST.get("override_source_organisation_title", ""), context.REQUEST.get("override_destination_person_title", ""), context.REQUEST.get("override_destination_organisation_title", ""), context.REQUEST.get("display_head", 1), context.REQUEST.get("override_date", ""), context.REQUEST.get("display_source_address", 0), context.REQUEST.get("display_svg", "png"), context.REQUEST.get("destination_position_in_letter", "right"), context.REQUEST.get("display_sender_company_above_recipient", 0), context.REQUEST.get(\'destination_position_padding_left\', \'100px\'))
python: \'<iframe width="100%%" height="500" style="background-color:#FFFFFF;box-sizing:border-box;-wekbit-box-sizing:border-box;" src="%s/WebPage_viewAsWeb?portal_skin=Letter&amp;override_source_person_title=%s&amp;override_source_organisation_title=%s&amp;override_destination_person_title=%s&amp;override_destination_organisation_title=%s&amp;display_head=%s&amp;override_date=%s&amp;display_svg=%s&amp;destination_position_in_letter=%s&amp;display_sender_company_above_recipient=%s&amp;destination_position_padding_left=%s" name="default_version"></iframe>\' % (context.absolute_url(), context.REQUEST.get("override_source_person_title", ""), context.REQUEST.get("override_source_organisation_title", ""), context.REQUEST.get("override_destination_person_title", ""), context.REQUEST.get("override_destination_organisation_title", ""), context.REQUEST.get("display_head", 1), context.REQUEST.get("override_date", ""), context.REQUEST.get("display_svg", "png"), context.REQUEST.get("destination_position_in_letter", "right"), context.REQUEST.get("display_sender_company_above_recipient", 0), context.REQUEST.get(\'destination_position_padding_left\', \'100px\'))
]]></string> </value>
</item>
......
<?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>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>display_source_address</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> <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>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> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Display sender address in address window.</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_checkbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Display Source Address</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -532,7 +532,7 @@ NOTE: logos will disappear in wkhtmltopdf if they go beyond the available space
.ci-book ul li,
.ci-book ol li {
padding-left: 16px;
text-indent: -24px;
/*text-indent: -24px;*/
}
.ci-book ul li:before {
content: "•";
......
......@@ -128,6 +128,7 @@ html{
font-size: small;
border-bottom: 1px solid black;
display: inline-block;
margin-left: -1mm;
}
/* === adress-right === */
......
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