Пример #1
0
    def embed_layout(self, context, layout, **kwargs):
        """Render layout and widgets

        :param context: Rendering context
        :param layout: Identifier of target layout
        :param schema: Data describing widget positioning
        :param widgets: Widgets definition
        """
        dbmod = DashboardModule(self.env)
        schema = kwargs.get('schema', {})
        if isinstance(schema, basestring):
            schema = _json.loads(schema)
        widgets = kwargs.get('widgets')
        if widgets is not None:
            # TODO: Use this one once widgets markup parser will be ready
            #widgets = parse_widgets_markup(widgets)
            if isinstance(widgets, basestring):
                widgets = _json.loads(widgets)
        else:
            widgets = {}
        schema['widgets'] = widgets
        template, layout_data = dbmod.expand_layout_data(
            context, layout, schema, True)
        widgets = dbmod.expand_widget_data(context, layout_data)
        return Chrome(self.env).render_template(
            context.req,
            template,
            dict(context=context,
                 layout=layout_data,
                 widgets=widgets,
                 title='',
                 default={'height': dbmod.default_widget_height or None}),
            fragment=True)
Пример #2
0
    def embed_layout(self, context, layout, **kwargs):
        """Render layout and widgets

        :param context: Rendering context
        :param layout: Identifier of target layout
        :param schema: Data describing widget positioning
        :param widgets: Widgets definition
        """
        dbmod = DashboardModule(self.env)
        schema = kwargs.get('schema', {})
        if isinstance(schema, basestring):
            schema = _json.loads(schema)
        widgets = kwargs.get('widgets')
        if widgets is not None:
            # TODO: Use this one once widgets markup parser will be ready
            #widgets = parse_widgets_markup(widgets)
            if isinstance(widgets, basestring):
                widgets = _json.loads(widgets)
        else:
            widgets = {}
        schema['widgets'] = widgets
        template, layout_data = dbmod.expand_layout_data(context, layout,
                                                         schema, True)
        widgets = dbmod.expand_widget_data(context, layout_data)
        return Chrome(self.env).render_template(
            context.req, template,
            dict(context=context, layout=layout_data, widgets=widgets, title='',
                 default={'height': dbmod.default_widget_height or None}),
            fragment=True)
Пример #3
0
    def expand_widget(self, context, widget):
        """Render single widget

        :param context: Rendering context
        :param widget: Widget definition
        """
        dbmod = DashboardModule(self.env)
        options = widget['args'][2]
        argsdef = options.get('args')
        if isinstance(argsdef, basestring):
            options['args'] = _json.loads(argsdef)
        elif isinstance(argsdef, Stream):
            options['args'] = parse_args_tag(argsdef)
        return dbmod.expand_widget_data(context, {'widgets': {0: widget}})[0]
Пример #4
0
    def expand_widget(self, context, widget):
        """Render single widget

        :param context: Rendering context
        :param widget: Widget definition
        """
        dbmod = DashboardModule(self.env)
        options = widget['args'][2]
        argsdef = options.get('args')
        if isinstance(argsdef, basestring):
            options['args'] = _json.loads(argsdef)
        elif isinstance(argsdef, Stream):
            options['args'] = parse_args_tag(argsdef)
        return dbmod.expand_widget_data(context, {'widgets': {0: widget}})[0]