Skip to content

Issue 71: separated count votes functions #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions vote/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,20 @@ def all(self, user_id, action=UP):

return self.model.objects.filter(pk__in=list(object_ids))

def count(self, action=UP):
def count_up(self):
return self.through.votes_for(self.model,
self.instance, action).count()
self.instance, UP).count()

def count_down(self):
return self.through.votes_for(self.model,
self.instance, DOWN).count()

def count(self):
votes = {
"up": self.count_up(),
"down": self.count_down()
}
return votes

def user_ids(self, action=UP):
return self.through.votes_for(
Expand Down