From 9f225157d2a8a2859347bf0a87b013f84809305b Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 10 Apr 2023 19:44:33 -0500 Subject: [PATCH] Make comment revision work again --- judge/views/comment.py | 9 ++++++++- templates/comments/revision-ajax.html | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/judge/views/comment.py b/judge/views/comment.py index 962d9f1..19085fb 100644 --- a/judge/views/comment.py +++ b/judge/views/comment.py @@ -24,6 +24,8 @@ from judge.utils.views import TitleMixin from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget from judge.comments import add_mention_notifications, del_mention_notifications +import json + __all__ = [ "upvote_comment", "downvote_comment", @@ -120,7 +122,12 @@ class CommentRevisionAjax(CommentMixin, DetailView): ) except ValueError: raise Http404 - context["revision"] = revisions[wanted] + revision = revisions[wanted] + data = json.loads(revision.serialized_data) + try: + context["body"] = data[0]["fields"]["body"] + except Exception: + context["body"] = "" return context def get_object(self, queryset=None): diff --git a/templates/comments/revision-ajax.html b/templates/comments/revision-ajax.html index 6c6360a..4a2091e 100644 --- a/templates/comments/revision-ajax.html +++ b/templates/comments/revision-ajax.html @@ -1,3 +1 @@ -{% with node=revision.object %} -
{{ node.body|markdown|reference|str|safe }}
-{% endwith %} +
{{ body|markdown|reference|str|safe }}