コード例 #1
0
ファイル: models.py プロジェクト: Turistforeningen/sherpa
    def render_widget(self, request, current_site, admin_context=False, preview_context=False):
        """Render this widget (obviously only applicable for widget-content) in the context of the given site"""
        from cms.widgets.util import render_widget
        if self.type != 'widget':
            raise Exception("render_widget called on Content of type '%s'" % self.type)

        return render_widget(
            request,
            self.get_content,
            current_site,
            admin_context=admin_context,
            preview_context=preview_context,
            content_id=self.id,
        )
コード例 #2
0
def reload_raw_widget(request, site):
    try:
        active_site = Site.get_cached_by_id(site)
        return HttpResponse(render_widget(
            request,
            json.loads(request.POST['content']),
            active_site,
            raw=True,
            admin_context=True,
        ))
    except:
        logger.warning(
            "Feil ved raw widget rendering i editor",
            exc_info=sys.exc_info(),
            extra={
                'request': request,
                'site': site,
            }
        )
        return HttpResponseBadRequest()