Make comment revision work again

This commit is contained in:
cuom1999 2023-04-10 19:44:33 -05:00
parent d0511f46c0
commit 9f225157d2
2 changed files with 9 additions and 4 deletions

View file

@ -24,6 +24,8 @@ from judge.utils.views import TitleMixin
from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget
from judge.comments import add_mention_notifications, del_mention_notifications from judge.comments import add_mention_notifications, del_mention_notifications
import json
__all__ = [ __all__ = [
"upvote_comment", "upvote_comment",
"downvote_comment", "downvote_comment",
@ -120,7 +122,12 @@ class CommentRevisionAjax(CommentMixin, DetailView):
) )
except ValueError: except ValueError:
raise Http404 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 return context
def get_object(self, queryset=None): def get_object(self, queryset=None):

View file

@ -1,3 +1 @@
{% with node=revision.object %} <div class="comment-body">{{ body|markdown|reference|str|safe }}</div>
<div class="comment-body">{{ node.body|markdown|reference|str|safe }}</div>
{% endwith %}