|
|
|
|
@ -606,7 +606,7 @@ class Tournament(models.Model): |
|
|
|
|
matches.extend(first_round.get_matches_recursive(True)) |
|
|
|
|
else: |
|
|
|
|
current_round = self.round_to_show() |
|
|
|
|
print(f'current_round = {current_round.index} / parent = {current_round.parent}') |
|
|
|
|
# print(f'current_round = {current_round.index} / parent = {current_round.parent}') |
|
|
|
|
if current_round: |
|
|
|
|
all_upper_matches_are_over = current_round.all_matches_are_over() |
|
|
|
|
if all_upper_matches_are_over is False: |
|
|
|
|
@ -615,20 +615,20 @@ class Tournament(models.Model): |
|
|
|
|
# Add full matches from the next rounds |
|
|
|
|
next_round = self.round_for_index(current_round.index - 1) |
|
|
|
|
if next_round: |
|
|
|
|
print('next round') |
|
|
|
|
# print('next round') |
|
|
|
|
matches.extend(next_round.get_matches_recursive(True)) |
|
|
|
|
|
|
|
|
|
if all_upper_matches_are_over is True: |
|
|
|
|
print('all_upper_matches_are_over') |
|
|
|
|
# print('all_upper_matches_are_over') |
|
|
|
|
matches.extend(current_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: |
|
|
|
|
print('previous_round') |
|
|
|
|
# print('previous_round') |
|
|
|
|
matches.extend(previous_round.get_matches_recursive(True)) |
|
|
|
|
else: |
|
|
|
|
print('group_stages') |
|
|
|
|
# print('group_stages') |
|
|
|
|
group_stages = [gs.live_group_stages() for gs in self.last_group_stage_step()] |
|
|
|
|
|
|
|
|
|
return matches, group_stages |
|
|
|
|
@ -669,7 +669,7 @@ 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] |
|
|
|
|
print(f'first_unfinished_match > match len: {len(matches)}') |
|
|
|
|
# print(f'first_unfinished_match > match len: {len(matches)}') |
|
|
|
|
matches.sort(key=lambda m: m.start_date) |
|
|
|
|
if matches: |
|
|
|
|
return matches[0] |
|
|
|
|
@ -677,20 +677,20 @@ class Tournament(models.Model): |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
def round_to_show(self): |
|
|
|
|
print('===== round_to_show') |
|
|
|
|
# print('===== round_to_show') |
|
|
|
|
last_started_match = self.first_unfinished_match() |
|
|
|
|
if last_started_match: |
|
|
|
|
print(f'last_started_match = {last_started_match.name}') |
|
|
|
|
# print(f'last_started_match = {last_started_match.name}') |
|
|
|
|
current_round = last_started_match.round.root_round() |
|
|
|
|
print(f'round_to_show > current_round: {current_round.name()}') |
|
|
|
|
# print(f'round_to_show > current_round: {current_round.name()}') |
|
|
|
|
if current_round: |
|
|
|
|
return current_round |
|
|
|
|
|
|
|
|
|
# all started matches have ended, possibly |
|
|
|
|
last_finished_match = self.last_finished_match() |
|
|
|
|
print(f'last_finished_match = {last_finished_match.name}') |
|
|
|
|
# print(f'last_finished_match = {last_finished_match.name}') |
|
|
|
|
round_root_index = last_finished_match.round.root_round().index |
|
|
|
|
print(f'round_index = {round_root_index}') |
|
|
|
|
# print(f'round_index = {round_root_index}') |
|
|
|
|
if round_root_index == 0: |
|
|
|
|
return last_finished_match.round |
|
|
|
|
else: |
|
|
|
|
@ -700,14 +700,6 @@ class Tournament(models.Model): |
|
|
|
|
else: |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
# main_rounds = list(self.round_set.filter(parent=None).all()) |
|
|
|
|
# main_rounds.sort(key=lambda r: r.index) |
|
|
|
|
# if main_rounds: |
|
|
|
|
# print(f'round_to_show > main_rounds: {main_rounds[0].name()}') |
|
|
|
|
# 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] |
|
|
|
|
matches.sort(key=lambda m: m.start_date, reverse=True) |
|
|
|
|
|