django-vote icon indicating copy to clipboard operation
django-vote copied to clipboard

django-vote does not support down voting as README states

Open MurphyAdam opened this issue 4 years ago • 5 comments

I have implemented django-vote in one of my projects and I found an odd behaviour where a user could perform a 'downvote' to the same object over and over, and obj.votes.exists(user_id) would return false because the 'downvote' is not committed to the vote object but nevertheless is counted in num_vote_down.

If 5 users decided to 'downvote' an object, we will have num_vote_down equals 5, but the user_ids would still return an empty queryset and the exists method would return false for each users. This happens only regarding the down method.

Am I missing something? Thank you for your help!

MurphyAdam avatar Aug 03 '21 14:08 MurphyAdam

The down feature was added later, the document doesn't mention there is a new action parameter for both exists and the user_ids function, you can use the second parameter to get your expected result.

shellfly avatar Aug 04 '21 12:08 shellfly

Thank you for your response. I see, so in order to check whether a user has voted regardless of whether it was an upvote or downvote, I need to check both against obj.votes.exists(user_id, action=UP) and obj.votes.exists(user.id, action=DOWN), correct?

MurphyAdam avatar Aug 04 '21 15:08 MurphyAdam

If you would like, I could contribute to this project to have docs updates and a method that checks whether a user has a vote regardless of what it is.

MurphyAdam avatar Aug 04 '21 16:08 MurphyAdam

That will be great, any contribution is welcome

shellfly avatar Aug 05 '21 03:08 shellfly

Alright cool! Thanks for the help.

MurphyAdam avatar Aug 05 '21 11:08 MurphyAdam