diff --git a/judge/comments.py b/judge/comments.py index f13a560..09171b0 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -165,8 +165,10 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): context["replies"] = len(queryset.filter(parent=None)) queryset = ( queryset.filter(parent=None)[:10].select_related("author__user") + .filter(hidden=False) .defer("author__about") - .annotate(revisions=Count("versions")).annotate(count_replies=Count("replies")) + .annotate(revisions=Count("versions")) + .annotate(count_replies=Count("replies")) ) context["has_comments"] = queryset.exists() context["comment_lock"] = self.is_comment_locked() diff --git a/judge/views/comment.py b/judge/views/comment.py index ec30647..bba7d38 100644 --- a/judge/views/comment.py +++ b/judge/views/comment.py @@ -30,6 +30,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", @@ -188,7 +190,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/resources/comments.scss b/resources/comments.scss index efede6a..0b4cc6c 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/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 %} -