Skip to content
Snippets Groups Projects
Commit 5eb8af36 authored by Alice Heaton's avatar Alice Heaton :speech_balloon:
Browse files

Ensure render_widget works if a widget has no 'get_context_data', and fix dashboard tests

parent cd6763ab
Branches
No related tags found
No related merge requests found
...@@ -51,6 +51,8 @@ def render_widget(widget_instance): ...@@ -51,6 +51,8 @@ def render_widget(widget_instance):
# Get context # Get context
try: try:
context = widget.get_context_data(**settings) context = widget.get_context_data(**settings)
except AttributeError:
context = {}
except Exception as e: except Exception as e:
logger.exception('Error while fetching widget context data: %s', e) logger.exception('Error while fetching widget context data: %s', e)
template_name = 'dashboard/widget-error.html' template_name = 'dashboard/widget-error.html'
......
...@@ -150,5 +150,5 @@ class WidgetPoolTestCase(TestCase): ...@@ -150,5 +150,5 @@ class WidgetPoolTestCase(TestCase):
mock, 'template_name' mock, 'template_name'
) )
self.assertEqual( self.assertEqual(
template_name, 'dashboard/widget-missing-template.html' template_name, 'dashboard/widget-error.html'
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment