remotes/1693045480750635534/spooky-22
Aevann1 2022-02-07 14:38:45 +02:00
parent be13ba1810
commit 486023e7cb
4 changed files with 12 additions and 8 deletions

View File

@ -381,8 +381,9 @@ class Comment(Base):
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
curr = self.total_choice_voted(v)
if curr:
body += f'<input class="d-none" id="current-{self.id}" value={curr[0].comment_id}>'
if curr: curr = " value=" + str(curr[0].comment_id)
else: curr = ''
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
for c in self.choices:
body += f'''<div class="custom-control"><input name="choice" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''

View File

@ -394,8 +394,9 @@ class Submission(Base):
body += f'"> - <a href="/votes?link=t3_{c.id}"><span id="poll-{c.id}">{c.upvotes}</span> votes</a></span></label></div>'
curr = self.total_choice_voted(v)
if curr:
body += f'<input class="d-none" id="current-{self.id}" value={curr[0].comment_id}>'
if curr: curr = " value=" + str(curr[0].comment_id)
else: curr = ''
body += f'<input class="d-none" id="current-{self.id}"{curr}>'
for c in self.choices:
body += f'''<div class="custom-control"><input name="choice" autocomplete="off" class="custom-control-input" type="radio" id="{c.id}" onchange="choice_vote('{c.id}','{self.id}')"'''

View File

@ -15,8 +15,8 @@ class Vote(Base):
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
real = Column(Boolean, default=True)
user = relationship("User", lazy="subquery", viewonly=True)
post = relationship("Submission", lazy="subquery", viewonly=True)
user = relationship("User", viewonly=True)
post = relationship("Submission", viewonly=True)
def __init__(self, *args, **kwargs):
@ -56,8 +56,8 @@ class CommentVote(Base):
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
real = Column(Boolean, default=True)
user = relationship("User", lazy="subquery")
comment = relationship("Comment", lazy="subquery", viewonly=True)
user = relationship("User")
comment = relationship("Comment")
def __init__(self, *args, **kwargs):

View File

@ -259,6 +259,8 @@ def api_vote_choice(comment_id, v):
else: parent = comment.post
for vote in parent.total_choice_voted(v):
vote.comment.upvotes = g.db.query(CommentVote.id).filter_by(comment_id=vote.comment.id, vote_type=1).count() - 1
g.db.add(vote.comment)
g.db.delete(vote)
try: