From 9f225157d2a8a2859347bf0a87b013f84809305b Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 10 Apr 2023 19:44:33 -0500 Subject: [PATCH 1/3] 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 }}
From 7ef0c47427e178f60c69fdfbcd578bfac319c3ea Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 10 Apr 2023 20:25:49 -0500 Subject: [PATCH 2/3] Change comment css --- resources/comments.scss | 13 +++++++++---- templates/comments/list.html | 14 +++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/resources/comments.scss b/resources/comments.scss index 54118e7..9abca9e 100644 --- a/resources/comments.scss +++ b/resources/comments.scss @@ -37,6 +37,11 @@ a { border: 1px solid #CCC; } + .comment-img { + display: flex; + margin-right: 4px; + } + .new-comments .comment-display { display: flex; margin-top: -0.25em !important; @@ -47,9 +52,8 @@ a { } .new-comments .comment .detail { - margin: 0px 15px 0px; width: 100%; - max-width: calc(100% - 134px); + padding-right: 1em; } .new-comments .comment-edits { @@ -64,6 +68,7 @@ a { border-bottom: 1px #888 solid; color: #888; text-align: right; + align-items: center; } .previous-revision, .next-revision { @@ -80,8 +85,8 @@ a { } .new-comments .gravatar { - width: 75px; - max-width: 75px; + width: 1.5em; + border-radius: 50%; } .new-comments .vote { diff --git a/templates/comments/list.html b/templates/comments/list.html index 44c2515..6adf903 100644 --- a/templates/comments/list.html +++ b/templates/comments/list.html @@ -64,16 +64,16 @@ class="downvote-link fa fa-chevron-down fa-fw"> {% endif %} - {% with author=node.author, user=node.author.user %} - - - - {% endwith %}
- {{ link_user(node.author) }}  - {{ relative_time(node.time, abs=_('commented on {time}'), rel=_('commented {time}')) }} + {% with author=node.author, user=node.author.user %} + + + + {% endwith %} + {{ link_user(node.author) }},  + {{ relative_time(node.time, abs=_('{time}'), rel=_('{time}')) }} {% if node.revisions > 1 %} From 9cdcfa54d604b45bd802fbf04c1e303d2ebf452f Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 10 Apr 2023 20:40:41 -0500 Subject: [PATCH 3/3] Filter hidden comments --- judge/comments.py | 1 + 1 file changed, 1 insertion(+) diff --git a/judge/comments.py b/judge/comments.py index d99f11e..08d1cb7 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -166,6 +166,7 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): context["comment_lock"] = self.is_comment_locked() queryset = ( queryset.select_related("author__user") + .filter(hidden=False) .defer("author__about") .annotate(revisions=Count("versions")) )