cxv
This commit is contained in:
parent
2921f52e3b
commit
2464775210
4 changed files with 12 additions and 8 deletions
|
@ -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}')"'''
|
||||
|
|
|
@ -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}')"'''
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue