From 759a70ef4dc302d7589fcb44ae6776c5de7fc1c1 Mon Sep 17 00:00:00 2001
From: Alice Heaton <aliceh@aptivate.org>
Date: Mon, 13 Jul 2015 11:31:36 +0100
Subject: [PATCH] Allow the basic text widget to display html

---
 .../dashboard/templates/dashboard/basic-text-widget.html    | 6 +++++-
 django/website/dashboard/widget_pool.py                     | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/django/website/dashboard/templates/dashboard/basic-text-widget.html b/django/website/dashboard/templates/dashboard/basic-text-widget.html
index 9d831663..03583536 100644
--- a/django/website/dashboard/templates/dashboard/basic-text-widget.html
+++ b/django/website/dashboard/templates/dashboard/basic-text-widget.html
@@ -4,6 +4,10 @@
         {{ title }}
     </div>
     <div class='panel-body'>
-        {{ text }}
+        {% if html %}
+            {{ text|safe }}
+        {% else %}
+            {{ text }}
+        {% endif %}
     </div>
 </div>
diff --git a/django/website/dashboard/widget_pool.py b/django/website/dashboard/widget_pool.py
index 4dcece56..7615b0bb 100644
--- a/django/website/dashboard/widget_pool.py
+++ b/django/website/dashboard/widget_pool.py
@@ -36,15 +36,19 @@ class BasicTextWidget(object):
     Settings:
         title: The widget title
         text: The widget text
+        html: If true, the content contains html.
+              If false, the content should be escaped.
     """
     template_name = 'dashboard/basic-text-widget.html'
 
     def get_context_data(self, **kwargs):
         title = kwargs.get('title', '(no title')
         text = kwargs.get('text', '(no text)')
+        html = kwargs.get('html', False)
         return {
             'title': title,
-            'text': text
+            'text': text,
+            'html': html
         }
 
 register_widget('basic-text-widget', BasicTextWidget())
-- 
GitLab