Working on hiding filtered comments
This commit is contained in:
parent
d1d7071304
commit
ba9689f017
3 changed files with 23 additions and 6 deletions
|
@ -231,15 +231,26 @@ class Comment(Base):
|
||||||
def replies(self):
|
def replies(self):
|
||||||
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]
|
if self.replies2 != None: return [x for x in self.replies2 if not x.author.shadowbanned]
|
||||||
if not self.parent_submission:
|
if not self.parent_submission:
|
||||||
return sorted((x for x in self.child_comments if x.author and not x.author.shadowbanned), key=lambda x: x.created_utc)
|
return sorted((x for x in self.child_comments
|
||||||
return sorted((x for x in self.child_comments if x.author and not x.author.shadowbanned and x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), key=lambda x: x.realupvotes, reverse=True)
|
if x.author
|
||||||
|
and x.filter_state not in ('filtered', 'removed')
|
||||||
|
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.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
|
||||||
|
key=lambda x: x.realupvotes, reverse=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def replies3(self):
|
def replies_ignoring_shadowbans(self):
|
||||||
if self.replies2 != None: return self.replies2
|
if self.replies2 != None: return self.replies2
|
||||||
if not self.parent_submission:
|
if not self.parent_submission:
|
||||||
return sorted(self.child_comments, key=lambda x: x.created_utc)
|
return sorted(self.child_comments, key=lambda x: x.created_utc)
|
||||||
return sorted((x for x in self.child_comments if x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), key=lambda x: x.realupvotes, reverse=True)
|
return sorted((x for x in self.child_comments
|
||||||
|
if x.author_id not in (AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)),
|
||||||
|
key=lambda x: x.realupvotes, reverse=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def replies2(self):
|
def replies2(self):
|
||||||
|
|
|
@ -148,7 +148,13 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
|
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level > 2):
|
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)
|
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.filter(Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))).join(
|
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID))).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
{% set score=ups-downs %}
|
{% set score=ups-downs %}
|
||||||
|
|
||||||
{% if v and (v.shadowbanned or v.admin_level > 2) %}
|
{% if v and (v.shadowbanned or v.admin_level > 2) %}
|
||||||
{% set replies=c.replies3 %}
|
{% set replies=c.replies_ignoring_shadowbans %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set replies=c.replies %}
|
{% set replies=c.replies %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue