Ask Your Question
1

on trying to upvote again previous vote gets cancelled!

asked 2012-09-27 08:58:47 -0500

vikas.gulati gravatar image vikas.gulati
11 3

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?

delete close flag offensive retag edit

Comments

Maybe it's not the best way, how would you suggest to handle this situation?

Evgeny ( 2012-09-27 12:10:50 -0500 )edit

desired 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 )edit

Not 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 )edit

What if you wanted to cancel your upvote without downvoting (or vice versa)?

todofixthis ( 2012-09-27 22:51:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-09-27 12:30:48 -0500

vikas.gulati gravatar image vikas.gulati
11 3

updated 2012-09-28 08:46:11 -0500

todofixthis gravatar image todofixthis flag of Chile
1082 16 18 37
http://www.fiveyearsabroa...

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"
link publish delete flag offensive edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

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 site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-09-27 08:58:47 -0500

Seen: 53 times

Last updated: Sep 28 '12