diff --git a/tournaments/migrations/0081_round_group_stage_loser_bracket.py b/tournaments/migrations/0081_round_group_stage_loser_bracket.py new file mode 100644 index 0000000..233a29a --- /dev/null +++ b/tournaments/migrations/0081_round_group_stage_loser_bracket.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.11 on 2024-09-09 11:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournaments', '0080_alter_club_acronym'), + ] + + operations = [ + migrations.AddField( + model_name='round', + name='group_stage_loser_bracket', + field=models.BooleanField(default=False), + ), + ] diff --git a/tournaments/models/enums.py b/tournaments/models/enums.py index 76a340b..0a3a1b9 100644 --- a/tournaments/models/enums.py +++ b/tournaments/models/enums.py @@ -25,13 +25,13 @@ class FederalLevelCategory(models.IntegerChoices): class FederalAgeCategory(models.IntegerChoices): UNLISTED = 0, '' - A11_12 = 120, 'A11_12' - A13_14 = 140, 'A13_14' - A15_16 = 160, 'A15_16' - A17_18 = 180, 'A17_18' - SENIOR = 200, 'SENIOR' - A45 = 450, 'A45' - A55 = 550, 'A55' + A11_12 = 120, 'U12' + A13_14 = 140, 'U14' + A15_16 = 160, 'U16' + A17_18 = 180, 'U18' + SENIOR = 200, 'Senior' + A45 = 450, '+45 ans' + A55 = 550, '+55 ans' class FederalMatchCategory(models.IntegerChoices): TWO_SETS = 0, 'Two sets' diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 5797f80..0ad10e3 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -9,6 +9,7 @@ class Round(models.Model): parent = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE, related_name='children') format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True) start_date = models.DateTimeField(null=True, blank=True) + group_stage_loser_bracket = models.BooleanField(default=False) def __str__(self): if self.parent: @@ -23,6 +24,8 @@ class Round(models.Model): def name(self): if self.parent: return "Matchs de classement" + elif self.group_stage_loser_bracket is True: + return "Matchs de classement de poule" else: if self.index == 0: return "Finale" diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 4fd6320..0b43c87 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -119,6 +119,11 @@ class Tournament(models.Model): def category(self): return self.get_federal_category_display() + def age(self): + if self.federal_age_category == 0: + return None + return self.get_federal_age_category_display() + def formatted_start_date(self): return self.start_date.strftime("%d/%m/%y") @@ -542,6 +547,14 @@ class Tournament(models.Model): matches.extend(group_stage.match_set.all()) matches = [m for m in matches if m.should_appear()] matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index)) + + group_stage_loser_bracket = list(self.round_set.filter(parent=None, group_stage_loser_bracket=True).all()) + if len(group_stage_loser_bracket) > 0: + loser_matches = group_stage_loser_bracket[0].all_matches(True) + loser_matches = [m for m in loser_matches if m.should_appear()] + loser_matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index)) + matches.extend(loser_matches) + return matches def elected_broadcast_group_stages(self): diff --git a/tournaments/templates/tournaments/broadcast/broadcast_club.html b/tournaments/templates/tournaments/broadcast/broadcast_club.html index 81109d9..d5e5073 100644 --- a/tournaments/templates/tournaments/broadcast/broadcast_club.html +++ b/tournaments/templates/tournaments/broadcast/broadcast_club.html @@ -19,6 +19,9 @@