|
|
@ -49,7 +49,7 @@ class BasePlugin(models.Model): |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def register_with_renderer(cls, renderer): |
|
|
|
def register_with_renderer(cls, renderer): |
|
|
|
renderer.register_template_renderer(cls, cls.get_template, cls.get_context_data) |
|
|
|
renderer.register_template_renderer(cls, cls.get_template, cls.get_plugin_context) |
|
|
|
|
|
|
|
|
|
|
|
def get_template_names(self): |
|
|
|
def get_template_names(self): |
|
|
|
t = getattr(self, 'template_name', None) |
|
|
|
t = getattr(self, 'template_name', None) |
|
|
@ -69,13 +69,16 @@ class BasePlugin(models.Model): |
|
|
|
""" |
|
|
|
""" |
|
|
|
return self.get_template_names() |
|
|
|
return self.get_template_names() |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, context=None, **kwargs): |
|
|
|
def get_plugin_context(self, context=None, **kwargs): |
|
|
|
context = context or {} |
|
|
|
""" |
|
|
|
context['content'] = self |
|
|
|
Returns a dict. |
|
|
|
context['parent'] = self.parent |
|
|
|
""" |
|
|
|
|
|
|
|
plugin_context = {} |
|
|
|
|
|
|
|
plugin_context['content'] = self |
|
|
|
|
|
|
|
plugin_context['parent'] = self.parent |
|
|
|
if 'request_context' in kwargs: |
|
|
|
if 'request_context' in kwargs: |
|
|
|
context['request'] = getattr(kwargs['request_context'], 'request', None) |
|
|
|
plugin_context['request'] = getattr(kwargs['request_context'], 'request', None) |
|
|
|
return context |
|
|
|
return plugin_context |
|
|
|
|
|
|
|
|
|
|
|
# For rendering the template's render() method is used |
|
|
|
# For rendering the template's render() method is used |
|
|
|
|
|
|
|
|
|
|
@ -165,8 +168,8 @@ class SectionBase(StyleMixin, BasePlugin): |
|
|
|
<h2>{{ subheading }}</h2> |
|
|
|
<h2>{{ subheading }}</h2> |
|
|
|
""") |
|
|
|
""") |
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, context=None, **kwargs): |
|
|
|
def get_plugin_context(self, context=None, **kwargs): |
|
|
|
context = super().get_context_data(context=context, **kwargs) |
|
|
|
context = super().get_plugin_context(context=None, **kwargs) |
|
|
|
context['slug'] = self.slug |
|
|
|
context['slug'] = self.slug |
|
|
|
context['subheading'] = self.subheading |
|
|
|
context['subheading'] = self.subheading |
|
|
|
return context |
|
|
|
return context |
|
|
|