forked from MarseyWorld/MarseyWorld
fix poll-voting
parent
8185340e15
commit
e7ce39bd80
|
@ -135,8 +135,8 @@ class Comment(Base):
|
|||
@lazy
|
||||
def total_choice_voted(self, v):
|
||||
if v:
|
||||
return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
|
||||
return False
|
||||
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
|
||||
return None
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -128,8 +128,8 @@ class Submission(Base):
|
|||
@lazy
|
||||
def total_choice_voted(self, v):
|
||||
if v and self.choices:
|
||||
return g.db.query(CommentVote.comment_id).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
|
||||
return False
|
||||
return g.db.query(CommentVote).filter(CommentVote.user_id == v.id, CommentVote.comment_id.in_([x.id for x in self.choices])).first()
|
||||
return None
|
||||
|
||||
@lazy
|
||||
def total_bet_voted(self, v):
|
||||
|
|
|
@ -278,7 +278,8 @@ def api_vote_choice(comment_id, v):
|
|||
if comment.parent_comment: parent = comment.parent_comment
|
||||
else: parent = comment.post
|
||||
|
||||
for vote in parent.total_choice_voted(v):
|
||||
vote = parent.total_choice_voted(v)
|
||||
if vote:
|
||||
vote.comment.upvotes = g.db.query(CommentVote).filter_by(comment_id=vote.comment.id, vote_type=1).count() - 1
|
||||
g.db.add(vote.comment)
|
||||
g.db.delete(vote)
|
||||
|
|
Loading…
Reference in New Issue