mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-09 12:50:20 +02:00
Teams can request a validation
This commit is contained in:
@ -90,12 +90,22 @@ class MyTeamDetailView(LoginRequiredMixin, RedirectView):
|
||||
class TeamDetailView(LoginRequiredMixin, DetailView):
|
||||
model = Team
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
def get(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
if user.registration.is_admin or user.registration.participates and user.registration.team.pk == kwargs["pk"]:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
return super().get(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
team = self.object
|
||||
context["can_validate"] = team.students.count() >= 3 and \
|
||||
all(r.photo_authorization for r in team.students.all()) and \
|
||||
team.participation.problem
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class TeamUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Team
|
||||
@ -148,7 +158,7 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView):
|
||||
_("Photo authorization of {student}.{ext}").format(student=str(student), ext=ext))
|
||||
zf.close()
|
||||
response = HttpResponse(content_type="application/zip")
|
||||
response["Content-Disposition"] = "attachment; filename=\"{filename}\""\
|
||||
response["Content-Disposition"] = "attachment; filename=\"{filename}\"" \
|
||||
.format(filename=_("Photo authorizations of team {trigram}.zip").format(trigram=team.trigram))
|
||||
response.write(output.getvalue())
|
||||
return response
|
||||
@ -172,7 +182,7 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
|
||||
user = request.user
|
||||
if not self.get_object().valid:
|
||||
raise PermissionDenied(_("The team is not validated yet."))
|
||||
if user.registration.is_admin or user.registration.participates\
|
||||
if user.registration.is_admin or user.registration.participates \
|
||||
and user.registration.team.participation.pk == kwargs["pk"]:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
@ -185,7 +195,7 @@ class UploadVideoView(LoginRequiredMixin, UpdateView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
if user.registration.is_admin or user.registration.participates\
|
||||
if user.registration.is_admin or user.registration.participates \
|
||||
and user.registration.team.participation.pk == self.get_object().participation.pk:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
Reference in New Issue
Block a user