Commit c1b33489 authored by Romain Courteaud's avatar Romain Courteaud

GadgetField: handle gadget fields loaded from a web site

parent 7401827b
...@@ -41,11 +41,14 @@ class GadgetWidget(Widget.Widget): ...@@ -41,11 +41,14 @@ class GadgetWidget(Widget.Widget):
return self.render_view(field, value, REQUEST, render_prefix, key) return self.render_view(field, value, REQUEST, render_prefix, key)
def render_view(self, field, value, REQUEST=None, render_prefix=None, key=None): def render_view(self, field, value, REQUEST=None, render_prefix=None, key=None):
gadget_url = field.get_value('gadget_url')
gadget_component = field.restrictedTraverse(gadget_url, None)
if gadget_component is not None:
gadget_url = gadget_component.absolute_url()
kw = { kw = {
'data-gadget-sandbox': field.get_value('js_sandbox'), 'data-gadget-sandbox': field.get_value('js_sandbox'),
# Duplicate the absolute url logic of xhtml style # Duplicate the absolute url logic of xhtml style
'data-gadget-url': urljoin(field.getPortalObject().absolute_url() + '/', 'data-gadget-url': gadget_url,
field.get_value('gadget_url')),
'data-gadget-value': value, 'data-gadget-value': value,
'data-gadget-renderjs-extra': dumps(dict(field.get_value('renderjs_extra'))) 'data-gadget-renderjs-extra': dumps(dict(field.get_value('renderjs_extra')))
} }
......
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