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. 67
      tournaments/templates/tournaments/broadcast/broadcasted_auto.html
  7. 6
      tournaments/templates/tournaments/broadcast/broadcasted_ranking.html
  8. 9
      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)
start_date = models.DateTimeField(null=True, blank=True)
name = models.CharField(max_length=200, null=True, blank=True)
step = models.IntegerField(default=0)
def __str__(self):
return self.display_name()

@ -221,7 +221,7 @@ class Tournament(models.Model):
names = team_registration.team_names()
stage = next_match.summon_stage_name()
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.sort(key=lambda s: s.date)
@ -372,10 +372,13 @@ class Tournament(models.Model):
groups = []
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))
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'):
group = self.group_stage_match_group(group_stage, broadcasted, hide_empty_matches=True)
if group:
@ -390,6 +393,8 @@ class Tournament(models.Model):
else:
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:
return self.create_match_group(group_stage.display_name(), matches)
else:
@ -405,6 +410,7 @@ class Tournament(models.Model):
matches = [m for m in matches if m.disabled is False]
if matches:
matches.sort(key=lambda m: m.index)
group = self.create_match_group(round.name(), matches)
groups.append(group)
@ -415,6 +421,7 @@ class Tournament(models.Model):
ranking_matches = [m for m in ranking_matches if m.disabled is False]
if len(ranking_matches) > 0:
ranking_matches.sort(key=lambda m: m.index)
group = self.create_match_group('Matchs de classement', ranking_matches)
groups.append(group)
@ -422,7 +429,6 @@ class Tournament(models.Model):
def create_match_group(self, name, matches):
matches = list(matches)
matches.sort(key=lambda m: m.index)
live_matches = [match.live_match() for match in 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
# 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()]
if group_stages:
return {
'matches': [],
'group_stages': group_stages_dicts,
'summons': team_summons_dicts,
'rankings' : []
}
else:
live_matches_dicts = [match.live_match().to_dict() for match in matches]
@ -452,6 +459,16 @@ class Tournament(models.Model):
'matches': live_matches_dicts,
'group_stages': [],
'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
live_matches_dicts = [match.live_match().to_dict() for match in matches]
@ -459,6 +476,7 @@ class Tournament(models.Model):
'matches': live_matches_dicts,
'group_stages': group_stages_dicts,
'summons': [],
'rankings' : []
}
def broadcasted_matches_and_group_stages(self):
@ -473,19 +491,26 @@ class Tournament(models.Model):
matches.extend(first_round.get_matches_recursive(True))
else:
current_round = self.round_to_show()
print("current_round", current_round)
if current_round:
# 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)
if next_round:
print("next_round", next_round)
matches.extend(next_round.get_matches_recursive(True))
# 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)
if previous_round:
print("previous_round", previous_round)
print('test 1')
matches.extend(current_round.get_matches_recursive(True))
matches.extend(previous_round.get_matches_recursive(True))
else:
print("else")
matches.extend(current_round.all_matches(True))
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)
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)
if 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 False
@ -679,7 +711,7 @@ class Tournament(models.Model):
return min(matches, key=lambda m: m.start_date).start_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):
end = self.start_date + timedelta(days=self.day_duration + 1)
@ -721,11 +753,12 @@ class MatchGroup:
self.matches = matches
class TeamSummon:
def __init__(self, names, date, weight, stage, image):
def __init__(self, names, date, weight, stage, court, image):
self.names = names
self.date = date
self.weight = weight
self.stage = stage
self.court = court
self.image = image
def formatted_date(self):
@ -741,6 +774,7 @@ class TeamSummon:
"date": self.formatted_date(),
"weight": self.weight,
"stage": self.stage,
"court": self.court,
"image": self.image,
}

File diff suppressed because it is too large Load Diff

@ -36,6 +36,7 @@
paginatedMatches: null,
paginatedGroupStages: null,
paginatedSummons: null,
paginatedRankings: null,
active: 1,
prefixTitle: '',
retrieveData() {
@ -45,11 +46,33 @@
this.paginatedMatches = this.paginate(data.matches, 8)
this.paginatedGroupStages = this.paginate(data.group_stages, 4)
this.paginatedSummons = this.paginateSummons(data.summons)
this.paginatedRankings = this.paginateRankings(data.rankings)
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) {
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)
const splitGroups = []
@ -80,46 +103,39 @@
}, 15000)
},
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() {
if (this.active < 1 + this.paginatedSummons.length) {
this.prefixTitle = 'Convocations'
} else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) {
this.prefixTitle = 'Matchs'
} else {
} else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) {
this.prefixTitle = 'Poules'
} else {
this.prefixTitle = 'Classement'
}
}
}" x-init="loop()">
<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">
<div id="header">
<div class="left-content bubble">
<img src="{% static 'tournaments/images/PadelClub_logo_512.png' %}" alt="logo" class="logo">
<div class="left-margin">
<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>
{% 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">
<template x-for="i in paginatedSummons.length">
@ -146,6 +162,13 @@
</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>
</main>

@ -1,5 +1,5 @@
{% load static %}
<div class="bubble">
<template x-for="(ranking, index) in column" >
<div>
<div class="table-row-3-colums-ranks">
@ -18,3 +18,5 @@
<hr/>
</div>
</div>
</template>
</div>

@ -16,7 +16,7 @@
.then(res => res.json())
.then((data) => {
let pageSize = 20
let pageSize = 16
this.paginatedRankings = this.paginate(data, pageSize)
const splitGroups = [];
@ -54,14 +54,7 @@
<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">
<div class="bubble">
<template x-for="(ranking, index) in column" >
{% include 'tournaments/broadcast/broadcasted_ranking.html' %}
</template>
</div>
</div>
</template>
</template>

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

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

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

Loading…
Cancel
Save