From d89f2c266d3b9acffe44b4691fe4003c7c3cb7d8 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 6 May 2020 21:10:48 +0200 Subject: [PATCH] Juries have more rights --- apps/member/views.py | 3 +++ apps/tournament/views.py | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index 200d417..8494351 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -157,6 +157,9 @@ class DocumentView(LoginRequiredMixin, View): if isinstance(doc, Solution): for pool in doc.pools.all(): + if request.user in pool.juries: + grant = True + break if pool.round == 2 and timezone.now() < doc.tournament.date_solutions_2: continue if self.request.user.team in pool.teams.all(): diff --git a/apps/tournament/views.py b/apps/tournament/views.py index cdb2981..330dc06 100644 --- a/apps/tournament/views.py +++ b/apps/tournament/views.py @@ -255,9 +255,7 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView): return context def get_queryset(self): - qs = super().get_queryset() - if not self.request.user.admin: - qs = qs.filter(team=self.request.user.team) + qs = super().get_queryset().filter(team=self.request.user.team) return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', 'problem',) @@ -327,7 +325,7 @@ class SolutionsOrgaListView(OrgaMixin, SingleTableView): def get_queryset(self): qs = super().get_queryset() if not self.request.user.admin: - qs = qs.filter(team__tournament__organizers=self.request.user) + qs = qs.filter(Q(team__tournament__organizers=self.request.user) | Q(pools__juries=self.request.user)) return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', 'problem',) @@ -360,9 +358,7 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView): return super().post(request, *args, **kwargs) def get_queryset(self): - qs = super().get_queryset() - if not self.request.user.admin: - qs = qs.filter(team=self.request.user.team) + qs = super().get_queryset().filter(team=self.request.user.team) return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', 'round', 'source',) @@ -446,7 +442,7 @@ class SynthesesOrgaListView(OrgaMixin, SingleTableView): def get_queryset(self): qs = super().get_queryset() if not self.request.user.admin: - qs = qs.filter(team__tournament__organizers=self.request.user) + qs = qs.filter(Q(team__tournament__organizers=self.request.user) | Q(team__pools__juries=self.request.user)) return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', 'round', 'source',)