|
|
@@ -45,18 +45,15 @@ class Panel:
|
|
|
Parameters:
|
|
|
title (str): The human-friendly title of the panel
|
|
|
actions (list): An iterable of PanelActions to include in the panel header
|
|
|
- template_name (str): Overrides the default template name, if defined
|
|
|
"""
|
|
|
template_name = None
|
|
|
title = None
|
|
|
actions = None
|
|
|
|
|
|
- def __init__(self, title=None, actions=None, template_name=None):
|
|
|
+ def __init__(self, title=None, actions=None):
|
|
|
if title is not None:
|
|
|
self.title = title
|
|
|
self.actions = actions or self.actions or []
|
|
|
- if template_name is not None:
|
|
|
- self.template_name = template_name
|
|
|
|
|
|
def get_context(self, context):
|
|
|
"""
|
|
|
@@ -324,12 +321,17 @@ class TemplatePanel(Panel):
|
|
|
Parameters:
|
|
|
template_name (str): The name of the template to render
|
|
|
"""
|
|
|
- def __init__(self, template_name):
|
|
|
- super().__init__(template_name=template_name)
|
|
|
+ def __init__(self, template_name, **kwargs):
|
|
|
+ self.template_name = template_name
|
|
|
+ super().__init__(**kwargs)
|
|
|
|
|
|
def render(self, context):
|
|
|
- # Pass the entire context to the template
|
|
|
- return render_to_string(self.template_name, context.flatten())
|
|
|
+ # Pass the entire context to the template, but let the panel's own context take precedence
|
|
|
+ # for panel-specific variables (title, actions, panel_class)
|
|
|
+ return render_to_string(self.template_name, {
|
|
|
+ **context.flatten(),
|
|
|
+ **self.get_context(context),
|
|
|
+ })
|
|
|
|
|
|
|
|
|
class TextCodePanel(ObjectPanel):
|