when i try to upvote a post that i have upvoted previously the previous vote gets cancelled and score gets reduced.
same problem occurs when i try to downvote a post that i have previously downvoted. Is this the desired behavior?
what i did was to override the process_vote method and change the line which says:
score_delta = vote.cancel()
response_data['count'] = post.score + score_delta
response_data['status'] = 1 #this means "cancel"
to this:
before_vote = vote.vote
if (before_vote<0 and vote_direction == 'up') or (before_vote>0 and vote_direction == 'down'):
score_delta = vote.cancel()
response_data['count'] = post.score + score_delta
response_data['status'] = 1 #this means "cancel"
Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.
create your Q&A siteAsked: 2012-09-27 08:58:47 -0500
Seen: 53 times
Last updated: Sep 28 '12
Copyright Askbot, 2010-2011. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
Maybe it's not the best way, how would you suggest to handle this situation?
Evgeny ( 2012-09-27 12:10:50 -0500 )editdesired behavior should be that previous vote shall only be cancelled if my current vote and old vote are opposites otherwise it shouldn't.
to tackle this situation i had to override the process_vote method and added a check before vote.cancel() as mentioned below in my answer.
vikas.gulati ( 2012-09-27 12:27:21 -0500 )editNot sure if it's a big deal, this is the first time someone identified this as a problem in more than two years.
Evgeny ( 2012-09-27 16:45:16 -0500 )editWhat if you wanted to cancel your upvote without downvoting (or vice versa)?
todofixthis ( 2012-09-27 22:51:51 -0500 )edit