Displays match even when tournament is over

clubs
Laurent 2 years ago
parent 5961461c88
commit 12e4198432
  1. 22
      tournaments/models/tournament.py

@ -176,8 +176,8 @@ class Tournament(models.Model):
group_stages = self.live_group_stages()
matches = self.group_stages_matches()
else:
last_started_match = self.first_unfinished_match()
current_round = last_started_match.round.root_round()
# last_started_match = self.first_unfinished_match()
current_round = self.round_to_show()
previous_round = self.round_for_index(current_round.index + 1)
if previous_round:
@ -218,7 +218,23 @@ class Tournament(models.Model):
def first_unfinished_match(self):
matches = [m for m in self.all_matches(False) if m.start_date and m.end_date is None]
matches.sort(key=lambda m: m.start_date)
return matches[0]
if matches:
return matches[0]
else:
return None
def round_to_show(self):
last_started_match = self.first_unfinished_match()
if last_started_match:
current_round = last_started_match.round.root_round()
if current_round:
return current_round
main_rounds = list(self.round_set.filter(parent=None).all())
main_rounds.sort(key=lambda r: r.index)
if main_rounds:
return main_rounds[0]
else:
return None
def last_started_match(self):
matches = [m for m in self.all_matches(False) if m.start_date]

Loading…
Cancel
Save