def get_context_data(self, **kwargs): context = super(Lecturer, self).get_context_data(**kwargs) # Quotes / QuoteVotes context['quotes'] = helpers.extend_quotes_with_votes( self.object.Quote.all(), self.request.user.pk) # Ratings ratings = models.LecturerRating.objects.filter( lecturer=self.get_object(), user=self.request.user) ratings_dict = dict([(r.category, r.rating) for r in ratings]) for cat in ['d', 'm', 'f']: context['rating_%c' % cat] = ratings_dict.get(cat) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # Quotes / QuoteVotes context["quotes"] = helpers.extend_quotes_with_votes( self.object.Quote.all(), self.request.user.pk) # Ratings ratings = models.LecturerRating.objects.filter( lecturer=self.get_object(), user=self.request.user) ratings_dict = {r.category: r.rating for r in ratings} for cat in ["d", "m", "f"]: context["rating_%c" % cat] = ratings_dict.get(cat) return context
def get_context_data(self, **kwargs): context = super(Lecturer, self).get_context_data(**kwargs) # Quotes / QuoteVotes context['quotes'] = helpers.extend_quotes_with_votes( self.object.Quote.all(), self.request.user.pk ) # Ratings ratings = models.LecturerRating.objects.filter( lecturer=self.get_object(), user=self.request.user) ratings_dict = dict([(r.category, r.rating) for r in ratings]) for cat in ['d', 'm', 'f']: context['rating_%c' % cat] = ratings_dict.get(cat) return context
def get_queryset(self): return helpers.extend_quotes_with_votes(models.Quote.objects.all(), self.request.user.pk)
def get_queryset(self): return helpers.extend_quotes_with_votes( models.Quote.objects.all(), self.request.user.pk )