Repository: comic/grand-challenge.org

Issue:
https://grand-challenge.org/forum is broken
![image](https://user-images.githubusercontent.com/1818749/48251866-5eb8bc00-e403-11e8-98c8-5933b6797028.png)

Remove the link to it? Fix it? Or stop using the forum altogether? If it is easy to make our own forum in django, this may be preferable. Especially if we can then also send out our own mailings via django. We could keep the google forum open until this works though.


Discussion:
This broke as we no longer allow challenge administrators to execute scripts. For now, lets replace it with a tag that people can use so we can get the existing forums back. 

I know that EYRA would like forums built in, I will discuss this with them on Tuesday.

Resolving patch:
diff --git a/app/config/settings.py b/app/config/settings.py
--- a/app/config/settings.py
+++ b/app/config/settings.py
@@ -406,7 +406,13 @@ def strtobool(val) -> bool:
     "abbr": ["title"],
     "acronym": ["title"],
     "div": ["data-geochart"],  # Required for geocharts
-    "iframe": ["src", "sandbox"],  # For continuous registration challenge
+    "iframe": [
+        "src",
+        "sandbox",
+        "data-groupname",
+        "scrolling",
+        "height",
+    ],  # For continuous registration challenge and google group
     "img": ["height", "src", "width"],
 }
 BLEACH_ALLOWED_STYLES = ["height", "margin-left", "text-align", "width"]
diff --git a/app/grandchallenge/core/templatetags/grandchallenge_tags.py b/app/grandchallenge/core/templatetags/grandchallenge_tags.py
--- a/app/grandchallenge/core/templatetags/grandchallenge_tags.py
+++ b/app/grandchallenge/core/templatetags/grandchallenge_tags.py
@@ -18,6 +18,7 @@
 from django.db.models import Count
 from django.template import defaulttags
 from django.urls import reverse as reverse_djangocore
+from django.utils.safestring import mark_safe
 from matplotlib.backends.backend_svg import FigureCanvasSVG as FigureCanvas
 from matplotlib.figure import Figure
 
@@ -330,6 +331,24 @@ def main_page_url():
         return "/"
 
 
+@register.simple_tag
+def google_group(group_name):
+    """Allows challenge admins to add google groups to pages"""
+    return mark_safe(
+        f"""
+    <iframe 
+        class="w-100"
+        id="forum_embed" 
+        data-groupname="{group_name}"
+        src="javascript:void(0)"
+        scrolling="no"
+        frameborder="0"
+        height="700px">
+    </iframe>
+    """
+    )
+
+
 @register.tag(
     name="listdir",
     usagestr="""Tag usage: {% listdir <path>:string  <extensionFilter>:ext1,ext2,ext3 %}


Test patch:
diff --git a/app/tests/core_tests/test_templatetags.py b/app/tests/core_tests/test_templatetags.py
--- a/app/tests/core_tests/test_templatetags.py
+++ b/app/tests/core_tests/test_templatetags.py
@@ -78,3 +78,12 @@ def test_insert_graph(rf: RequestFactory, view_type):
         assert "Created with matplotlib" in rendered
     else:
         assert "comictablecontainer" in rendered
+
+
+@pytest.mark.django_db
+def test_google_group():
+    template = Template(
+        "{% load google_group from grandchallenge_tags %}{% google_group 'my-group' %}"
+    )
+    rendered = template.render(Context({}))
+    assert 'data-groupname="my-group"' in rendered