Commit c028a436 authored by Nicolas Delaby's avatar Nicolas Delaby

Propagate render_prefix to be able to display OOoChart in ReportSection

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24621 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a42fc74e
...@@ -71,7 +71,7 @@ def Field_render(self, value=None, REQUEST=None, key=None, render_prefix=None): ...@@ -71,7 +71,7 @@ def Field_render(self, value=None, REQUEST=None, key=None, render_prefix=None):
if value and REQUEST are both None, the 'default' property of if value and REQUEST are both None, the 'default' property of
the field will be used for the value. the field will be used for the value.
""" """
return self._render_helper(self.generate_field_key(key=key), value, REQUEST) return self._render_helper(self.generate_field_key(key=key), value, REQUEST, render_prefix)
def Field_render_view(self, value=None, REQUEST=None, render_prefix=None): def Field_render_view(self, value=None, REQUEST=None, render_prefix=None):
"""Render value to be viewed. """Render value to be viewed.
...@@ -84,7 +84,7 @@ def Field_render_sub_field(self, id, value=None, REQUEST=None, key=None, render_ ...@@ -84,7 +84,7 @@ def Field_render_sub_field(self, id, value=None, REQUEST=None, key=None, render_
Added key parameter for ERP5 in order to be compatible with listbox/matrixbox Added key parameter for ERP5 in order to be compatible with listbox/matrixbox
""" """
return self.sub_form.get_field(id)._render_helper( return self.sub_form.get_field(id)._render_helper(
self.generate_subfield_key(id, key=key), value, REQUEST) self.generate_subfield_key(id, key=key), value, REQUEST, render_prefix)
def Field_generate_subfield_key(self, id, validation=0, key=None): def Field_generate_subfield_key(self, id, validation=0, key=None):
"""Generate the key Silva uses to render a sub field. """Generate the key Silva uses to render a sub field.
......
...@@ -395,7 +395,8 @@ class ListBoxWidget(Widget.Widget): ...@@ -395,7 +395,8 @@ class ListBoxWidget(Widget.Widget):
if REQUEST is None: if REQUEST is None:
REQUEST = get_request() REQUEST = get_request()
if render_format == 'list': if render_format == 'list':
renderer = ListBoxListRenderer(self, field, REQUEST) renderer = ListBoxListRenderer(self, field, REQUEST,
render_prefix=render_prefix)
else: else:
renderer = ListBoxHTMLRenderer(self, field, REQUEST, render_prefix=render_prefix) renderer = ListBoxHTMLRenderer(self, field, REQUEST, render_prefix=render_prefix)
...@@ -1813,7 +1814,7 @@ class ListBoxRendererLine: ...@@ -1813,7 +1814,7 @@ class ListBoxRendererLine:
"""This class describes a line in a ListBox to assist ListBoxRenderer. """This class describes a line in a ListBox to assist ListBoxRenderer.
""" """
def __init__(self, renderer = None, obj = None, index = 0, is_summary = False, context = None, def __init__(self, renderer = None, obj = None, index = 0, is_summary = False, context = None,
is_open = False, selection_domain = None, depth = 0, domain_title=None): is_open = False, selection_domain = None, depth = 0, domain_title=None, render_prefix=None):
"""In reality, the object is a brain or a brain-like object. """In reality, the object is a brain or a brain-like object.
""" """
self.renderer = renderer self.renderer = renderer
...@@ -1825,6 +1826,7 @@ class ListBoxRendererLine: ...@@ -1825,6 +1826,7 @@ class ListBoxRendererLine:
self.selection_domain = selection_domain self.selection_domain = selection_domain
self.depth = depth self.depth = depth
self.domain_title = domain_title self.domain_title = domain_title
self.render_prefix = render_prefix
def getBrain(self): def getBrain(self):
"""Return the brain. This can be identical to a real object. """Return the brain. This can be identical to a real object.
...@@ -2625,7 +2627,8 @@ class ListBox(ZMIField): ...@@ -2625,7 +2627,8 @@ class ListBox(ZMIField):
self) self)
return self.widget.render(field, self.generate_field_key(), None, return self.widget.render(field, self.generate_field_key(), None,
request, request,
render_format=kw.get('render_format')) render_format=kw.get('render_format'),
render_prefix=kw.get('render_prefix'))
else: else:
return None return None
else: else:
......
...@@ -343,7 +343,9 @@ class OOoChartWidget(Widget.Widget): ...@@ -343,7 +343,9 @@ class OOoChartWidget(Widget.Widget):
listbox_id = field.get_value('listbox_id') listbox_id = field.get_value('listbox_id')
if listbox_id in ('', None): if listbox_id in ('', None):
listbox_id = 'listbox' listbox_id = 'listbox'
render_prefix = REQUEST.get('render_prefix')
extra_argument_dict = dict( extra_argument_dict = dict(
render_prefix = render_prefix,
chart_form_id = listbox_form_id, chart_form_id = listbox_form_id,
chart_field_id = listbox_id, chart_field_id = listbox_id,
chart_title = field.get_value('title'), chart_title = field.get_value('title'),
...@@ -383,7 +385,8 @@ class OOoChartWidget(Widget.Widget): ...@@ -383,7 +385,8 @@ class OOoChartWidget(Widget.Widget):
Render a Chart in read-only. Render a Chart in read-only.
""" """
if REQUEST is None: REQUEST=get_request() if REQUEST is None: REQUEST=get_request()
return self.render(field, key, value, REQUEST, render_format=render_format) return self.render(field, key, value, REQUEST, render_format=render_format,
render_prefix=render_prefix)
def render_odf(self, field, key, value, REQUEST, render_format='ooo', render_prefix=None): def render_odf(self, field, key, value, REQUEST, render_format='ooo', render_prefix=None):
...@@ -392,7 +395,6 @@ class OOoChartWidget(Widget.Widget): ...@@ -392,7 +395,6 @@ class OOoChartWidget(Widget.Widget):
""" """
form = field.aq_parent form = field.aq_parent
here = getattr(form, 'aq_parent', REQUEST) here = getattr(form, 'aq_parent', REQUEST)
extra_context = self.getArgumentDict(field, here.REQUEST)
content = ''' content = '''
<office:include path="%s/ERP5Site_buildChart" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed"/> <office:include path="%s/ERP5Site_buildChart" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed"/>
''' % here.getPath() ''' % here.getPath()
...@@ -413,7 +415,6 @@ class OOoChartWidget(Widget.Widget): ...@@ -413,7 +415,6 @@ class OOoChartWidget(Widget.Widget):
If the format is set to an image type (ex. png) If the format is set to an image type (ex. png)
render the chart using that format. render the chart using that format.
""" """
title = field.get_value('title') title = field.get_value('title')
alt = field.get_value('description') or title alt = field.get_value('description') or title
form = field.aq_parent form = field.aq_parent
...@@ -431,20 +432,22 @@ class OOoChartWidget(Widget.Widget): ...@@ -431,20 +432,22 @@ class OOoChartWidget(Widget.Widget):
display = field.get_value('image_display') display = field.get_value('image_display')
if format in STANDARD_IMAGE_FORMAT_LIST: if format in STANDARD_IMAGE_FORMAT_LIST:
main_content = '''<div class="OOoChartContent"> main_content = '''<div class="OOoChartContent">
<img class="%s" src="%s?render_format=%s&display=%s" title="%s" alt="%s"/"> <img class="%s" src="%s?render_format=%s&display=%s&render_prefix=%s" title="%s" alt="%s"/">
</div>''' % (css_class, </div>''' % (css_class,
field_absolute_url, field_absolute_url,
format, format,
display, display,
render_prefix,
title, title,
alt) alt)
return main_content return main_content
elif format == 'raw': elif format == 'raw':
UrlIconOOo = '%s/misc_/ERP5OOo/OOo.png' % REQUEST['BASEPATH1'] UrlIconOOo = '%s/misc_/ERP5OOo/OOo.png' % REQUEST['BASEPATH1']
main_content = '''<div class="OOoChartContent"> main_content = '''<div class="OOoChartContent">
<a href="%s?render_format=&display=%s"><img src="%s" alt="OOo"/></a></div> <a href="%s?render_format=&display=%s&render_prefix=%s"><img src="%s" alt="OOo"/></a></div>
''' % (field_absolute_url, ''' % (field_absolute_url,
display, display,
render_prefix,
UrlIconOOo) UrlIconOOo)
return main_content return main_content
elif format == 'pdf': elif format == 'pdf':
...@@ -453,6 +456,7 @@ class OOoChartWidget(Widget.Widget): ...@@ -453,6 +456,7 @@ class OOoChartWidget(Widget.Widget):
<a href="%s?render_format=pdf&display=%s"><img src="%s" alt="PDF" /></a> <a href="%s?render_format=pdf&display=%s"><img src="%s" alt="PDF" /></a>
</div>''' % (field_absolute_url, </div>''' % (field_absolute_url,
display, display,
render_prefix,
UrlIconPdf) UrlIconPdf)
return main_content return main_content
else: else:
...@@ -466,7 +470,7 @@ class OOoChartWidget(Widget.Widget): ...@@ -466,7 +470,7 @@ class OOoChartWidget(Widget.Widget):
ooo_template = getattr(here, method_id) ooo_template = getattr(here, method_id)
# Render the chart # Render the chart
return ooo_template(format=render_format) return ooo_template(format=render_format, **extra_context)
class OOoChartValidator(Validator.Validator): class OOoChartValidator(Validator.Validator):
""" """
......
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