Return helpful/unhelpful votes from the Review model

This commit is contained in:
Koen Bolhuis 2018-10-09 21:16:13 +02:00
parent 4e59b1710a
commit 57ad0f20e0
1 changed files with 2 additions and 2 deletions

View File

@ -63,11 +63,11 @@ class Review(models.Model):
# Gets the total number of votes which marked this review as 'helpful'. # Gets the total number of votes which marked this review as 'helpful'.
def getHelpfulVoteCount(self): def getHelpfulVoteCount(self):
ReviewHelpfulVote.objects.filter(pk=self.pk, helpful=True).count() return ReviewHelpfulVote.objects.filter(pk=self.pk, helpful=True).count()
# Gets the total number of votes which marked this review as 'unhelpful'. # Gets the total number of votes which marked this review as 'unhelpful'.
def getUnhelpfulVoteCount(self): def getUnhelpfulVoteCount(self):
ReviewHelpfulVote.objects.filter(pk=self.pk, helpful=False).count() return ReviewHelpfulVote.objects.filter(pk=self.pk, helpful=False).count()
# A vote for a review as either positive or negative. # A vote for a review as either positive or negative.
class ReviewHelpfulVote(models.Model): class ReviewHelpfulVote(models.Model):