|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
|
|
|
#coding:utf-8 |
|
|
|
|
|
|
|
|
|
|
|
from django.shortcuts import render, get_object_or_404 |
|
|
|
from django.shortcuts import render, get_object_or_404 |
|
|
|
from django.http import HttpResponse |
|
|
|
|
|
|
|
from .serializers import ClubSerializer, TournamentSerializer, ExpandedTournamentSerializer, UserSerializer, ChangePasswordSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamStateSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer |
|
|
|
from .serializers import ClubSerializer, TournamentSerializer, ExpandedTournamentSerializer, UserSerializer, ChangePasswordSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamStateSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer |
|
|
|
from .models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamState, TeamRegistration, PlayerRegistration |
|
|
|
from .models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamState, TeamRegistration, PlayerRegistration |
|
|
|
from .models import TeamCall |
|
|
|
from .models import TeamCall |
|
|
|
@ -10,21 +11,20 @@ from rest_framework.response import Response |
|
|
|
from rest_framework.decorators import api_view |
|
|
|
from rest_framework.decorators import api_view |
|
|
|
from rest_framework import status |
|
|
|
from rest_framework import status |
|
|
|
from rest_framework.generics import UpdateAPIView |
|
|
|
from rest_framework.generics import UpdateAPIView |
|
|
|
from django.template import loader |
|
|
|
|
|
|
|
from datetime import date |
|
|
|
from datetime import date |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: 1 app core (avec les models), 1 app web, 1 app API pour séparer les views |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
|
|
|
# Web UI |
|
|
|
|
|
|
|
## |
|
|
|
|
|
|
|
|
|
|
|
def index(request): |
|
|
|
def index(request): |
|
|
|
today = date.today() |
|
|
|
today = date.today() |
|
|
|
future_tournaments = Tournament.objects.filter(end_date__isnull=True, start_date__gt=today).order_by('start_date') |
|
|
|
future_tournaments = Tournament.objects.filter(end_date__isnull=True, start_date__gt=today).order_by('start_date') |
|
|
|
live_tournaments = Tournament.objects.filter(end_date__isnull=True, start_date__lte=today).order_by('start_date') |
|
|
|
live_tournaments = Tournament.objects.filter(end_date__isnull=True, start_date__lte=today).order_by('start_date') |
|
|
|
ended_tournaments = Tournament.objects.filter(end_date__isnull=False).order_by('start_date') |
|
|
|
ended_tournaments = Tournament.objects.filter(end_date__isnull=False).order_by('start_date') |
|
|
|
# template = loader.get_template('tournaments/tournaments.html') |
|
|
|
|
|
|
|
# context = { |
|
|
|
|
|
|
|
# 'future': future_tournaments, |
|
|
|
|
|
|
|
# 'live': live_tournaments, |
|
|
|
|
|
|
|
# 'ended': ended_tournaments, |
|
|
|
|
|
|
|
# } |
|
|
|
|
|
|
|
# return HttpResponse(template.render(context, request)) |
|
|
|
|
|
|
|
return render( |
|
|
|
return render( |
|
|
|
request, |
|
|
|
request, |
|
|
|
"tournaments/tournaments.html", |
|
|
|
"tournaments/tournaments.html", |
|
|
|
@ -38,31 +38,31 @@ def index(request): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tournament(request, tournament_id): |
|
|
|
def tournament(request, tournament_id): |
|
|
|
|
|
|
|
|
|
|
|
tournament = get_object_or_404(Tournament, pk=tournament_id) |
|
|
|
tournament = get_object_or_404(Tournament, pk=tournament_id) |
|
|
|
today = date.today() |
|
|
|
today = date.today() |
|
|
|
|
|
|
|
|
|
|
|
future_matches = Match.objects.filter(end_date__isnull=True, start_date__gt=today).order_by('start_date') |
|
|
|
future_matches = Match.objects.filter(end_date__isnull=True, start_date__gt=today).order_by('start_date') |
|
|
|
live_matches = Match.objects.filter(end_date__isnull=True, start_date__lte=today).order_by('start_date') |
|
|
|
live_matches = Match.objects.filter(end_date__isnull=True, start_date__lte=today).order_by('start_date') |
|
|
|
ended_matches = Match.objects.filter(end_date__isnull=False).order_by('start_date') |
|
|
|
ended_matches = Match.objects.filter(end_date__isnull=False).order_by('start_date') |
|
|
|
template = loader.get_template('tournaments/tournament.html') |
|
|
|
|
|
|
|
context = { |
|
|
|
context = { |
|
|
|
'future': future_matches, |
|
|
|
'future': future_matches, |
|
|
|
'live': live_matches, |
|
|
|
'live': live_matches, |
|
|
|
'ended': ended_matches, |
|
|
|
'ended': ended_matches, |
|
|
|
} |
|
|
|
} |
|
|
|
return HttpResponse(template.render(context, request)) |
|
|
|
return render(request, "tournaments/tournament.html", context) |
|
|
|
|
|
|
|
|
|
|
|
def tournament_planning(request, tournament_id): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tournament_planning(request, tournament_id): |
|
|
|
tournament = get_object_or_404(Tournament, pk=tournament_id) |
|
|
|
tournament = get_object_or_404(Tournament, pk=tournament_id) |
|
|
|
team_calls = tournament.team_calls() |
|
|
|
team_calls = tournament.team_calls() |
|
|
|
|
|
|
|
context = {'team_calls': team_calls} |
|
|
|
|
|
|
|
return render(request, "tournaments/planning.html", context) |
|
|
|
|
|
|
|
|
|
|
|
template = loader.get_template('tournaments/planning.html') |
|
|
|
|
|
|
|
context = { |
|
|
|
def tournament_stream(request, tournament_id): |
|
|
|
'team_calls': team_calls, |
|
|
|
tournament = get_object_or_404(Tournament, pk=tournament_id) |
|
|
|
} |
|
|
|
return render(request, "tournaments/tournament_stream.html", { |
|
|
|
return HttpResponse(template.render(context, request)) |
|
|
|
"tournament": tournament, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def index(request): |
|
|
|
# def index(request): |
|
|
|
@ -77,6 +77,11 @@ def tournament_planning(request, tournament_id): |
|
|
|
# } |
|
|
|
# } |
|
|
|
# return HttpResponse(template.render(context, request)) |
|
|
|
# return HttpResponse(template.render(context, request)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
|
|
|
# API |
|
|
|
|
|
|
|
## |
|
|
|
|
|
|
|
|
|
|
|
@api_view(['GET']) |
|
|
|
@api_view(['GET']) |
|
|
|
def user_by_token(request): |
|
|
|
def user_by_token(request): |
|
|
|
# return Response({"message": "Hello for today! See you tomorrow!"}) |
|
|
|
# return Response({"message": "Hello for today! See you tomorrow!"}) |
|
|
|
@ -143,3 +148,4 @@ class TeamRegistrationViewSet(viewsets.ModelViewSet): |
|
|
|
class PlayerRegistrationViewSet(viewsets.ModelViewSet): |
|
|
|
class PlayerRegistrationViewSet(viewsets.ModelViewSet): |
|
|
|
queryset = PlayerRegistration.objects.all() |
|
|
|
queryset = PlayerRegistration.objects.all() |
|
|
|
serializer_class = PlayerRegistrationSerializer |
|
|
|
serializer_class = PlayerRegistrationSerializer |
|
|
|
|
|
|
|
|
|
|
|
|