Laurent 1 year ago
commit 17ea4c185b
  1. 18
      tournaments/migrations/0088_groupstage_step.py
  2. 1
      tournaments/models/group_stage.py
  3. 50
      tournaments/models/tournament.py
  4. 11151
      tournaments/static/rankings/CLASSEMENT-PADEL-DAMES-10-2024.csv
  5. 40002
      tournaments/static/rankings/CLASSEMENT-PADEL-MESSIEURS-10-2024.csv
  6. 77
      tournaments/templates/tournaments/broadcast/broadcasted_auto.html
  7. 34
      tournaments/templates/tournaments/broadcast/broadcasted_ranking.html
  8. 11
      tournaments/templates/tournaments/broadcast/broadcasted_rankings.html
  9. 12
      tournaments/templates/tournaments/broadcast/broadcasted_summon.html
  10. 2
      tournaments/templates/tournaments/broadcast/broadcasted_summons.html
  11. 7
      tournaments/templates/tournaments/summon_row.html

@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-09-28 15:21
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('tournaments', '0087_alter_playerregistration_phone_number'),
]
operations = [
migrations.AddField(
model_name='groupstage',
name='step',
field=models.IntegerField(default=0),
),
]

@ -13,6 +13,7 @@ class GroupStage(models.Model):
format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True) format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True)
start_date = models.DateTimeField(null=True, blank=True) start_date = models.DateTimeField(null=True, blank=True)
name = models.CharField(max_length=200, null=True, blank=True) name = models.CharField(max_length=200, null=True, blank=True)
step = models.IntegerField(default=0)
def __str__(self): def __str__(self):
return self.display_name() return self.display_name()

@ -221,7 +221,7 @@ class Tournament(models.Model):
names = team_registration.team_names() names = team_registration.team_names()
stage = next_match.summon_stage_name() stage = next_match.summon_stage_name()
weight = team_registration.weight weight = team_registration.weight
summon = TeamSummon(names, next_match.start_date, weight, stage, team_registration.logo) summon = TeamSummon(names, next_match.start_date, weight, stage, next_match.court_name(next_match.court_index), team_registration.logo)
summons.append(summon) summons.append(summon)
summons.sort(key=lambda s: s.date) summons.sort(key=lambda s: s.date)
@ -372,10 +372,13 @@ class Tournament(models.Model):
groups = [] groups = []
if self.display_matches(): if self.display_matches():
for round in self.round_set.filter(parent=None).all().order_by('index'): for round in self.round_set.filter(parent=None, group_stage_loser_bracket=False).all().order_by('index'):
groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True)) groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True))
if self.display_group_stages(): if self.display_group_stages():
for round in self.round_set.filter(parent=None, group_stage_loser_bracket=True).all().order_by('index'):
groups.extend(self.round_match_groups(round, broadcasted, hide_empty_matches=True))
for group_stage in self.groupstage_set.all().order_by('index'): for group_stage in self.groupstage_set.all().order_by('index'):
group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True) group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True)
if group: if group:
@ -390,6 +393,8 @@ class Tournament(models.Model):
else: else:
matches = [m for m in matches if m.disabled is False] matches = [m for m in matches if m.disabled is False]
matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index))
if matches: if matches:
return self.create_match_group(group_stage.display_name(), matches) return self.create_match_group(group_stage.display_name(), matches)
else: else:
@ -405,6 +410,7 @@ class Tournament(models.Model):
matches = [m for m in matches if m.disabled is False] matches = [m for m in matches if m.disabled is False]
if matches: if matches:
matches.sort(key=lambda m: m.index)
group = self.create_match_group(round.name(), matches) group = self.create_match_group(round.name(), matches)
groups.append(group) groups.append(group)
@ -415,6 +421,7 @@ class Tournament(models.Model):
ranking_matches = [m for m in ranking_matches if m.disabled is False] ranking_matches = [m for m in ranking_matches if m.disabled is False]
if len(ranking_matches) > 0: if len(ranking_matches) > 0:
ranking_matches.sort(key=lambda m: m.index)
group = self.create_match_group('Matchs de classement', ranking_matches) group = self.create_match_group('Matchs de classement', ranking_matches)
groups.append(group) groups.append(group)
@ -422,7 +429,6 @@ class Tournament(models.Model):
def create_match_group(self, name, matches): def create_match_group(self, name, matches):
matches = list(matches) matches = list(matches)
matches.sort(key=lambda m: m.index)
live_matches = [match.live_match() for match in matches] live_matches = [match.live_match() for match in matches]
return MatchGroup(name, live_matches) return MatchGroup(name, live_matches)
@ -438,13 +444,14 @@ class Tournament(models.Model):
# if now is before the first match, we want to show the summons + group stage or first matches # if now is before the first match, we want to show the summons + group stage or first matches
# change timezone to datetime to avoid the bug RuntimeWarning: DateTimeField Tournament.start_date received a naive datetime (2024-05-16 00:00:00) while time zone support is active. # change timezone to datetime to avoid the bug RuntimeWarning: DateTimeField Tournament.start_date received a naive datetime (2024-05-16 00:00:00) while time zone support is active.
if datetime.now().date() < self.start_date.date(): if timezone.now() < self.start_date:
team_summons_dicts = [summon.to_dict() for summon in self.team_summons()] team_summons_dicts = [summon.to_dict() for summon in self.team_summons()]
if group_stages: if group_stages:
return { return {
'matches': [], 'matches': [],
'group_stages': group_stages_dicts, 'group_stages': group_stages_dicts,
'summons': team_summons_dicts, 'summons': team_summons_dicts,
'rankings' : []
} }
else: else:
live_matches_dicts = [match.live_match().to_dict() for match in matches] live_matches_dicts = [match.live_match().to_dict() for match in matches]
@ -452,13 +459,24 @@ class Tournament(models.Model):
'matches': live_matches_dicts, 'matches': live_matches_dicts,
'group_stages': [], 'group_stages': [],
'summons': team_summons_dicts, 'summons': team_summons_dicts,
'rankings' : []
} }
elif self.end_date is not None:
live_matches_dicts = [match.live_match().to_dict() for match in matches]
team_rankings_dicts = [ranking.to_dict() for ranking in self.rankings()]
return {
'matches': live_matches_dicts,
'group_stages': [],
'summons': [],
'rankings' : team_rankings_dicts
}
else: # we want to display the broadcasted content else: # we want to display the broadcasted content
live_matches_dicts = [match.live_match().to_dict() for match in matches] live_matches_dicts = [match.live_match().to_dict() for match in matches]
return { return {
'matches': live_matches_dicts, 'matches': live_matches_dicts,
'group_stages': group_stages_dicts, 'group_stages': group_stages_dicts,
'summons': [], 'summons': [],
'rankings' : []
} }
def broadcasted_matches_and_group_stages(self): def broadcasted_matches_and_group_stages(self):
@ -473,19 +491,26 @@ class Tournament(models.Model):
matches.extend(first_round.get_matches_recursive(True)) matches.extend(first_round.get_matches_recursive(True))
else: else:
current_round = self.round_to_show() current_round = self.round_to_show()
print("current_round", current_round)
if current_round: if current_round:
# Add full matches from the next rounds # Add full matches from the next rounds
print("Add full matches from the next rounds")
next_round = self.round_for_index(current_round.index - 1) next_round = self.round_for_index(current_round.index - 1)
if next_round: if next_round:
print("next_round", next_round)
matches.extend(next_round.get_matches_recursive(True)) matches.extend(next_round.get_matches_recursive(True))
# Add matches from the previous round or group_stages # Add matches from the previous round or group_stages
print("Add matches from the previous round or group_stages")
previous_round = self.round_for_index(current_round.index + 1) previous_round = self.round_for_index(current_round.index + 1)
if previous_round: if previous_round:
print("previous_round", previous_round)
print('test 1')
matches.extend(current_round.get_matches_recursive(True)) matches.extend(current_round.get_matches_recursive(True))
matches.extend(previous_round.get_matches_recursive(True)) matches.extend(previous_round.get_matches_recursive(True))
else: else:
print("else")
matches.extend(current_round.all_matches(True)) matches.extend(current_round.all_matches(True))
group_stages = self.live_group_stages() group_stages = self.live_group_stages()
@ -654,13 +679,20 @@ class Tournament(models.Model):
first_match_start_date = self.first_match_start_date(bracket_matches) first_match_start_date = self.first_match_start_date(bracket_matches)
if first_match_start_date is None: if first_match_start_date is None:
return datetime.now().date() >= self.start_date.date() return timezone.now() >= self.start_date
bracket_start_date = self.getEightAm(first_match_start_date) bracket_start_date = self.getEightAm(first_match_start_date)
if bracket_start_date < self.start_date: if bracket_start_date < self.start_date:
bracket_start_date = self.start_date bracket_start_date = self.start_date
if datetime.now().date() >= bracket_start_date.date(): group_stage_start_date = self.group_stage_start_date()
if group_stage_start_date is not None:
if bracket_start_date < group_stage_start_date:
return False
if timezone.now() >= bracket_start_date:
return True return True
return False return False
@ -679,7 +711,7 @@ class Tournament(models.Model):
return min(matches, key=lambda m: m.start_date).start_date return min(matches, key=lambda m: m.start_date).start_date
def getEightAm(self, date): def getEightAm(self, date):
return date.replace(hour=8, minute=0, second=0, microsecond=0) return date.replace(hour=8, minute=0, second=0, microsecond=0, tzinfo=date.tzinfo)
def supposedly_in_progress(self): def supposedly_in_progress(self):
end = self.start_date + timedelta(days=self.day_duration + 1) end = self.start_date + timedelta(days=self.day_duration + 1)
@ -721,11 +753,12 @@ class MatchGroup:
self.matches = matches self.matches = matches
class TeamSummon: class TeamSummon:
def __init__(self, names, date, weight, stage, image): def __init__(self, names, date, weight, stage, court, image):
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.court = court
self.image = image self.image = image
def formatted_date(self): def formatted_date(self):
@ -741,6 +774,7 @@ class TeamSummon:
"date": self.formatted_date(), "date": self.formatted_date(),
"weight": self.weight, "weight": self.weight,
"stage": self.stage, "stage": self.stage,
"court": self.court,
"image": self.image, "image": self.image,
} }

File diff suppressed because it is too large Load Diff

@ -36,6 +36,7 @@
paginatedMatches: null, paginatedMatches: null,
paginatedGroupStages: null, paginatedGroupStages: null,
paginatedSummons: null, paginatedSummons: null,
paginatedRankings: null,
active: 1, active: 1,
prefixTitle: '', prefixTitle: '',
retrieveData() { retrieveData() {
@ -45,11 +46,33 @@
this.paginatedMatches = this.paginate(data.matches, 8) this.paginatedMatches = this.paginate(data.matches, 8)
this.paginatedGroupStages = this.paginate(data.group_stages, 4) this.paginatedGroupStages = this.paginate(data.group_stages, 4)
this.paginatedSummons = this.paginateSummons(data.summons) this.paginatedSummons = this.paginateSummons(data.summons)
this.paginatedRankings = this.paginateRankings(data.rankings)
this.setPrefixTitle() this.setPrefixTitle()
// Adjust active if it exceeds the new page count
if (this.active > this.pageCount()) {
this.active = 1; // Reset to the first page
}
}) })
}, },
paginateSummons(array) { paginateSummons(array) {
let pageSize = 20 let pageSize = 16
pages = this.paginate(array, pageSize)
const splitGroups = []
pages.forEach(group => {
const firstHalf = group.slice(0, pageSize / 2)
const secondHalf = group.slice(pageSize / 2)
if (secondHalf.length > 0) {
splitGroups.push([firstHalf, secondHalf])
} else {
splitGroups.push([firstHalf])
}
});
return splitGroups
},
paginateRankings(array) {
let pageSize = 16
pages = this.paginate(array, pageSize) pages = this.paginate(array, pageSize)
const splitGroups = [] const splitGroups = []
@ -80,46 +103,39 @@
}, 15000) }, 15000)
}, },
pageCount() { pageCount() {
return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length + this.paginatedRankings.length
}, },
setPrefixTitle() { setPrefixTitle() {
if (this.active < 1 + this.paginatedSummons.length) { if (this.active < 1 + this.paginatedSummons.length) {
this.prefixTitle = 'Convocations' this.prefixTitle = 'Convocations'
} else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) { } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) {
this.prefixTitle = 'Matchs' this.prefixTitle = 'Matchs'
} else { } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) {
this.prefixTitle = 'Poules' this.prefixTitle = 'Poules'
} else {
this.prefixTitle = 'Classement'
} }
} }
}" x-init="loop()"> }" x-init="loop()">
<header>
<div class="wrapper"> <div id="header">
<header> <div class="left-content bubble">
<div class="grid-x"> <img src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" alt="logo" class="logo">
<div class="cell medium-6 large-6 topblock my-block"> <div class="left-margin">
<div class="bubble"> <h1 class="club">{{ tournament.broadcast_event_display_name }}</h1>
<img <h1 class="event"><span x-text="prefixTitle"></span> {{ tournament.broadcast_display_name }}</h1>
src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" </div >
class="logo inline"
/>
<div class="inline">
<h1 class="club">{{ tournament.broadcast_event_display_name }}</h1>
<h1 class="event"><span x-text="prefixTitle"></span> {{ tournament.broadcast_display_name }}</h1>
<!-- <span>Propulsé par Padel Club</span> -->
</div>
</div>
</div>
<div class="cell medium-6 large-6 topblock my-block">
<div class="right">
{% qr_from_text qr_code_url options=qr_code_options %}
</div>
</div>
</div> </div>
</header> {% if qr_code_options %}
<div class="right-content">{% qr_from_text qr_code_url options=qr_code_options %}</div>
{% endif %}
</div>
</header>
<main>
<div class="wrapper">
<main>
<div class="grid-x"> <div class="grid-x">
<template x-for="i in paginatedSummons.length"> <template x-for="i in paginatedSummons.length">
@ -146,6 +162,13 @@
</template> </template>
</template> </template>
<template x-for="i in paginatedRankings.length">
<template x-for="column in paginatedRankings[i-1]">
<div class="cell medium-6 large-6 topblock my-block" x-show="active === i + paginatedSummons.length + paginatedMatches.length + paginatedGroupStages.length">
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
</div>
</template>
</template>
</div> </div>
</main> </main>

@ -1,20 +1,22 @@
{% load static %} <div class="bubble">
<template x-for="(ranking, index) in column" >
<div>
<div class="table-row-3-colums-ranks">
<div> <div class="table-cell"><div class="mybox center"><span x-text="ranking.formatted_ranking"></div></div>
<div class="table-row-3-colums-ranks"> <div class="table-cell table-cell-large padding-left semibold">
<div class="table-cell"><div class="mybox center"><span x-text="ranking.formatted_ranking"></div></div> <template x-for="name in ranking.names" >
<div class="table-cell table-cell-large padding-left semibold"> <div><span x-text="name"></div>
</template>
<template x-for="name in ranking.names" > </div>
<div><span x-text="name"></div> {% if tournament.display_points_earned %}
</template> <div class="table-cell right horizontal-padding numbers"><span x-text="ranking.points"></div>
{% endif %}
</div>
<div x-show="index < column.length - 1">
<hr/>
</div>
</div> </div>
{% if tournament.display_points_earned %} </template>
<div class="table-cell right horizontal-padding numbers"><span x-text="ranking.points"></div>
{% endif %}
</div>
<div x-show="index < column.length - 1">
<hr/>
</div>
</div> </div>

@ -16,7 +16,7 @@
.then(res => res.json()) .then(res => res.json())
.then((data) => { .then((data) => {
let pageSize = 20 let pageSize = 16
this.paginatedRankings = this.paginate(data, pageSize) this.paginatedRankings = this.paginate(data, pageSize)
const splitGroups = []; const splitGroups = [];
@ -54,14 +54,7 @@
<template x-for="i in paginatedRankings.length" > <template x-for="i in paginatedRankings.length" >
<template x-for="column in paginatedRankings[i-1]" > <template x-for="column in paginatedRankings[i-1]" >
<div class="cell medium-6 large-6 topblock my-block" x-show="active === i"> <div class="cell medium-6 large-6 topblock my-block" x-show="active === i">
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
<div class="bubble">
<template x-for="(ranking, index) in column" >
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
</template>
</div>
</div> </div>
</template> </template>
</template> </template>

@ -7,13 +7,11 @@
<div x-text="summon.names[i-1]"></div> <div x-text="summon.names[i-1]"></div>
</template> </template>
</div> </div>
<div class="table-cell left numbers"><span x-text=""></span></div>
{% if not tournament.hide_weight %} <div class="table-cell left">
<div class="table-cell center numbers"><span x-text="summon.weight"></span></div> <div class="table-cell large"><span x-text="summon.date"></span></div>
{% else %} <div class="table-cell"><span x-text="summon.court"></span></div>
<div class="table-cell center numbers"><span x-text=""></span></div> </div>
{% endif %}
<div class="table-cell large center"><span x-text="summon.date"></span></div>
<div class="table-cell right"><div class="mybox center"><span x-text="summon.stage"></span></div></div> <div class="table-cell right"><div class="mybox center"><span x-text="summon.stage"></span></div></div>
</div> </div>

@ -16,7 +16,7 @@
.then(res => res.json()) .then(res => res.json())
.then((data) => { .then((data) => {
let pageSize = 20 let pageSize = 16
this.paginatedMatches = this.paginate(data, pageSize) this.paginatedMatches = this.paginate(data, pageSize)
const splitGroups = []; const splitGroups = [];

@ -8,8 +8,11 @@
{% endfor %} {% endfor %}
</div> </div>
<div class="table-cell large center">{{ summon.date|date:'l H:i' }}</div> <div class="table-cell left">
<div class="table-cell"><div class="mybox center">{{ summon.stage }}</div></div> <div class="table-cell large">{{ summon.date|date:'l H:i' }}</div>
<div class="table-cell">{{ summon.court }}</div>
</div>
<div class="table-cell right"><div class="mybox center">{{ summon.stage }}</div></div>
</div> </div>
{% if not forloop.last %} {% if not forloop.last %}

Loading…
Cancel
Save