mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 17:56:38 +02:00
Add a lot of comments
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
# Copyright (C) 2023 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import TemplateView, DetailView
|
||||
|
||||
@ -8,6 +9,10 @@ from participation.models import Tournament
|
||||
|
||||
|
||||
class DisplayView(LoginRequiredMixin, TemplateView):
|
||||
"""
|
||||
This view is the main interface of the drawing system, which is working
|
||||
with Javascript and websockets.
|
||||
"""
|
||||
template_name = 'draw/index.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
@ -15,18 +20,21 @@ class DisplayView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
reg = self.request.user.registration
|
||||
if reg.is_admin:
|
||||
# Administrators can manage all tournaments
|
||||
tournaments = Tournament.objects.order_by('id').all()
|
||||
elif reg.is_volunteer:
|
||||
# A volunteer can see their tournaments
|
||||
tournaments = reg.interesting_tournaments
|
||||
else:
|
||||
# A participant can see its own tournament, or the final if necessary
|
||||
tournaments = [reg.team.participation.tournament]
|
||||
if reg.team.participation.final:
|
||||
tournaments.append(Tournament.final_tournament())
|
||||
|
||||
context['tournaments'] = tournaments
|
||||
# This will be useful for JavaScript data
|
||||
context['tournaments_simplified'] = [{'id': t.id, 'name': t.name} for t in tournaments]
|
||||
context['problems'] = settings.PROBLEMS
|
||||
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class DisplayContentView(LoginRequiredMixin, DetailView):
|
||||
model = Tournament
|
||||
template_name = 'draw/tournament_content.html'
|
||||
|
Reference in New Issue
Block a user