Better final handle

This commit is contained in:
Yohann D'ANELLO 2020-05-20 15:47:45 +02:00
parent d3412f3963
commit 495f42e594
1 changed files with 21 additions and 9 deletions

View File

@ -105,6 +105,10 @@ class TournamentDetailView(DetailView):
context["title"] = _("Tournament of {name}").format(name=self.object.name) context["title"] = _("Tournament of {name}").format(name=self.object.name)
if self.object.final:
team_users = TFJMUser.objects.filter(team__selected_for_final=True)
valid_team_users = team_users
else:
team_users = TFJMUser.objects.filter( team_users = TFJMUser.objects.filter(
Q(team__tournament=self.object) Q(team__tournament=self.object)
| Q(organized_tournaments=self.object)).order_by('role') | Q(organized_tournaments=self.object)).order_by('role')
@ -403,6 +407,10 @@ 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:
if self.request.user in Tournament.get_final().organizers.all():
qs = qs.filter(Q(team__tournament__organizers=self.request.user) | Q(pools__juries=self.request.user)
| Q(final=True))
else:
qs = qs.filter(Q(team__tournament__organizers=self.request.user) | Q(pools__juries=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',).distinct() 'problem',).distinct()
@ -529,7 +537,11 @@ 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(Q(team__tournament__organizers=self.request.user) | Q(team__pools__juries=self.request.user)) if self.request.user in Tournament.get_final().organizers.all():
qs = qs.filter(Q(team__tournament__organizers=self.request.user) | Q(pools__juries=self.request.user)
| Q(final=True))
else:
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',
'round', 'source',).distinct() 'round', 'source',).distinct()