Created
August 15, 2017 15:21
-
-
Save czpython/1d9ebb35cc6fb0a174fa5192df5d4b5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import AnonymousUser | |
from django.test.client import RequestFactory | |
from sekizai.context import SekizaiContext | |
from cms.toolbar.toolbar import CMSToolbar | |
def get_request(path='/'): | |
request = RequestFactory().get(path) | |
request.current_page = None | |
request.session = {'cms_edit': False} | |
request.user = AnonymousUser() | |
request.LANGUAGE_CODE = plugin.language | |
request.toolbar = CMSToolbar(request) | |
return request | |
def render_plugin(plugin): | |
request = get_request() | |
renderer = request.toolbar.content_renderer | |
context = SekizaiContext() | |
context['request'] = request | |
return renderer.render_plugin(plugin, context, editable=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment