Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1482 from piquadrat/feature/fix-inherit-empty-plugin

fixed the inherit plugin so that it does not explode when trying to render an "empty" plugin
  • Loading branch information...
commit 4d797856e42bfc2b5121b9f139c5e93b955cea27 2 parents 2b95e08 + fda2484
Patrick Lauber authored
Showing with 31 additions and 0 deletions.
  1. +2 −0  cms/plugins/inherit/cms_plugins.py
  2. +29 −0 cms/tests/plugins.py
2  cms/plugins/inherit/cms_plugins.py
View
@@ -51,6 +51,8 @@ def render(self, context, instance, placeholder):
tmpctx = copy.copy(context)
tmpctx.update(template_vars)
inst, name = plg.get_plugin_instance()
+ if inst is None:
+ continue
outstr = inst.render_plugin(tmpctx, placeholder)
plugin_output.append(outstr)
template_vars['parent_output'] = plugin_output
29 cms/tests/plugins.py
View
@@ -495,6 +495,35 @@ def test_inheritplugin_media(self):
response = self.client.get(page.get_absolute_url())
self.assertTrue('%scms/js/libs/jquery.tweet.js' % settings.STATIC_URL in response.content, response.content)
+ def test_inherit_plugin_with_empty_plugin(self):
+ inheritfrompage = create_page('page to inherit from',
+ 'nav_playground.html',
+ 'en', published=True)
+
+ body = inheritfrompage.placeholders.get(slot="body")
+ empty_plugin = CMSPlugin(
+ plugin_type='TextPlugin', # create an empty plugin
+ placeholder=body,
+ position=1,
+ language='en',
+ )
+ empty_plugin.insert_at(None, position='last-child', save=True)
+ other_page = create_page('other page', 'nav_playground.html', 'en', published=True)
+ inherited_body = other_page.placeholders.get(slot="body")
+ inherit_plugin = InheritPagePlaceholder(
+ plugin_type='InheritPagePlaceholderPlugin',
+ placeholder=inherited_body,
+ position=1,
+ language='en',
+ from_page=inheritfrompage,
+ from_language='en'
+ )
+ inherit_plugin.insert_at(None, position='last-child', save=True)
+ add_plugin(inherited_body, "TextPlugin", "en", body="foobar")
+ # this should not fail, even if there in an empty plugin
+ rendered = inherited_body.render(context=self.get_context(other_page.get_absolute_url()), width=200)
+ self.assertIn("foobar", rendered)
+
def test_render_textplugin(self):
# Setup
page = create_page("render test", "nav_playground.html", "en")
Please sign in to comment.
Something went wrong with that request. Please try again.