fix queryset
This commit is contained in:
parent
e02675279d
commit
7680ba4bb0
3 changed files with 22 additions and 18 deletions
|
@ -164,8 +164,8 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
|||
queryset = self.object.comments
|
||||
context["replies"] = len(queryset.filter(parent=None))
|
||||
queryset = (
|
||||
queryset.filter(parent=None)[:10].select_related("author__user")
|
||||
.filter(hidden=False)
|
||||
queryset.filter(parent=None, hidden=False)[:10]
|
||||
.select_related("author__user")
|
||||
.defer("author__about")
|
||||
.annotate(revisions=Count("versions"))
|
||||
.annotate(count_replies=Count("replies"))
|
||||
|
@ -186,7 +186,6 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
|||
).exists()
|
||||
)
|
||||
context["comment_list"] = queryset
|
||||
# context["comment_count"] = len(queryset)
|
||||
context["vote_hide_threshold"] = settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD
|
||||
context["comment_root_id"] = 0
|
||||
context["offset"] = 10
|
||||
|
|
|
@ -137,9 +137,11 @@ def get_comment(request, limit=10):
|
|||
queryset = page_obj.comments
|
||||
replies = len(queryset.filter(parent=comment_obj))
|
||||
queryset = (
|
||||
queryset.filter(parent=comment_obj)[offset:offset+limit].select_related("author__user")
|
||||
queryset.filter(parent=comment_obj, hidden=False)[offset:offset+limit]
|
||||
.select_related("author__user")
|
||||
.defer("author__about")
|
||||
.annotate(revisions=Count("versions")).annotate(count_replies=Count("replies"))
|
||||
.annotate(revisions=Count("versions"))
|
||||
.annotate(count_replies=Count("replies"))
|
||||
)
|
||||
if request.user.is_authenticated:
|
||||
profile = request.profile
|
||||
|
|
|
@ -23,16 +23,16 @@
|
|||
title="{{ _('Please login to vote') }}" class="downvote-link fa fa-chevron-down fa-fw"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% with author=node.author, user=node.author.user %}
|
||||
<a href="{{ url('user_page', user.username) }}" class="user">
|
||||
<img src="{{ gravatar(author, 135) }}" class="gravatar">
|
||||
</a>
|
||||
{% endwith %}
|
||||
</div>
|
||||
<div class="detail">
|
||||
<div class="header">
|
||||
{{ link_user(node.author) }}
|
||||
{{ relative_time(node.time, abs=_('commented on {time}'), rel=_('commented {time}')) }}
|
||||
{% with author=node.author, user=node.author.user %}
|
||||
<a href="{{ url('user_page', user.username) }}" class="user comment-img">
|
||||
<img src="{{ gravatar(author, 135) }}" class="gravatar">
|
||||
</a>
|
||||
{% endwith %}
|
||||
{{ link_user(node.author) }},
|
||||
{{ relative_time(node.time, abs=_('{time}'), rel=_('{time}')) }}
|
||||
<span class="comment-spacer"></span>
|
||||
<span class="comment-operation">
|
||||
{% if node.revisions > 1 %}
|
||||
|
@ -107,9 +107,11 @@
|
|||
{% endif %}
|
||||
|
||||
{% if real_replies > 1 %}
|
||||
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ real_replies }} {{ _(' Replies ') }} </a>
|
||||
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ real_replies }} {{
|
||||
_(' Replies ') }} </a>
|
||||
{% elif real_replies %}
|
||||
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ real_replies }} {{ _(' Reply ') }} </a>
|
||||
<a href="javascript:comment_reply({{ node.id }}, {{ object.id }})" class="show_more_reply"> {{ real_replies }} {{
|
||||
_(' Reply ') }} </a>
|
||||
{% endif %}
|
||||
</li>
|
||||
<ul id="comment-{{ node.id }}-reply" class="reply-comment" hidden></ul>
|
||||
|
@ -117,5 +119,6 @@
|
|||
{% endfor %}
|
||||
|
||||
{% if replies - offset > 0 %}
|
||||
<a href="javascript:comment_show_more({{ comment_root_id }}, {{ object.id }}, {{ offset }} )" class="show_more_comment"> {{ replies - offset }} Replies More</a>
|
||||
<a href="javascript:comment_show_more({{ comment_root_id }}, {{ object.id }}, {{ offset }} )" class="show_more_comment">
|
||||
{{ replies - offset }} Replies More</a>
|
||||
{% endif %}
|
Loading…
Add table
Add a link
Reference in a new issue