diff --git a/judge/views/problem.py b/judge/views/problem.py index 76c118c..dcd474c 100644 --- a/judge/views/problem.py +++ b/judge/views/problem.py @@ -395,6 +395,11 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView queryset = queryset.filter(points__gte=self.point_start) if self.point_end is not None: queryset = queryset.filter(points__lte=self.point_end) + if self.show_editorial: + queryset = queryset.annotate( + has_public_editorial=Sum(Case(When(solution__is_public=True, then=1), + default=0, output_field=IntegerField()))) + return queryset.distinct() def get_queryset(self): @@ -410,11 +415,6 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView context['full_text'] = 0 if self.in_contest else int(self.full_text) context['show_editorial'] = 0 if self.in_contest else int(self.show_editorial) - if (context['show_editorial']): - context['object_list'] = context['object_list'] \ - .annotate(has_public_editorial=Sum(Case(When(solution__is_public=True, then=1), - default=0, output_field=IntegerField()))) - context['category'] = self.category context['categories'] = ProblemGroup.objects.all() if self.show_types: