From 0c91650a1dd7927e860c80d0c2b5c74040d70aeb Mon Sep 17 00:00:00 2001 From: Aevann Date: Mon, 6 Mar 2023 00:50:06 +0200 Subject: [PATCH] remove jc insanity --- files/classes/comment.py | 5 +++-- files/routes/posts.py | 6 +++--- files/routes/users.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 498ed3f0c..6a6e73f70 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -86,9 +86,10 @@ class Comment(Base): def __repr__(self): return f"<{self.__class__.__name__}(id={self.id})>" + @property @lazy - def top_comment(self, db:scoped_session): - return db.get(Comment, self.top_comment_id) + def top_comment(self): + return g.db.get(Comment, self.top_comment_id) @property @lazy diff --git a/files/routes/posts.py b/files/routes/posts.py index bbe171881..0fced7792 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -153,9 +153,9 @@ def post_id(pid, anything=None, v=None, sub=None): pin.stickied_utc = None g.db.add(pin) elif pin.level > 1: - pinned2[pin.top_comment(g.db)] = '' - if pin.top_comment(g.db) in comments: - comments.remove(pin.top_comment(g.db)) + pinned2[pin.top_comment] = '' + if pin.top_comment in comments: + comments.remove(pin.top_comment) else: pinned2[pin] = '' diff --git a/files/routes/users.py b/files/routes/users.py index c3a83c581..de49e3b48 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -623,7 +623,7 @@ def messagereply(v:User): push_notif({user_id}, title, body, url) - top_comment = c.top_comment(g.db) + top_comment = c.top_comment if top_comment.sentto == MODMAIL_ID: admins = g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_MODMAIL'], User.id != v.id)