From f81205a427c47ec284df63ccb8fbe33d01c6bcf4 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 11 Nov 2022 21:02:57 +0200 Subject: [PATCH] hide poll scores until the user votes --- files/assets/js/comments+submission_listing.js | 6 ++++++ files/classes/comment.py | 12 ++++++++++-- files/classes/submission.py | 12 ++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/files/assets/js/comments+submission_listing.js b/files/assets/js/comments+submission_listing.js index 6740f3332..d45cd70f7 100644 --- a/files/assets/js/comments+submission_listing.js +++ b/files/assets/js/comments+submission_listing.js @@ -77,6 +77,9 @@ function post(url) { }; function poll_vote_0(oid, parentid, kind) { + for(let el of document.getElementsByClassName('presult-'+parentid)) { + el.classList.remove('d-none'); + } const full_oid = kind + '-' + oid const type = document.getElementById(full_oid).checked; const scoretext = document.getElementById('score-' + full_oid); @@ -87,6 +90,9 @@ function poll_vote_0(oid, parentid, kind) { } function poll_vote_1(oid, parentid, kind) { + for(let el of document.getElementsByClassName('presult-'+parentid)) { + el.classList.remove('d-none'); + } const full_oid = kind + '-' + oid let curr = document.getElementById(`current-${kind}-${parentid}`) if (curr && curr.value) diff --git a/files/classes/comment.py b/files/classes/comment.py index 271f728f6..9e3955128 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -260,6 +260,13 @@ class Comment(Base): return data + @lazy + def total_poll_voted(self, v): + if v: + for o in self.options: + if o.voted(v): return True + return False + @lazy def realbody(self, v): if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id] or (self.parent_comment and v.id == self.parent_comment.author_id))): @@ -319,8 +326,9 @@ class Comment(Base): else: body += f''' onchange="poll_vote_no_v()"''' - body += f'''>''' + body += f'''>''' if not self.ghost and self.author.show_sig(v): body += f"
{self.author.sig_html}" diff --git a/files/classes/submission.py b/files/classes/submission.py index a1f2f65c6..eebfe9a22 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -277,6 +277,13 @@ class Submission(Base): if o.exclusive == 2 and o.voted(v): return True return False + @lazy + def total_poll_voted(self, v): + if v: + for o in self.options: + if o.voted(v): return True + return False + @lazy 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

" @@ -338,8 +345,9 @@ class Submission(Base): else: body += f''' onchange="poll_vote_no_v()"''' - body += f'''>''' + body += f'''>''' if not listing and not self.ghost and self.author.show_sig(v):