Commit 58cf57d8 authored by Romain Courteaud's avatar Romain Courteaud Committed by Xiaowu Zhang

GadgetField: handle gadget fields loaded from a web site

parent f7666634
...@@ -41,11 +41,15 @@ class GadgetWidget(Widget.Widget): ...@@ -41,11 +41,15 @@ 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')
if 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