Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adds cms stack plugin

closes #2
  • Loading branch information...
commit 7fd3a8a529d4abd97de96afb488ab847f3bcdbbc 1 parent 8ee67aa
Stefan Foulis stefanfoulis authored
Showing with 24 additions and 21 deletions.
  1. +23 −17 stacks/cms_plugins.py
  2. +1 −4 stacks/templates/cms/plugins/stacks.html
40 stacks/cms_plugins.py
View
@@ -1,22 +1,28 @@
+from django.utils.safestring import mark_safe
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
from django.utils.translation import ugettext_lazy as _
-#from stacks.models import StackLink
+from cms.plugin_rendering import render_plugins
+from stacks.models import StackLink
from cms.plugins.utils import get_plugins
-#class StackPlugin(CMSPluginBase):
-# model = StackLink
-# name = _("Stack")
-#
-# render_template = "cms/plugins/stacks.html"
-#
-# def render(self, context, instance, placeholder):
-# plugins = get_plugins(context['request'], instance.stack.content)
-# context.update({
-# 'object': instance,
-# 'placeholder':placeholder,
-# 'plugins':plugins,
-# })
-# return context
-#
-#plugin_pool.register_plugin(StackPlugin)
+class StackPlugin(CMSPluginBase):
+ model = StackLink
+ name = _("Stack")
+
+ render_template = "cms/plugins/stacks.html"
+
+ def render(self, context, instance, placeholder):
+ # TODO: once we drop 2.3.x support we can just use the "render_plugin" templatetag
+ # instead of rendering html here.
+ plugins = get_plugins(context['request'], instance.stack.content)
+ processors = ()
+ html_content = mark_safe("".join(render_plugins(plugins, context, placeholder, processors)))
+ context.update({
+ 'instance': instance,
+ 'placeholder': placeholder,
+ 'content': html_content,
+ })
+ return context
+
+plugin_pool.register_plugin(StackPlugin)
5 stacks/templates/cms/plugins/stacks.html
View
@@ -1,4 +1 @@
-{% load cms_tags %}
-{% for plugin in plugins %}
- {% render_plugin plugin %}
-{% endfor %}
+{{ content }}
Please sign in to comment.
Something went wrong with that request. Please try again.