Browse Source

[IMP] report_py3o: Allows to interpret \n and \t in texts, cleans html tags too

pull/258/head
Omar 7 years ago
committed by Laurent Mignon (ACSONE)
parent
commit
838f94e3fc
  1. 11
      report_py3o/models/py3o_report.py

11
report_py3o/models/py3o_report.py

@ -9,6 +9,7 @@ import json
import logging import logging
import os import os
from contextlib import closing from contextlib import closing
from genshi.core import Markup
import pkg_resources import pkg_resources
import requests import requests
@ -64,12 +65,22 @@ def py3o_report_extender(report_xml_id=None):
return fct1 return fct1
def format_multiline_value(value):
if value:
return Markup(unicode(value).replace('<', '&lt;').replace('>', '&gt;').
replace('\n', '<text:line-break/>').
replace('\t', '<text:s/><text:s/><text:s/><text:s/>'))
return ""
@py3o_report_extender() @py3o_report_extender()
def defautl_extend(report_xml, localcontext): def defautl_extend(report_xml, localcontext):
# add the base64decode function to be able do decode binary fields into # add the base64decode function to be able do decode binary fields into
# the template # the template
localcontext['b64decode'] = b64decode localcontext['b64decode'] = b64decode
localcontext['report_xml'] = report_xml localcontext['report_xml'] = report_xml
localcontext['format_multiline_value'] = format_multiline_value
localcontext['html_sanitize'] = tools.html2plaintext
class Py3oReport(models.TransientModel): class Py3oReport(models.TransientModel):

Loading…
Cancel
Save