fix 500 error

master
Aevann1 2022-07-02 01:18:41 +02:00
parent 9f124e2c8d
commit 100677c1bb
1 changed files with 12 additions and 9 deletions

View File

@ -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 (sort == "hot" or (v and v.id == Q_ID)) and page == 1 and ccmode == "false" and not gt and not lt:
if sub: if sub:
pins = g.db.query(Submission).filter(Submission.sub == sub.name, Submission.hole_pinned != None) 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 = 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))
for pin in pins: if v:
if pin.stickied_utc and int(time.time()) > pin.stickied_utc: pins = pins.filter(or_(Submission.sub == None, Submission.sub.notin_(v.all_blocks)))
pin.stickied = None for pin in pins:
pin.stickied_utc = None if pin.stickied_utc and int(time.time()) > pin.stickied_utc:
g.db.add(pin) pin.stickied = None
pins.remove(pin) 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() pins = pins.order_by(Submission.created_utc.desc()).all()