|
|
|
@ -177,24 +177,28 @@ class Tournament(models.Model): |
|
|
|
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 |
|
|
|
current_round = last_started_match.round.root_round() |
|
|
|
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: |
|
|
|
matches.extend(current_round.get_matches_recursive(False)) |
|
|
|
matches.extend(current_round.get_matches_recursive(True)) |
|
|
|
matches.extend(previous_round.get_matches_recursive(False)) |
|
|
|
matches.extend(previous_round.get_matches_recursive(True)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
matches.extend(current_round.all_matches()) |
|
|
|
matches.extend(current_round.all_matches(True)) |
|
|
|
group_stages = self.live_group_stages() |
|
|
|
group_stages = self.live_group_stages() |
|
|
|
|
|
|
|
|
|
|
|
return matches, group_stages |
|
|
|
return matches, group_stages |
|
|
|
|
|
|
|
|
|
|
|
def all_matches(self): |
|
|
|
def all_matches(self, hide_empty_matches): |
|
|
|
matches = [] |
|
|
|
matches = [] |
|
|
|
for round in self.round_set.all(): |
|
|
|
for round in self.round_set.all(): |
|
|
|
matches.extend(round.all_matches()) |
|
|
|
matches.extend(round.all_matches()) |
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
matches.extend(group_stage.match_set.all()) |
|
|
|
matches.extend(group_stage.match_set.all()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if hide_empty_matches: |
|
|
|
|
|
|
|
matches = [m for m in matches if m.should_appear()] |
|
|
|
|
|
|
|
|
|
|
|
return matches |
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
|
|
def group_stage_matches(self): |
|
|
|
def group_stage_matches(self): |
|
|
|
@ -212,12 +216,12 @@ class Tournament(models.Model): |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def first_unfinished_match(self): |
|
|
|
def first_unfinished_match(self): |
|
|
|
matches = [m for m in self.all_matches() 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) |
|
|
|
return matches[0] |
|
|
|
return matches[0] |
|
|
|
|
|
|
|
|
|
|
|
def last_started_match(self): |
|
|
|
def last_started_match(self): |
|
|
|
matches = [m for m in self.all_matches() if m.start_date] |
|
|
|
matches = [m for m in self.all_matches(False) if m.start_date] |
|
|
|
matches.sort(key=lambda m: m.start_date, reverse=True) |
|
|
|
matches.sort(key=lambda m: m.start_date, reverse=True) |
|
|
|
return matches[0] |
|
|
|
return matches[0] |
|
|
|
|
|
|
|
|
|
|
|
|