From 0ea9ca7c334ebd47f676ddd8beed20e350083aa6 Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Fri, 21 Jun 2019 10:13:52 +0200
Subject: [PATCH] Finish removing deprecated restructuredtext template filter

---
 forums/templates/forums/post_card.html        |  4 +--
 .../templates/forums/post_confirm_create.html |  4 +--
 forums/templates/forums/post_form.html        |  2 --
 scipost/templatetags/restructuredtext.py      | 28 -------------------
 .../email/helpdesk/followup_on_ticket.html    |  4 +--
 5 files changed, 6 insertions(+), 36 deletions(-)
 delete mode 100644 scipost/templatetags/restructuredtext.py

diff --git a/forums/templates/forums/post_card.html b/forums/templates/forums/post_card.html
index 4e740b40c..da9085602 100644
--- a/forums/templates/forums/post_card.html
+++ b/forums/templates/forums/post_card.html
@@ -1,4 +1,4 @@
-{% load restructuredtext %}
+{% load automarkup %}
 
 <div class="card m-2 {% if post.motion %}text-white bg-dark{% else %}text-body{% endif %}" id="post{{ post.id }}">
   <div class="card-header">
@@ -12,7 +12,7 @@
     </div>
   </div>
   <div class="card-body">
-    {{ post.text|restructuredtext }}
+    {{ post.text|automarkup }}
   </div>
   <div class="card-footer">
     <div class="d-flex flex-wrap justify-content-end align-items-center">
diff --git a/forums/templates/forums/post_confirm_create.html b/forums/templates/forums/post_confirm_create.html
index ecfe1118e..cf151c8c1 100644
--- a/forums/templates/forums/post_confirm_create.html
+++ b/forums/templates/forums/post_confirm_create.html
@@ -1,7 +1,7 @@
 {% extends 'forums/base.html' %}
 
 {% load bootstrap %}
-{% load restructuredtext %}
+{% load automarkup %}
 
 
 {% block breadcrumb_items %}
@@ -23,7 +23,7 @@
 	</div>
 	<div class="card-body">
 	  {% if form.initial.text %}
-	    {{ form.initial.text|restructuredtext }}
+	    {{ form.initial.text|automarkup }}
 	  {% else %}
 	    <span class="text-danger">No text given</span>
 	  {% endif %}
diff --git a/forums/templates/forums/post_form.html b/forums/templates/forums/post_form.html
index b78bd613d..75d62c012 100644
--- a/forums/templates/forums/post_form.html
+++ b/forums/templates/forums/post_form.html
@@ -1,8 +1,6 @@
 {% extends 'forums/base.html' %}
 
 {% load bootstrap %}
-{% load restructuredtext %}
-
 
 {% block breadcrumb_items %}
   {{ block.super }}
diff --git a/scipost/templatetags/restructuredtext.py b/scipost/templatetags/restructuredtext.py
deleted file mode 100644
index 1bc890ffb..000000000
--- a/scipost/templatetags/restructuredtext.py
+++ /dev/null
@@ -1,28 +0,0 @@
-__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
-__license__ = "AGPL v3"
-
-
-from django import template
-from django.utils.encoding import force_text
-from django.utils.safestring import mark_safe
-
-
-register = template.Library()
-
-
-@register.filter(name='restructuredtext')
-def restructuredtext(text):
-    if not text:
-        return ''
-    from docutils.core import publish_parts
-    parts = publish_parts(
-        source=text,
-        writer_name='html5_polyglot',
-        settings_overrides={
-            'math_output': 'MathJax  https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML,Safe',
-            'initial_header_level': 1,
-            'doctitle_xform': False,
-            'raw_enabled': False,
-            'file_insertion_enabled': False,
-        })
-    return mark_safe(force_text(parts['html_body']))
diff --git a/templates/email/helpdesk/followup_on_ticket.html b/templates/email/helpdesk/followup_on_ticket.html
index 16d0ea703..67baf4f61 100644
--- a/templates/email/helpdesk/followup_on_ticket.html
+++ b/templates/email/helpdesk/followup_on_ticket.html
@@ -1,10 +1,10 @@
-{% load restructuredtext %}
+{% load automarkup %}
 <p>
   Re: ticket {{ followup.ticket.title }}
 </p>
 <p>A followup has been posted by {{ followup.by.get_full_name }} on the ticket above:</p>
 <hr>
-{{ followup.text|restructuredtext }}
+{{ followup.text|automarkup }}
 <hr>
 <p>You can view details (and eventually take further steps) by navigating to the <a href="https://scipost.org{{ followup.ticket.get_absolute_url }}">ticket's page</a> (login required). You can also see this ticket on your personal list at our online <a href="https://scipost.org/helpdesk/">helpdesk</a>.</p>
 <p>
-- 
GitLab