From 5aad7e09a6ba9adef26c4a8cc03d47c7453d9fab Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 26 Jun 2022 08:10:02 +0200 Subject: [PATCH] dont query polls on frontpage --- files/classes/submission.py | 78 +++++++++++-------------- files/templates/submission_listing.html | 8 +-- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index f9c11fc90..95ce45229 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -387,7 +387,7 @@ class Submission(Base): return url @lazy - def realbody(self, v): + def realbody(self, v, listing=False): if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"

{CC} ONLY

" body = self.body_html or "" @@ -407,43 +407,44 @@ class Submission(Base): self.upvotes += amount g.db.add(self) - for c in self.options: - body += f'
' + if not listing: + for c in self.options: + body += f'
' - if self.choices: - curr = self.total_choice_voted(v) - if curr: curr = " value=" + str(curr.comment_id) - else: curr = '' - body += f'' + if self.choices: + curr = self.total_choice_voted(v) + if curr: curr = " value=" + str(curr.comment_id) + else: curr = '' + body += f'' - for c in self.choices: - body += f'''
' + for c in self.choices: + body += f'''
' - for c in self.bet_options: - body += f'''
200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled " - body += f'''>" - if v and v.admin_level > 2: - body += f'''''' - body += "
" + for c in self.bet_options: + body += f'''
200) or self.total_bet_voted(v) or not v.can_gamble: body += " disabled " + body += f'''>" + if v and v.admin_level > 2: + body += f'''''' + body += "
" - if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))): - body += f"
{self.author.sig_html}" + if self.author.sig_html and (self.author_id == MOOSE_ID or (not self.ghost and not (v and v.sigs_disabled))): + body += f"
{self.author.sig_html}" return body @@ -503,13 +504,4 @@ class Submission(Base): @lazy def active_flags(self, v): - return len(self.flags(v)) - - - @lazy - def is_saved(self, v): - return g.db.query(SaveRelationship).filter_by(user_id=v.id, submission_id=self.id).one_or_none() - - @lazy - def is_subscribed(self, v): - return g.db.query(Subscription).filter_by(user_id=v.id, submission_id=self.id).one_or_none() \ No newline at end of file + return len(self.flags(v)) \ No newline at end of file diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index f3b7e4f46..0bccbfb71 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -218,7 +218,7 @@