def score(self) -> float: dummies = RatingDummy.dummies_for( self, ("Semester", "Finals", "Interesting")).values_list("id", flat=True) ratings = Rating.objects.filter( Q(object_id__in=dummies) & Q(content_type__model="ratingdummy") & ~Q(count=0)) if not ratings.exists(): return 0 return sum(ratings.values_list("average", flat=True)) / len(ratings)
def interesting_rating(self) -> RatingDummy: return RatingDummy.dummy_for(self, "Interesting")
def finals_rating(self) -> RatingDummy: return RatingDummy.dummy_for(self, "Finals")
def semester_rating(self) -> RatingDummy: return RatingDummy.dummy_for(self, "Semester")