def _get_queryset(self): queryset = Submission.objects.all() use_straight_join(queryset) queryset = submission_related(queryset.order_by('-id')) if self.show_problem: queryset = queryset.prefetch_related(Prefetch('problem__translations', queryset=ProblemTranslation.objects.filter( language=self.request.LANGUAGE_CODE), to_attr='_trans')) if self.in_contest: queryset = queryset.filter(contest__participation__contest_id=self.contest.id) if self.contest.hide_scoreboard and self.contest.is_in_contest(self.request): queryset = queryset.filter(contest__participation__user=self.request.user.profile) else: queryset = queryset.select_related('contest__participation__contest') \ .defer('contest__participation__contest__description') # This is not technically correct since contest organizers *should* see these, but # the join would be far too messy if not self.request.user.has_perm('judge.see_private_contest'): queryset = queryset.exclude(contest__participation__contest__hide_scoreboard=True) if self.selected_languages: queryset = queryset.filter(language_id__in=Language.objects.filter(key__in=self.selected_languages)) if self.selected_statuses: queryset = queryset.filter(result__in=self.selected_statuses) return queryset
def get_queryset(self, request): queryset = Submission.objects.select_related('problem', 'user__user', 'language').only( 'problem__code', 'problem__name', 'user__user__username', 'language__name', 'time', 'memory', 'points', 'status', 'result' ) use_straight_join(queryset) if not request.user.has_perm('judge.edit_all_problem'): id = request.user.profile.id queryset = queryset.filter(Q(problem__authors__id=id) | Q(problem__curators__id=id)).distinct() return queryset
def _get_queryset(self): queryset = Submission.objects.all() use_straight_join(queryset) queryset = submission_related(queryset.order_by('-id')) if self.show_problem: queryset = queryset.prefetch_related(Prefetch('problem__translations', queryset=ProblemTranslation.objects.filter(language=self.request.LANGUAGE_CODE), to_attr='_trans')) if self.in_contest: return queryset.filter(contest__participation__contest_id=self.contest.id) return queryset
def _get_queryset(self): queryset = Submission.objects.all() use_straight_join(queryset) queryset = submission_related(queryset.order_by('-id')) if self.show_problem: queryset = queryset.prefetch_related( Prefetch('problem__translations', queryset=ProblemTranslation.objects.filter( language=self.request.LANGUAGE_CODE), to_attr='_trans')) if self.in_contest: queryset = queryset.filter(contest_object=self.contest) if not self.contest.can_see_full_scoreboard(self.request.user): queryset = queryset.filter(user=self.request.profile) else: queryset = queryset.select_related('contest_object').defer( 'contest_object__description') # This is not technically correct since contest organizers *should* see these, but # the join would be far too messy if not self.request.user.has_perm('judge.see_private_contest'): # Show submissions for any contest you can edit or visible scoreboard contest_queryset = Contest.objects.filter( Q(authors=self.request.profile) | Q(curators=self.request.profile) | Q(scoreboard_visibility=Contest.SCOREBOARD_VISIBLE) | Q(end_time__lt=timezone.now())).distinct() queryset = queryset.filter( Q(user=self.request.profile) | Q(contest_object__in=contest_queryset) | Q(contest_object__isnull=True)) if self.selected_languages: queryset = queryset.filter(language__in=Language.objects.filter( key__in=self.selected_languages)) if self.selected_statuses: queryset = queryset.filter(result__in=self.selected_statuses) return queryset