Final organizers can see more things

This commit is contained in:
Yohann D'ANELLO 2020-05-19 00:09:07 +02:00
parent 7c89aa62cc
commit d3412f3963
1 changed files with 4 additions and 1 deletions

View File

@ -13,7 +13,7 @@ from django.views import View
from django.views.generic import CreateView, UpdateView, DetailView, FormView
from django_tables2 import SingleTableView
from tournament.forms import TeamForm, JoinTeam
from tournament.models import Team
from tournament.models import Team, Tournament
from tournament.views import AdminMixin, TeamMixin, OrgaMixin
from .forms import SignUpForm, TFJMUserForm, AdminUserForm, CoachUserForm
@ -66,6 +66,8 @@ class UserDetailView(LoginRequiredMixin, DetailView):
if not request.user.admin \
and (self.object.team is not None and request.user not in self.object.team.tournament.organizers.all())\
and (self.object.team is not None and self.object.team.selected_for_final
and request.user not in Tournament.get_final().organizers.all())\
and self.request.user != self.object:
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)
@ -192,6 +194,7 @@ class DocumentView(LoginRequiredMixin, View):
if isinstance(doc, Solution) or isinstance(doc, Synthesis) or isinstance(doc, MotivationLetter):
grant = grant or doc.team == request.user.team or request.user in doc.team.tournament.organizers.all()
grant = grant or (doc.team.selected_for_final and request.user in Tournament.get_final().organizers.all())
if isinstance(doc, Synthesis) and request.user.organizes:
grant = True