From 6b7ae51d61b58d431884a78e25f66024058cc7ed Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 19 Sep 2021 22:06:52 +0200 Subject: [PATCH] dfsfsd --- files/classes/badges.py | 3 ++- files/classes/clients.py | 4 ++-- files/classes/comment.py | 2 ++ files/classes/submission.py | 6 +++++- files/classes/user.py | 5 +++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/files/classes/badges.py b/files/classes/badges.py index 7d6ed01c2..4af64c338 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -88,6 +88,7 @@ class Badge(Base): 'icon_url':f"https://{app.config['SERVER_NAME']}{self.path}" } - property + @property + @lazy def json(self): return self.json_core diff --git a/files/classes/clients.py b/files/classes/clients.py index a98274706..78ed21e41 100644 --- a/files/classes/clients.py +++ b/files/classes/clients.py @@ -36,7 +36,7 @@ class OauthApp(Base): @lazy def permalink(self): return f"/admin/app/{self.id}" - + @lazy def idlist(self, page=1, **kwargs): posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) @@ -47,7 +47,7 @@ class OauthApp(Base): return [x[0] for x in posts.all()] - + @lazy def comments_idlist(self, page=1, **kwargs): posts = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) diff --git a/files/classes/comment.py b/files/classes/comment.py index 6f01f63be..eb69c5e38 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -327,6 +327,7 @@ class Comment(Base): self.comment_aux.body_html = x g.db.add(self.comment_aux) + @lazy def realbody(self, v): if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" body = self.comment_aux.body_html @@ -365,6 +366,7 @@ class Comment(Base): #def award_count(self): #return len(self.awards) + @lazy def collapse_for_user(self, v): if self.over_18 and not (v and v.over_18) and not self.post.over_18: diff --git a/files/classes/submission.py b/files/classes/submission.py index a92706c7e..8f16cde1b 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -209,6 +209,7 @@ class Submission(Base): return f"/post/{self.id}/{output}" + @lazy def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None): # check for banned @@ -282,7 +283,7 @@ class Submission(Base): else: return f"https://{site}/assets/images/default_thumb_link.webp" @property - + @lazy def json_raw(self): flags = {} for f in self.flags: flags[f.user.username] = f.reason @@ -383,6 +384,7 @@ class Submission(Base): self.submission_aux.url = x g.db.add(self.submission_aux) + @lazy def realurl(self, v): if v and v.agendaposter and random.randint(1, 10) < 4: return 'https://secure.actblue.com/donate/ms_blm_homepage_2019' @@ -416,6 +418,7 @@ class Submission(Base): self.submission_aux.body_html = x g.db.add(self.submission_aux) + @lazy def realbody(self, v): if self.club and not (v and v.paid_dues): return "COUNTRY CLUB ONLY" body = self.submission_aux.body_html @@ -437,6 +440,7 @@ class Submission(Base): self.submission_aux.title_html = x g.db.add(self.submission_aux) + @lazy def realtitle(self, v): if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY' elif self.title_html: title = self.title_html diff --git a/files/classes/user.py b/files/classes/user.py index 1566b6771..965aac7fd 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -417,6 +417,7 @@ class User(Base): return output + @lazy def alts_threaded(self, db): subq = db.query(Alt).filter( @@ -531,6 +532,7 @@ class User(Base): g.db.add(self) + def unban(self): self.is_banned = 0 @@ -562,10 +564,12 @@ class User(Base): return [x for x in self._applications.order_by( OauthApp.id.asc()).all()] + @lazy def subscribed_idlist(self, page=1): posts = g.db.query(Subscription.submission_id).options(lazyload('*')).filter_by(user_id=self.id).all() return [x[0] for x in posts] + @lazy def saved_idlist(self, page=1): posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, @@ -592,6 +596,7 @@ class User(Base): return [x[0] for x in posts.offset(25 * (page - 1)).limit(26).all()] + @lazy def saved_comment_idlist(self, page=1): comments = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0)