Broadcast: adds matches from the next round

clubs
Laurent 1 year ago
parent eb1576e666
commit 38891be4c2
  1. 16
      tournaments/models/tournament.py

@ -427,11 +427,20 @@ class Tournament(models.Model):
if len(self.groupstage_set.all()) > 0 and self.no_bracket_match_has_started(): if len(self.groupstage_set.all()) > 0 and self.no_bracket_match_has_started():
group_stages = self.live_group_stages() group_stages = self.live_group_stages()
matches = self.broadcasted_group_stages_matches() matches = self.broadcasted_group_stages_matches()
first_round = self.first_round()
if first_round:
matches.extend(first_round.get_matches_recursive(True))
else: else:
current_round = self.round_to_show() current_round = self.round_to_show()
if current_round: if current_round:
previous_round = self.round_for_index(current_round.index + 1)
# Add full matches from the next rounds
next_round = self.round_for_index(current_round.index - 1)
if next_round:
matches.extend(next_round.get_matches_recursive(True))
# Add matches from the previous round or group_stages
previous_round = self.round_for_index(current_round.index + 1)
if previous_round: if previous_round:
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))
@ -504,6 +513,11 @@ class Tournament(models.Model):
def round_for_index(self, index): def round_for_index(self, index):
return self.round_set.filter(index=index, parent=None).first() return self.round_set.filter(index=index, parent=None).first()
def first_round(self):
main_rounds = list(self.round_set.filter(parent=None))
main_rounds.sort(key=lambda r: r.index, reverse=True)
return main_rounds[0]
def broadcasted_group_stages_matches(self): def broadcasted_group_stages_matches(self):
matches = [] matches = []
group_stages = self.elected_broadcast_group_stages() group_stages = self.elected_broadcast_group_stages()

Loading…
Cancel
Save