1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-22 23:18:28 +02:00

Only participants in a valid team can see the draw

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello
2023-04-10 10:02:37 +02:00
parent a240d7cad5
commit 3d7a39a593
4 changed files with 196 additions and 175 deletions

View File

@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}
{% block content %}
{# The navbar to select the tournament #}
@ -25,6 +26,10 @@
aria-labelledby="tab-{{ tournament.id }}" tabindex="0">
{% include "draw/tournament_content.html" with tournament=tournament %}
</div>
{% else %}
<div class="alert alert-warning">
{% trans "You don't participate to any tournament." %}
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -3,6 +3,8 @@
from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from participation.models import Tournament
@ -25,8 +27,11 @@ class DisplayView(LoginRequiredMixin, TemplateView):
# A volunteer can see their tournaments
tournaments = reg.interesting_tournaments
else:
if not reg.team:
raise PermissionDenied(_("You are not in a team."))
# A participant can see its own tournament, or the final if necessary
tournaments = [reg.team.participation.tournament]
tournaments = [reg.team.participation.tournament] if reg.team.participation.valid else []
if reg.team.participation.final:
tournaments.append(Tournament.final_tournament())