From c3e91509fa5669adcabf31847d60a123fe503c59 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 18 Feb 2022 11:19:58 +0200 Subject: [PATCH] xvc --- files/classes/comment.py | 2 +- files/routes/front.py | 21 +++++++++++---------- files/routes/posts.py | 16 ++++++++-------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 13702718f..d06c06bc6 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -428,7 +428,7 @@ class Comment(Base): if self.is_banned: return True - if path.startswith('/post') and (self.slots_result or self.blackjack_result) and (not self.body or len(self.body) <= 50) and self.level > 1: return True + if path.startswith('/post') and (self.slots_result or self.blackjack_result or self.wordle_result) and (not self.body or len(self.body) <= 50) and self.level > 1: return True if v and v.filter_words and self.body and any(x in self.body for x in v.filter_words): return True diff --git a/files/routes/front.py b/files/routes/front.py index 86acd34b6..de26e9988 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -270,7 +270,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if sub: posts = posts.filter_by(sub=sub.name) elif SITE != 'devrama.xyz': - elif SITE_NAME == '2Much4You': posts = posts.filter(Submission.sub.in_(toomuch_subs)) + if SITE_NAME == '2Much4You': posts = posts.filter(Submission.sub.in_(toomuch_subs)) elif SITE_NAME == 'Ruqqus': posts = posts.filter(Submission.sub != None) if v and v.all_blocks: posts = posts.filter(Submission.sub.notin_(v.all_blocks)) @@ -350,13 +350,14 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false" if (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false" and not gt and not lt: pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) if sub: pins = pins.filter_by(sub=sub.name) - elif SITE_NAME == '2Much4You': pins = pins.filter(Submission.sub.in_(toomuch_subs)) - elif SITE_NAME == 'Ruqqus': - pins = pins.filter(Submission.sub != None) - if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) - elif SITE_NAME == 'PCM': - if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) - else: pins = pins.filter_by(sub=None) + elif SITE != 'devrama.xyz': + if SITE_NAME == '2Much4You': pins = pins.filter(Submission.sub.in_(toomuch_subs)) + elif SITE_NAME == 'Ruqqus': + pins = pins.filter(Submission.sub != None) + if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) + elif SITE_NAME == 'PCM': + if v and v.all_blocks: pins = pins.filter(Submission.sub.notin_(v.all_blocks)) + else: pins = pins.filter_by(sub=None) if v and v.admin_level == 0: blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()] @@ -474,9 +475,9 @@ def random_post(v): @cache.memoize(timeout=86400) def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"): - cc_idlist = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()] + cc_or_private = [x[0] for x in g.db.query(Submission.id).filter(or_(Submission.club == True, Submission.private == True)).all()] - comments = g.db.query(Comment.id).filter(Comment.parent_submission != None, Comment.parent_submission.notin_(cc_idlist)) + comments = g.db.query(Comment.id).filter(Comment.parent_submission != None, Comment.parent_submission.notin_(cc_or_private)) if v and v.admin_level <= 3: blocking = [x[0] for x in g.db.query( diff --git a/files/routes/posts.py b/files/routes/posts.py index e923af7b2..8b9e19c1b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -216,8 +216,8 @@ def post_id(pid, anything=None, v=None, sub=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 50)).all()] - second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 50).all()] + first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None, Comment.wordle_result == None), func.length(Comment.body) > 50)).all()] + second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body) <= 50).all()] comments = first + second else: pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all() @@ -235,8 +235,8 @@ def post_id(pid, anything=None, v=None, sub=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 50)).all() - second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 50).all() + first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None, Comment.wordle_result == None), func.length(Comment.body) > 50)).all() + second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body) <= 50).all() comments = first + second offset = 0 @@ -344,8 +344,8 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 50)).all()] - second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 50).all()] + first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None, Comment.wordle_result == None), func.length(Comment.body) > 50)).all()] + second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body) <= 50).all()] comments = first + second else: comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID, AUTOCHOICE_ID)), Comment.level == 1, Comment.is_pinned == None, Comment.id.notin_(ids)) @@ -361,8 +361,8 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 50)).all() - second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 50).all() + first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None, Comment.wordle_result == None), func.length(Comment.body) > 50)).all() + second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body) <= 50).all() comments = first + second comments = comments[offset:]