From b4287b2477c3b2dba5f0618e6808937ea2a5da3c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 23 Sep 2021 19:28:30 +0200 Subject: [PATCH] fd --- files/classes/submission.py | 2 +- files/routes/admin.py | 5 +++-- files/routes/front.py | 4 ++-- files/routes/posts.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 8dc2355c8..7634c6499 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -46,7 +46,7 @@ class Submission(Base): deleted_utc = Column(Integer, default=0) distinguish_level = Column(Integer, default=0) created_str = Column(String(255)) - stickied = Column(Boolean, default=False) + stickied = Column(String) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) club = Column(Boolean, default=False) diff --git a/files/routes/admin.py b/files/routes/admin.py index 8801142e1..cd8e8fef8 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -971,7 +971,7 @@ def ban_post(post_id, v): post.is_banned = True post.is_approved = 0 - post.stickied = False + post.stickied = None post.is_pinned = False post.removed_by = v.id @@ -1066,7 +1066,8 @@ def api_sticky_post(post_id, v): post = g.db.query(Submission).options(lazyload('*')).filter_by(id=post_id).first() if post: - post.stickied = not (post.stickied) + if post.stickied: post.stickied = None + else: post.stickied = v.username g.db.add(post) ma=ModAction( diff --git a/files/routes/front.py b/files/routes/front.py index ce634503e..e6da1c623 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -131,7 +131,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' cutoff = now - 31536000 posts = posts.filter(Submission.created_utc >= cutoff) - posts = posts.filter_by(is_banned=False,stickied=False,private=False,deleted_utc = 0) + posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0) if v: posts = posts.filter(or_(Submission.processing == False, Submission.author_id == v.id)) @@ -198,7 +198,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts = posts[:25] - if page == 1: posts = g.db.query(Submission).options(lazyload('*')).filter_by(stickied=True).all() + posts + if page == 1: posts = g.db.query(Submission).options(lazyload('*')).filter(Submission.stickied != None).all() + posts if ids_only: posts = [x.id for x in posts] diff --git a/files/routes/posts.py b/files/routes/posts.py index 6e6f3e67c..5d77ab788 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1100,7 +1100,7 @@ def delete_post_pid(pid, v): post.deleted_utc = int(time.time()) post.is_pinned = False - post.stickied = False + post.stickied = None g.db.add(post)