Browse Source

Make request_context an optional argument in get_context_data.

master
Erik Stein 7 years ago
parent
commit
377f83cc8d
  1. 14
      content_plugins/base.py

14
content_plugins/base.py

@ -69,12 +69,13 @@ class BasePlugin(models.Model):
""" """
return self.get_template_names() return self.get_template_names()
def get_context_data(self, request_context=None, **kwargs): def get_context_data(self, **kwargs):
context = kwargs.get('context', {}) # context = kwargs.get('context', {})
context = {}
context['content'] = self context['content'] = self
context['parent'] = self.parent context['parent'] = self.parent
if request_context: if 'request_context' in kwargs:
context['request'] = getattr(request_context, 'request', None) context['request'] = getattr(kwargs['request_context'], 'request', None)
return context return context
# For rendering the template's render() method is used # For rendering the template's render() method is used
@ -120,6 +121,7 @@ class FilesystemTemplateRendererPlugin(BasePlugin):
else: else:
template_names = [] template_names = []
# TODO Don't call super here, this *is* the file system template plugin
template_names.extend(super().get_template_names() or []) template_names.extend(super().get_template_names() or [])
return template_names + [ return template_names + [
@ -164,8 +166,8 @@ class SectionBase(StyleMixin, BasePlugin):
<h2>{{ subheading }}</h2> <h2>{{ subheading }}</h2>
""") """)
def get_context_data(self, request_context, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(request_context, **kwargs) context = super().get_context_data(**kwargs)
context['slug'] = self.slug context['slug'] = self.slug
context['subheading'] = self.subheading context['subheading'] = self.subheading
return context return context

Loading…
Cancel
Save