Filter on other pages as well
This commit is contained in:
parent
420e3e1e8e
commit
f736d660b6
3 changed files with 15 additions and 7 deletions
|
@ -227,19 +227,21 @@ class Comment(Base):
|
|||
if self.parent_comment_id: return f"t3_{self.parent_comment_id}"
|
||||
elif self.parent_submission: return f"t2_{self.parent_submission}"
|
||||
|
||||
@property
|
||||
def replies(self):
|
||||
def replies(self, user):
|
||||
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]
|
||||
author_id = None
|
||||
if user:
|
||||
author_id = user.id
|
||||
if not self.parent_submission:
|
||||
return sorted((x for x in self.child_comments
|
||||
if x.author
|
||||
and x.filter_state not in ('filtered', 'removed')
|
||||
and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id)
|
||||
and not x.author.shadowbanned),
|
||||
key=lambda x: x.created_utc)
|
||||
return sorted((x for x in self.child_comments
|
||||
if x.author
|
||||
and not x.author.shadowbanned
|
||||
and x.filter_state not in ('filtered', 'removed')
|
||||
and (x.filter_state not in ('filtered', 'removed') or x.author_id == author_id)
|
||||
and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
|
||||
key=lambda x: x.realupvotes, reverse=True)
|
||||
|
||||
|
|
|
@ -286,6 +286,12 @@ def viewmore(v, pid, sort, offset):
|
|||
if not (v and v.shadowbanned) and not (v and v.admin_level > 2):
|
||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||
|
||||
if not v or v.admin_level < 2:
|
||||
filter_clause = (Comment.filter_state != 'filtered') & (Comment.filter_state != 'removed')
|
||||
if v:
|
||||
filter_clause = filter_clause | (Comment.author_id == v.id)
|
||||
comments = comments.filter(filter_clause)
|
||||
|
||||
comments=comments.join(
|
||||
votes,
|
||||
votes.c.comment_id == Comment.id,
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
{% if v and (v.shadowbanned or v.admin_level > 2) %}
|
||||
{% set replies=c.replies_ignoring_shadowbans %}
|
||||
{% else %}
|
||||
{% set replies=c.replies %}
|
||||
{% set replies=c.replies(v) %}
|
||||
{% endif %}
|
||||
|
||||
{% if (c.is_banned or c.deleted_utc or c.is_blocking) and not (v and v.admin_level > 1) and not (v and v.id==c.author_id) %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue