Adds broadcasted pages for group stages and summons

clubs
Laurent 2 years ago
parent ae968fcf46
commit 09e3de8f11
  1. 8
      static/tournaments/css/style.css
  2. 43
      tournaments/models/group_stage.py
  3. 20
      tournaments/models/team_registration.py
  4. 21
      tournaments/models/tournament.py
  5. 8
      tournaments/static/tournaments/css/style.css
  6. 44
      tournaments/templates/tournaments/base.html
  7. 22
      tournaments/templates/tournaments/broadcast.html
  8. 54
      tournaments/templates/tournaments/broadcast_base.html
  9. 131
      tournaments/templates/tournaments/broadcasted_group_stages.html
  10. 16
      tournaments/templates/tournaments/broadcasted_matches.html
  11. 70
      tournaments/templates/tournaments/broadcasted_summons.html
  12. 4
      tournaments/templates/tournaments/group_stage_cell.html
  13. 64
      tournaments/templates/tournaments/summons.html
  14. 8
      tournaments/urls.py
  15. 31
      tournaments/views.py

@ -79,10 +79,6 @@ a:hover {
} }
} }
.beige {
color: #fff7ed;
}
.mybox { .mybox {
color: #707070; color: #707070;
padding: 8px 12px; padding: 8px 12px;
@ -115,6 +111,10 @@ tr {
/* height: 40px; */ /* height: 40px; */
} }
.beige {
color: red;
}
.topblock { .topblock {
margin-top: 20px; margin-top: 20px;
} }

@ -2,6 +2,8 @@ from django.db import models
from . import Tournament, FederalMatchCategory from . import Tournament, FederalMatchCategory
import uuid import uuid
from ..utils.extensions import format_seconds from ..utils.extensions import format_seconds
from datetime import datetime, timedelta
from django.utils import timezone
class GroupStage(models.Model): class GroupStage(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
@ -21,7 +23,7 @@ class GroupStage(models.Model):
def matches_for_registration(self, player_registration): def matches_for_registration(self, player_registration):
team_scores = TeamScore.objects.filter(player_registrations=player_registration) team_scores = TeamScore.objects.filter(player_registrations=player_registration)
return map(lambda ts: ts.match, team_scores) return [ts.match for ts in team_scores] # map(lambda ts: ts.match, team_scores)
def live_group_stages(self): def live_group_stages(self):
lgs = LiveGroupStage(self.name()) lgs = LiveGroupStage(self.name())
@ -67,7 +69,8 @@ class GroupStage(models.Model):
team1.diff = total1 - total2 team1.diff = total1 - total2
team2.diff = total2 - total1 team2.diff = total2 - total1
for team in gs_teams.values(): teams = sorted(gs_teams.values(), key=lambda t: t.position)
for team in teams:
lgs.add_team(team) lgs.add_team(team)
return lgs return lgs
@ -98,9 +101,29 @@ class LiveGroupStage:
else: else:
return "--" return "--"
def to_dict(self):
return {
"title": self.title,
"teams": [team.to_dict() for team in self.teams],
"duration": self.formatted_duration()
}
def lean(self):
leanteams = []
for team in self.teams:
leanteams.append(team.lean())
return LeanGroupStage(self.title, [], self.formatted_duration())
class LeanGroupStage:
def __init__(self, title, teams, duration):
self.title = title
self.teams = teams
self.duration = duration
class GroupStageTeam: class GroupStageTeam:
def __init__(self, team_registration): def __init__(self, team_registration):
self.names = team_registration.team_names() self.names = team_registration.team_names()
self.position = team_registration.group_stage_position
self.wins = 0 self.wins = 0
self.losses = 0 self.losses = 0
self.diff = 0 self.diff = 0
@ -113,3 +136,19 @@ class GroupStageTeam:
return f"+{self.diff}" return f"+{self.diff}"
else: else:
return f"{self.diff}" return f"{self.diff}"
def to_dict(self):
return {
"names": self.names,
"win_loss": self.wins_losses(),
"diff": self.formatted_diff()
}
def lean(self):
return LeanTeam(self.names, self.wins_losses(), self.formatted_diff())
class LeanTeam:
def __init__(self, names, winloss, diff):
self.names = names
self.winloss = winloss
self.diff = diff

@ -24,10 +24,10 @@ class TeamRegistration(models.Model):
if self.name: if self.name:
return [self.name] return [self.name]
else: else:
return map(lambda pr: pr.name(), self.playerregistration_set.all()) return [pr.name() for pr in self.playerregistration_set.all()]
def player_names(self): def player_names(self):
names = map(lambda pr: pr.name(), self.playerregistration_set.all()) names = [pr.name() for pr in self.playerregistration_set.all()]
str = " - ".join(names) str = " - ".join(names)
if len(str) > 0: if len(str) > 0:
return str return str
@ -43,20 +43,6 @@ class TeamRegistration(models.Model):
else: else:
return all_matches[0] return all_matches[0]
# match = self.first_match(False)
# if match:
# return match
# else:
# return self.first_match(True)
# def first_match(self, completed):
# q_base = Q(team_scores__team_registration==self)
# q = Q(end_date__isnull=not completed, start_date__isnull=False)
# q_round = Q(round__tournament=self.tournament)
# q_group_stage = Q(group_stage__tournament=self.tournament)
# matches = Match.objects.filter(q_base, q, q_round | q_group_stage).order_by('start_date')
# return matches[0]
def next_stage(self): def next_stage(self):
matches = map(lambda ts: ts.match, self.teamscore_set.all()) matches = map(lambda ts: ts.match, self.teamscore_set.all())
matches = [m for m in matches if m.group_stage is None] matches = [m for m in matches if m.group_stage is None]
@ -64,7 +50,7 @@ class TeamRegistration(models.Model):
# matches = self.teamscore_set # matches = self.teamscore_set
# matches = Match.objects.filter(group_stage__isnull=True, team_scores__player_registrations__id=self.id).order_by('round__index') # matches = Match.objects.filter(group_stage__isnull=True, team_scores__player_registrations__id=self.id).order_by('round__index')
print(f"matches = {len(matches)}") # print(f"matches = {len(matches)}")
if matches: if matches:
return matches[0].round.name() return matches[0].round.name()
elif self.group_stage: elif self.group_stage:

@ -1,6 +1,7 @@
from django.db import models from django.db import models
from . import Event, CustomUser, FederalMatchCategory, FederalCategory, FederalLevelCategory, FederalAgeCategory from . import Event, CustomUser, FederalMatchCategory, FederalCategory, FederalLevelCategory, FederalAgeCategory
import uuid import uuid
from django.utils import timezone, formats
class Tournament(models.Model): class Tournament(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
@ -79,16 +80,30 @@ class Tournament(models.Model):
# matches = [m for m in matches if len(m.team_scores.all()) > 0] # matches = [m for m in matches if len(m.team_scores.all()) > 0]
matches.sort(key=lambda m: m.order) matches.sort(key=lambda m: m.order)
return map(lambda match: match.live_match(), matches) return [match.live_match() for match in matches]
# return map(lambda match: match.live_match(), matches)
def live_group_stages(self): def live_group_stages(self):
return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all()) return [gs.live_group_stages() for gs in self.groupstage_set.all()]
# return map(lambda gs: gs.live_group_stages(), self.groupstage_set.all())
class TeamSummon: class TeamSummon:
def __init__(self, names, date, weight, stage, image): def __init__(self, names, date, weight, stage, image):
self.names = []
self.names = names self.names = names
self.date = date self.date = date
self.weight = weight self.weight = weight
self.stage = stage self.stage = stage
self.image = image self.image = image
def formatted_date(self):
timezoned_datetime = timezone.localtime(self.date)
return formats.date_format(timezoned_datetime, format='H:i')
def to_dict(self):
return {
"names": self.names,
"date": self.formatted_date(),
"weight": self.weight,
"stage": self.stage,
"image": self.image,
}

@ -79,10 +79,6 @@ a:hover {
} }
} }
.beige {
color: #fff7ed;
}
.mybox { .mybox {
color: #707070; color: #707070;
padding: 8px 12px; padding: 8px 12px;
@ -115,6 +111,10 @@ tr {
/* height: 40px; */ /* height: 40px; */
} }
.beige {
color: #fff7ed;
}
.topblock { .topblock {
margin-top: 20px; margin-top: 20px;
} }

@ -21,30 +21,30 @@
</head> </head>
<body class="wrapper"> <body class="wrapper">
<header> <header>
<div class="grid-x"> <div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block"> <div class="cell medium-6 large-6 topblock my-block">
<!-- <div class="bubble"> --> <!-- <div class="bubble"> -->
<img <img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline" class="logo inline"
/> />
<div class="inline"> <div class="inline">
<h1 class="club">{% block first_title %}Page Title{% endblock %}</h1> <h1 class="club">{% block first_title %}Page Title{% endblock %}</h1>
<h1 class="event">{% block second_title %}Page Title{% endblock %}</h1> <h1 class="event">{% block second_title %}Page Title{% endblock %}</h1>
<!-- <span>Propulsé par Padel Club</span> --> <!-- <span>Propulsé par Padel Club</span> -->
</div> </div>
<!-- </div> --> <!-- </div> -->
</div>
</div> </div>
</header> </div>
</header>
<main> <main>
<!-- Content --> <!-- Content -->
{% block content %} {% block content %}
<!-- The content of child templates will be inserted here --> <!-- The content of child templates will be inserted here -->
{% endblock %} {% endblock %}
</main> </main>
</body> </body>
</html> </html>

@ -0,0 +1,22 @@
{% extends 'tournaments/broadcast_base.html' %}
{% load static %}
{% block head_title %}Broadcast{% endblock %}
{% block first_title %}{{ tournament.event.display_name }}{% endblock %}
{% block second_title %}Broadcast{% endblock %}
{% block content %}
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<div><a href="{% url 'broadcasted-matches' tournament.id %}">Matchs</a></div>
<div><a href="{% url 'broadcasted-group-stages' tournament.id %}">Poules</a></div>
<div><a href="{% url 'broadcasted-summons' tournament.id %}">Convocations</a></div>
</div>
</div>
</div>
{% endblock %}

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
{% load static %}
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link
rel="stylesheet"
href="{% static 'tournaments/css/foundation.min.css' %}"
/>
<link rel="stylesheet" href="{% static 'tournaments/css/style.css' %}" />
<link rel="stylesheet" href="{% static 'tournaments/css/broadcast.css' %}" />
<link
rel="icon"
type="image/png"
href="{% static 'tournaments/images/favicon.png' %}"
/>
<script src="{% static 'tournaments/js/alpine.min.js' %}"></script>
<title>{% block head_title %}Page Title{% endblock %}</title>
</head>
<body>
<div class="wrapper">
<header>
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">{% block first_title %}Page Title{% endblock %}</h1>
<h1 class="event">{% block second_title %}Page Title{% endblock %}</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
</div>
</header>
<main>
<!-- Content -->
{% block content %}
<!-- The content of child templates will be inserted here -->
{% endblock %}
</main>
</div>
</body>
</html>

@ -0,0 +1,131 @@
<!DOCTYPE html>
{% load static %}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="{% static 'tournaments/css/foundation.min.css' %}" />
<link rel="stylesheet" href="{% static 'tournaments/css/style.css' %}" />
<link rel="stylesheet" href="{% static 'tournaments/css/broadcast.css' %}" />
<link rel="icon" type="image/png" href="{% static 'tournaments/images/favicon.png' %}" />
<title>Padel</title>
<script src="{% static 'tournaments/js/alpine.min.js' %}"></script>
</head>
<body x-data="{
paginatedGroupStages: null,
active: 1,
retrieveMatches() {
fetch('/tournament/{{ tournament.id }}/group-stages/json/')
.then(res => res.json())
.then((data) => {
this.paginatedGroupStages = this.paginate(data, 4)
})
},
paginate(array, pageSize) {
let paginatedArray = [];
for (let i = 0; i < array.length; i += pageSize) {
paginatedArray.push(array.slice(i, i + pageSize));
}
return paginatedArray;
},
loop() {
this.retrieveMatches()
setInterval(() => {
this.retrieveMatches()
this.active = this.active === this.paginatedGroupStages.length ? 1 : this.active+1
}, 15000)
}
}" x-init="loop()">
<div class="wrapper">
<main class="page-body">
<div class="container">
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">{{ tournament.name }}</h1>
<h1 class="event">Poules</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
</div>
<div class="grid-x padding-bottom">
<template x-for="i in paginatedGroupStages.length" >
<template x-for="group_stage in paginatedGroupStages[i-1]" >
<div class="cell medium-6 large-3 my-block" x-show="active === i">
<div class="dark_bubble">
<div class="flex-row">
<label class="left-label matchtitle white"><span x-text="group_stage.title"></span></label>
<!-- <label class="right-label info"><span x-text="group_stage.date"></span></label> -->
</div>
<template x-for="i in group_stage.teams.length">
<div>
<div class="table-row-2-colums team-names-box padding-bottom-small">
<div class="table-cell table-cell-large">
<template x-for="name in group_stage.teams[i-1].names">
<div class="semibold" x-data="{
showName(name, team) {
let html = `<span class='`
if (team.is_winner) html += `winner`
html += `'>`
html += name
html += `</span>`
return html
},
}" x-html="showName(name, group_stage.teams[i-1])">
</div>
</template>
</div>
<div class="table-cell center">
<div class="score ws"><span x-text="group_stage.teams[i-1].win_loss"></span></div>
<div class="ws"><span x-text="group_stage.teams[i-1].diff"></span></div>
</div>
</div>
<div x-show="i === 1">
<div class="bottom-border"></div>
</div>
</div>
</template>
<div class="top-margin flex-row">
<label class="left-label minor-info"><span class="beige" x-text="group_stage.duration"></span></label>
<!-- <label class="right-label minor-info"><span x-text="group_stage.court"></span></label> -->
</div>
</div>
</div>
</template>
</template>
</div>
</div>
</main>
</div>
</body>
</html>

@ -19,7 +19,7 @@
paginatedMatches: null, paginatedMatches: null,
active: 1, active: 1,
retrieveMatches() { retrieveMatches() {
fetch('/tournament/{{ tournament.id }}/matches-json/') fetch('/tournament/{{ tournament.id }}/matches/json/')
.then(res => res.json()) .then(res => res.json())
.then((data) => { .then((data) => {
this.paginatedMatches = this.paginate(data, 8) this.paginatedMatches = this.paginate(data, 8)
@ -41,10 +41,8 @@
} }
}" x-init="loop()"> }" x-init="loop()">
<div class="wrapper"> <div class="wrapper">
<main class="page-body"> <main>
<div class="container">
<div class="grid-x"> <div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block"> <div class="cell medium-6 large-6 topblock my-block">
@ -54,7 +52,7 @@
class="logo inline" class="logo inline"
/> />
<div class="inline"> <div class="inline">
<h1 class="club">4Padel Toulouse</h1> <h1 class="club">{{ tournament.name }}</h1>
<h1 class="event">Matchs</h1> <h1 class="event">Matchs</h1>
<!-- <span>Propulsé par Padel Club</span> --> <!-- <span>Propulsé par Padel Club</span> -->
</div> </div>
@ -80,12 +78,6 @@
<div> <div>
<div class="table-row-3-colums team-names-box padding-bottom-small"> <div class="table-row-3-colums team-names-box padding-bottom-small">
<!-- <template x-if="match.teams[i-1].image">
<div class="table-cell">
<img src="{% static 'tournaments/images/pc_icon_round_200.png' %}" class="team_image" />
</div>
</template> -->
<div class="table-cell table-cell-large"> <div class="table-cell table-cell-large">
<template x-for="name in match.teams[i-1].names"> <template x-for="name in match.teams[i-1].names">
@ -144,9 +136,7 @@
</div> </div>
</div>
</main> </main>
</div> </div>
</body> </body>
</html> </html>

@ -0,0 +1,70 @@
{% extends 'tournaments/broadcast_base.html' %}
{% block head_title %}Convocations{% endblock %}
{% block first_title %}{{ tournament.name }}{% endblock %}
{% block second_title %}Convocations{% endblock %}
{% block content %}
{% load static %}
<div x-data="{
paginatedMatches: null,
active: 1,
retrieveMatches() {
fetch('/tournament/{{ tournament.id }}/summons/json/')
.then(res => res.json())
.then((data) => {
this.paginatedMatches = this.paginate(this.paginate(data, 16), 8)
})
},
paginate(array, pageSize) {
let paginatedArray = [];
for (let i = 0; i < array.length; i += pageSize) {
paginatedArray.push(array.slice(i, i + pageSize));
}
return paginatedArray;
},
loop() {
this.retrieveMatches()
setInterval(() => {
this.retrieveMatches()
this.active = this.active === this.paginatedMatches.length ? 1 : this.active+1
}, 15000)
}
}" x-init="loop()">
<div class="grid-x padding-bottom">
<template x-for="i in paginatedMatches.length" >
<template x-for="column in paginatedMatches[i-1]" >
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<template x-for="summon in column" >
<div class="table-row-4-colums bottom-border">
<div class="table-cell table-cell-large semibold">
<template x-for="i in summon.names.length">
<span x-text="summon.names[i-1]"></span>
</template>
</div>
<div class="table-cell"><span x-text="summon.weight"></span></div>
<div class="table-cell large center"><span x-text="summon.date"></span></div>
<div class="table-cell"><div class="mybox center"><span x-text="summon.stage"></span></div></div>
</div>
</template>
</div>
</div>
</template>
</template>
</div>
</div>
{% endblock %}

@ -4,7 +4,7 @@
<div class="dark_bubble"> <div class="dark_bubble">
<div class="flex-row"> <div class="flex-row">
<label class="left-label matchtitle white">{{ group_stage.title }}</label> <label class="left-label matchtitle winner">{{ group_stage.title }}</label>
<!-- <label class="right-label info">{{ match.date }}</label> --> <!-- <label class="right-label info">{{ match.date }}</label> -->
</div> </div>
@ -52,7 +52,7 @@
</div> </div>
<div class="flex-row top-margin"> <div class="flex-row top-margin">
<label class="left-label minor-info semibold beige">{{ group_stage.formatted_duration }}</label> <label class="left-label minor-info semibold"><span class="beige">{{ group_stage.formatted_duration }}</span></label>
<!-- <label class="right-label minor-info">{{ match.court }}</label> --> <!-- <label class="right-label minor-info">{{ match.court }}</label> -->
<!-- <a href="" class="right-label">{{ match.court }}</a> --> <!-- <a href="" class="right-label">{{ match.court }}</a> -->
</div> </div>

@ -16,20 +16,6 @@
{% include 'tournaments/summon_row.html' %} {% include 'tournaments/summon_row.html' %}
<!-- <div class="table-container bottom-border vertical-padding">
<img src="{% static 'tournaments/images/pc_icon_round_200.png' %}" class="team_image horizontal-margin" />
<div class="w50 tight table-cell hpadding10">
{% for name in team_call.names %}
<div>{{ name }}</div>
{% endfor %}
</div>
<div class="table-cell horizontal-padding">{{ team_call.weight }}</div>
<div class="table-cell horizontal-padding large">{{ team_call.date }}</div>
<div class="table-cell"><div class="mybox">{{ team_call.stage }}</div></div>
</div> -->
{% endfor %} {% endfor %}
</div> </div>
@ -37,53 +23,3 @@
</div> </div>
{% endblock %} {% endblock %}
<!-- <html>
{% load static %}
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link
rel="stylesheet"
href="{% static 'tournaments/css/foundation.min.css' %}"
/>
<link rel="stylesheet" href="{% static 'tournaments/css/style.css' %}" />
<link
rel="icon"
type="image/png"
href="{% static 'tournaments/images/favicon.png' %}"
/>
<title>Padel Club - Convocations</title>
</head>
<body>
<div class="wrapper">
<main class="page-body">
<div class="container">
<div class="grid-x">
<div class="cell medium-6 large-6 topblock my-block">
<div class="bubble">
<img
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}"
class="logo inline"
/>
<div class="inline">
<h1 class="club">4Padel Toulouse</h1>
<h1 class="event">Convocations</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</body>
</html> -->

@ -8,10 +8,14 @@ urlpatterns = [
include([ include([
path('', views.tournament, name='tournament'), path('', views.tournament, name='tournament'),
path('summons/', views.tournament_summons, name='tournament-summons'), path('summons/', views.tournament_summons, name='tournament-summons'),
path('broadcast/matches', views.tournament_matches, name='broadcasted-matches'), path('broadcast/summons/', views.tournament_broadcasted_summons, name='broadcasted-summons'),
path('matches-json/', views.tournament_matches_json, name='tournament-matches-json'), path('summons/json/', views.tournament_summons_json, name='tournament-summons-json'),
path('broadcast/matches/', views.tournament_matches, name='broadcasted-matches'),
path('broadcast/', views.tournament_broadcast, name='broadcast'),
path('matches/json/', views.tournament_matches_json, name='tournament-matches-json'),
path('broadcast/group-stages/', views.tournament_broadcasted_group_stages, name='broadcasted-group-stages'), path('broadcast/group-stages/', views.tournament_broadcasted_group_stages, name='broadcasted-group-stages'),
path('group-stages/', views.tournament_group_stages, name='group-stages'), path('group-stages/', views.tournament_group_stages, name='group-stages'),
path('group-stages/json/', views.tournament_live_group_stage_json, name='group-stages-json'),
]) ])
), ),
path('players/', views.players, name='players'), path('players/', views.players, name='players'),

@ -1,8 +1,12 @@
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse from django.http import HttpResponse
from tournaments.models import group_stage
from .serializers import ClubSerializer, TournamentSerializer, UserSerializer, ChangePasswordSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamScoreSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer, LiveMatchSerializer from .serializers import ClubSerializer, TournamentSerializer, UserSerializer, ChangePasswordSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamScoreSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer, LiveMatchSerializer
from .models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration from .models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration
from .models import TeamSummon from .models import TeamSummon
from datetime import datetime
import datetime
from rest_framework import viewsets, permissions from rest_framework import viewsets, permissions
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
@ -31,10 +35,8 @@ 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)
live_matches = list(tournament.live_matches()) live_matches = list(tournament.live_matches())
return render(request, 'tournaments/matches.html', { return render(request, 'tournaments/matches.html', {
'tournament': tournament, 'tournament': tournament,
'matches': live_matches, 'matches': live_matches,
@ -50,6 +52,23 @@ def tournament_summons(request, tournament_id):
'team_summons': team_summons, 'team_summons': team_summons,
}) })
def tournament_broadcasted_summons(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcasted_summons.html', {
'tournament': tournament,
})
def tournament_summons_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
team_summons = [summon.to_dict() for summon in tournament.team_summons()]
data = json.dumps(team_summons)
return HttpResponse(data, content_type='application/json')
def tournament_broadcast(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
return render(request, 'tournaments/broadcast.html', {
'tournament': tournament,
})
def tournament_matches(request, tournament_id): def tournament_matches(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
@ -59,7 +78,7 @@ def tournament_matches(request, tournament_id):
def tournament_matches_json(request, tournament_id): def tournament_matches_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
live_matches = list(tournament.live_matches()) live_matches = tournament.live_matches()
data = json.dumps(live_matches, default=vars) data = json.dumps(live_matches, default=vars)
return HttpResponse(data, content_type='application/json') return HttpResponse(data, content_type='application/json')
@ -79,8 +98,10 @@ def tournament_broadcasted_group_stages(request, tournament_id):
def tournament_live_group_stage_json(request, tournament_id): def tournament_live_group_stage_json(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
live_group_stages = list(tournament.live_group_stages())
data = json.dumps(live_group_stages, default=vars) gs_dicts = [gs.to_dict() for gs in tournament.live_group_stages()]
# group_stages = tournament.live_group_stages()
data = json.dumps(gs_dicts)
return HttpResponse(data, content_type='application/json') return HttpResponse(data, content_type='application/json')
def players(request): def players(request):

Loading…
Cancel
Save