diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py index 87f579dc23d225cbb052ad35ef175bf691d330d5..76b135ff16f26ea23c74f5b2bcf1eb8ffe050251 100644 --- a/SciPost_v1/settings/base.py +++ b/SciPost_v1/settings/base.py @@ -79,6 +79,7 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.sites', 'django_countries', + 'django_docutils', 'django_extensions', 'django_mathjax', 'ajax_select', diff --git a/forums/models.py b/forums/models.py index b109adcd5e1fe212c5d3e5485b35e8b4151b2a03..e5965eaf659d5c1b2b96acdddeabe61c2ecdb2a2 100644 --- a/forums/models.py +++ b/forums/models.py @@ -2,6 +2,8 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" +from docutils.core import publish_parts, publish_string + from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse diff --git a/forums/templates/forums/post_card.html b/forums/templates/forums/post_card.html index 772719e1526dd1d4b731683852efefd460f88c69..32994b754f0a90e8c0f9b54a1acfc9bf2ae3f788 100644 --- a/forums/templates/forums/post_card.html +++ b/forums/templates/forums/post_card.html @@ -1,3 +1,5 @@ +{% load django_docutils %} + <div class="card" id="post{{ post.id }}"> <div class="card-header"> {{ post.subject }} @@ -10,9 +12,7 @@ </div> </div> <div class="card-body"> - <p class="card-text"> - {{ post.text }} - </p> + {{ post.text|restructuredtext }} </div> <div class="card-footer"> <a href="{% url 'forums:post_create' slug=forum.slug parent_model='post' parent_id=post.id %}">Reply to this post</a> diff --git a/requirements.txt b/requirements.txt index df24bdb424318d6a94fc91123d8effc06c9fb7b9..1cf842d5c1fa33db9bf79b30a543ab3974611ad0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,6 +26,7 @@ django-maintenancemode-2==1.1.11 # Documentation Packages docutils==0.14 # What's this thing? -> for docs! +django-docutils=0.4.0 Pygments==2.2.0 # Syntax highlighter Sphinx==1.4.9 sphinx-rtd-theme==0.1.9 # Sphinx theme