2023-03-22 11:26:27 +00:00
|
|
|
# Copyright (C) 2023 by Animath
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-03-22 14:24:15 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from django.db.models import Q
|
2023-03-22 11:26:27 +00:00
|
|
|
from django.views.generic import TemplateView
|
|
|
|
|
2023-03-22 14:24:15 +00:00
|
|
|
from participation.models import Tournament
|
2023-03-22 11:26:27 +00:00
|
|
|
|
2023-03-22 14:24:15 +00:00
|
|
|
|
|
|
|
class DisplayView(LoginRequiredMixin, TemplateView):
|
2023-03-22 11:26:27 +00:00
|
|
|
template_name = 'draw/index.html'
|
2023-03-22 14:24:15 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
reg = self.request.user.registration
|
|
|
|
if reg.is_admin:
|
|
|
|
tournaments = Tournament.objects.all()
|
|
|
|
elif reg.is_volunteer:
|
|
|
|
tournaments = reg.interesting_tournaments
|
|
|
|
else:
|
|
|
|
tournaments = [reg.team.participation.tournament]
|
|
|
|
context['tournaments'] = [{'id': t.id, 'name': t.name} for t in tournaments]
|
|
|
|
|
|
|
|
|
|
|
|
return context
|