master
Aevann1 2022-02-18 11:19:58 +02:00
parent f0a53e8304
commit c3e91509fa
3 changed files with 20 additions and 19 deletions

View File

@ -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

View File

@ -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(

View File

@ -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:]