def ratings_range(self): r = [{'rate': i + 1, 'active': self.ratings > i} for i in xrange(Rating.length())] return r
def user_votes_range(self, user): vote = self.user_votes(user) rate = vote.rate if vote else 0 r = [{'rate': i + 1, 'active': rate > i} for i in xrange(Rating.length())] return r