Merge branch 'master' of https://github.com/zhaospei/online-judge
This commit is contained in:
commit
e02675279d
4 changed files with 21 additions and 9 deletions
|
@ -165,8 +165,10 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
||||||
context["replies"] = len(queryset.filter(parent=None))
|
context["replies"] = len(queryset.filter(parent=None))
|
||||||
queryset = (
|
queryset = (
|
||||||
queryset.filter(parent=None)[:10].select_related("author__user")
|
queryset.filter(parent=None)[:10].select_related("author__user")
|
||||||
|
.filter(hidden=False)
|
||||||
.defer("author__about")
|
.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["has_comments"] = queryset.exists()
|
||||||
context["comment_lock"] = self.is_comment_locked()
|
context["comment_lock"] = self.is_comment_locked()
|
||||||
|
|
|
@ -30,6 +30,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",
|
||||||
|
@ -188,7 +190,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):
|
||||||
|
|
|
@ -37,6 +37,11 @@ a {
|
||||||
border: 1px solid #CCC;
|
border: 1px solid #CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.comment-img {
|
||||||
|
display: flex;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.new-comments .comment-display {
|
.new-comments .comment-display {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: -0.25em !important;
|
margin-top: -0.25em !important;
|
||||||
|
@ -47,9 +52,8 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.new-comments .comment .detail {
|
.new-comments .comment .detail {
|
||||||
margin: 0px 15px 0px;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: calc(100% - 134px);
|
padding-right: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.new-comments .comment-edits {
|
.new-comments .comment-edits {
|
||||||
|
@ -64,6 +68,7 @@ a {
|
||||||
border-bottom: 1px #888 solid;
|
border-bottom: 1px #888 solid;
|
||||||
color: #888;
|
color: #888;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.previous-revision, .next-revision {
|
.previous-revision, .next-revision {
|
||||||
|
@ -80,8 +85,8 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.new-comments .gravatar {
|
.new-comments .gravatar {
|
||||||
width: 75px;
|
width: 1.5em;
|
||||||
max-width: 75px;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.new-comments .vote {
|
.new-comments .vote {
|
||||||
|
|
|
@ -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 %}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue