From 100677c1bbaa559d9836847d1a90fa5434025f95 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 2 Jul 2022 01:18:41 +0200 Subject: [PATCH] fix 500 error --- files/routes/front.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/files/routes/front.py b/files/routes/front.py index 779e71025..f29a4b4f3 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -315,17 +315,20 @@ 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: if sub: pins = g.db.query(Submission).filter(Submission.sub == sub.name, Submission.hole_pinned != None) - elif v: + else: pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) - pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) - pins = pins.filter(Submission.author_id.notin_(v.userblocks)) + + if v: + pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks))) + for pin in pins: + if pin.stickied_utc and int(time.time()) > pin.stickied_utc: + pin.stickied = None + pin.stickied_utc = None + g.db.add(pin) + pins.remove(pin) - for pin in pins: - if pin.stickied_utc and int(time.time()) > pin.stickied_utc: - pin.stickied = None - pin.stickied_utc = None - g.db.add(pin) - pins.remove(pin) + + if v: pins = pins.filter(Submission.author_id.notin_(v.userblocks)) pins = pins.order_by(Submission.created_utc.desc()).all()