This commit is contained in:
Aevann1 2021-09-19 22:06:52 +02:00
parent 5fae115060
commit 6b7ae51d61
5 changed files with 16 additions and 4 deletions

View file

@ -88,6 +88,7 @@ class Badge(Base):
'icon_url':f"https://{app.config['SERVER_NAME']}{self.path}" 'icon_url':f"https://{app.config['SERVER_NAME']}{self.path}"
} }
property @property
@lazy
def json(self): def json(self):
return self.json_core return self.json_core

View file

@ -36,7 +36,7 @@ class OauthApp(Base):
@lazy @lazy
def permalink(self): return f"/admin/app/{self.id}" def permalink(self): return f"/admin/app/{self.id}"
@lazy
def idlist(self, page=1, **kwargs): def idlist(self, page=1, **kwargs):
posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) 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()] return [x[0] for x in posts.all()]
@lazy
def comments_idlist(self, page=1, **kwargs): def comments_idlist(self, page=1, **kwargs):
posts = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id) posts = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(app_id=self.id)

View file

@ -327,6 +327,7 @@ class Comment(Base):
self.comment_aux.body_html = x self.comment_aux.body_html = x
g.db.add(self.comment_aux) g.db.add(self.comment_aux)
@lazy
def realbody(self, v): def realbody(self, v):
if self.post and self.post.club and not (v and v.paid_dues): return "<p>COUNTRY CLUB ONLY</p>" if self.post and self.post.club and not (v and v.paid_dues): return "<p>COUNTRY CLUB ONLY</p>"
body = self.comment_aux.body_html body = self.comment_aux.body_html
@ -365,6 +366,7 @@ class Comment(Base):
#def award_count(self): #def award_count(self):
#return len(self.awards) #return len(self.awards)
@lazy
def collapse_for_user(self, v): def collapse_for_user(self, v):
if self.over_18 and not (v and v.over_18) and not self.post.over_18: if self.over_18 and not (v and v.over_18) and not self.post.over_18:

View file

@ -209,6 +209,7 @@ class Submission(Base):
return f"/post/{self.id}/{output}" return f"/post/{self.id}/{output}"
@lazy
def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None): def rendered_page(self, sort=None, last_view_utc=None, comment=None, comment_info=None, v=None):
# check for banned # check for banned
@ -282,7 +283,7 @@ class Submission(Base):
else: return f"https://{site}/assets/images/default_thumb_link.webp" else: return f"https://{site}/assets/images/default_thumb_link.webp"
@property @property
@lazy
def json_raw(self): def json_raw(self):
flags = {} flags = {}
for f in self.flags: flags[f.user.username] = f.reason for f in self.flags: flags[f.user.username] = f.reason
@ -383,6 +384,7 @@ class Submission(Base):
self.submission_aux.url = x self.submission_aux.url = x
g.db.add(self.submission_aux) g.db.add(self.submission_aux)
@lazy
def realurl(self, v): def realurl(self, v):
if v and v.agendaposter and random.randint(1, 10) < 4: if v and v.agendaposter and random.randint(1, 10) < 4:
return 'https://secure.actblue.com/donate/ms_blm_homepage_2019' return 'https://secure.actblue.com/donate/ms_blm_homepage_2019'
@ -416,6 +418,7 @@ class Submission(Base):
self.submission_aux.body_html = x self.submission_aux.body_html = x
g.db.add(self.submission_aux) g.db.add(self.submission_aux)
@lazy
def realbody(self, v): def realbody(self, v):
if self.club and not (v and v.paid_dues): return "COUNTRY CLUB ONLY" if self.club and not (v and v.paid_dues): return "COUNTRY CLUB ONLY"
body = self.submission_aux.body_html body = self.submission_aux.body_html
@ -437,6 +440,7 @@ class Submission(Base):
self.submission_aux.title_html = x self.submission_aux.title_html = x
g.db.add(self.submission_aux) g.db.add(self.submission_aux)
@lazy
def realtitle(self, v): 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' 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 elif self.title_html: title = self.title_html

View file

@ -417,6 +417,7 @@ class User(Base):
return output return output
@lazy
def alts_threaded(self, db): def alts_threaded(self, db):
subq = db.query(Alt).filter( subq = db.query(Alt).filter(
@ -531,6 +532,7 @@ class User(Base):
g.db.add(self) g.db.add(self)
def unban(self): def unban(self):
self.is_banned = 0 self.is_banned = 0
@ -562,10 +564,12 @@ class User(Base):
return [x for x in self._applications.order_by( return [x for x in self._applications.order_by(
OauthApp.id.asc()).all()] OauthApp.id.asc()).all()]
@lazy
def subscribed_idlist(self, page=1): def subscribed_idlist(self, page=1):
posts = g.db.query(Subscription.submission_id).options(lazyload('*')).filter_by(user_id=self.id).all() posts = g.db.query(Subscription.submission_id).options(lazyload('*')).filter_by(user_id=self.id).all()
return [x[0] for x in posts] return [x[0] for x in posts]
@lazy
def saved_idlist(self, page=1): def saved_idlist(self, page=1):
posts = g.db.query(Submission.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, 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()] return [x[0] for x in posts.offset(25 * (page - 1)).limit(26).all()]
@lazy
def saved_comment_idlist(self, page=1): 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) comments = g.db.query(Comment.id).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=False, deleted_utc=0)