|
|
|
@ -176,8 +176,8 @@ class Tournament(models.Model): |
|
|
|
group_stages = self.live_group_stages() |
|
|
|
group_stages = self.live_group_stages() |
|
|
|
matches = self.group_stages_matches() |
|
|
|
matches = self.group_stages_matches() |
|
|
|
else: |
|
|
|
else: |
|
|
|
last_started_match = self.first_unfinished_match() |
|
|
|
# last_started_match = self.first_unfinished_match() |
|
|
|
current_round = last_started_match.round.root_round() |
|
|
|
current_round = self.round_to_show() |
|
|
|
previous_round = self.round_for_index(current_round.index + 1) |
|
|
|
previous_round = self.round_for_index(current_round.index + 1) |
|
|
|
|
|
|
|
|
|
|
|
if previous_round: |
|
|
|
if previous_round: |
|
|
|
@ -218,7 +218,23 @@ class Tournament(models.Model): |
|
|
|
def first_unfinished_match(self): |
|
|
|
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 = [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) |
|
|
|
matches.sort(key=lambda m: m.start_date) |
|
|
|
|
|
|
|
if matches: |
|
|
|
return matches[0] |
|
|
|
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): |
|
|
|
def last_started_match(self): |
|
|
|
matches = [m for m in self.all_matches(False) if m.start_date] |
|
|
|
matches = [m for m in self.all_matches(False) if m.start_date] |
|
|
|
|