1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 05:42:23 +00:00

Juries have more rights

This commit is contained in:
Yohann D'ANELLO 2020-05-06 21:10:48 +02:00
parent 72519c3d30
commit d89f2c266d
2 changed files with 7 additions and 8 deletions

View File

@ -157,6 +157,9 @@ class DocumentView(LoginRequiredMixin, View):
if isinstance(doc, Solution): if isinstance(doc, Solution):
for pool in doc.pools.all(): 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: if pool.round == 2 and timezone.now() < doc.tournament.date_solutions_2:
continue continue
if self.request.user.team in pool.teams.all(): if self.request.user.team in pool.teams.all():

View File

@ -255,9 +255,7 @@ class SolutionsView(TeamMixin, BaseFormView, SingleTableView):
return context return context
def get_queryset(self): def get_queryset(self):
qs = super().get_queryset() qs = super().get_queryset().filter(team=self.request.user.team)
if not self.request.user.admin:
qs = qs.filter(team=self.request.user.team)
return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram',
'problem',) 'problem',)
@ -327,7 +325,7 @@ class SolutionsOrgaListView(OrgaMixin, SingleTableView):
def get_queryset(self): def get_queryset(self):
qs = super().get_queryset() qs = super().get_queryset()
if not self.request.user.admin: 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', return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram',
'problem',) 'problem',)
@ -360,9 +358,7 @@ class SynthesesView(TeamMixin, BaseFormView, SingleTableView):
return super().post(request, *args, **kwargs) return super().post(request, *args, **kwargs)
def get_queryset(self): def get_queryset(self):
qs = super().get_queryset() qs = super().get_queryset().filter(team=self.request.user.team)
if not self.request.user.admin:
qs = qs.filter(team=self.request.user.team)
return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram', return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram',
'round', 'source',) 'round', 'source',)
@ -446,7 +442,7 @@ class SynthesesOrgaListView(OrgaMixin, SingleTableView):
def get_queryset(self): def get_queryset(self):
qs = super().get_queryset() qs = super().get_queryset()
if not self.request.user.admin: 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', return qs.order_by('final', 'team__tournament__date_start', 'team__tournament__name', 'team__trigram',
'round', 'source',) 'round', 'source',)