Browse Source

Optional context kwarg in get_context_data signature.

master
Erik Stein 7 years ago
parent
commit
28ec386384
  1. 9
      content_plugins/base.py
  2. 6
      content_plugins/plugins/mixins.py
  3. 2
      content_plugins/renderer.py

9
content_plugins/base.py

@ -69,9 +69,8 @@ class BasePlugin(models.Model):
"""
return self.get_template_names()
def get_context_data(self, **kwargs):
# context = kwargs.get('context', {})
context = {}
def get_context_data(self, context=None, **kwargs):
context = context or {}
context['content'] = self
context['parent'] = self.parent
if 'request_context' in kwargs:
@ -166,8 +165,8 @@ class SectionBase(StyleMixin, BasePlugin):
<h2>{{ subheading }}</h2>
""")
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
def get_context_data(self, context=None, **kwargs):
context = super().get_context_data(context=context, **kwargs)
context['slug'] = self.slug
context['subheading'] = self.subheading
return context

6
content_plugins/plugins/mixins.py

@ -45,10 +45,10 @@ class StyleMixin(models.Model):
)
]
def get_context_data(self, **kwargs):
def get_context_data(self, context=None, **kwargs):
if hasattr(super(), 'get_context_data'):
context = super().get_context_data(**kwargs)
context = super().get_context_data(context=context, **kwargs)
else:
context = {}
context = context or {}
context['style'] = self.get_style_slug()
return context

2
content_plugins/renderer.py

@ -30,7 +30,7 @@ class ContentPluginRenderer(TemplatePluginRenderer):
return super().regions(item, inherit_from=inherit_from, regions=regions)
# Preliminary class
# Experimental implementation
class PluginRenderer(content_editor.PluginRenderer):
def register(self, plugin, renderer=None):
if not renderer:

Loading…
Cancel
Save