bracket-feature
laurent 1 year ago
commit b0034e7cef
  1. 10
      tournaments/models/tournament.py

@ -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)

Loading…
Cancel
Save