|
|
|
|
@ -102,7 +102,9 @@ class Tournament(models.Model): |
|
|
|
|
|
|
|
|
|
def filter_name(self): |
|
|
|
|
components = [self.formatted_start_date(), self.short_base_name()] |
|
|
|
|
if self.event.name: |
|
|
|
|
if self.event and self.event.club and self.event.club.name: |
|
|
|
|
components.append(self.event.club.name) |
|
|
|
|
elif self.event.name: |
|
|
|
|
components.append(self.event.name) |
|
|
|
|
elif self.name: |
|
|
|
|
components.append(self.name) |
|
|
|
|
@ -337,7 +339,6 @@ class Tournament(models.Model): |
|
|
|
|
else: |
|
|
|
|
matches = [m for m in matches if m.disabled is False] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if matches: |
|
|
|
|
group = self.create_match_group(round.name(), matches, broadcasted) |
|
|
|
|
groups.append(group) |
|
|
|
|
@ -360,7 +361,7 @@ class Tournament(models.Model): |
|
|
|
|
live_matches = [match.live_match() for match in matches] |
|
|
|
|
return MatchGroup(name, live_matches) |
|
|
|
|
|
|
|
|
|
def live_group_stages(self): |
|
|
|
|
def broadcasted_group_stages(self): |
|
|
|
|
group_stages = list(self.groupstage_set.all()) |
|
|
|
|
group_stages.sort(key=lambda gs: gs.index) |
|
|
|
|
return [gs.live_group_stages() for gs in group_stages] |
|
|
|
|
@ -400,8 +401,8 @@ class Tournament(models.Model): |
|
|
|
|
group_stages = [] |
|
|
|
|
|
|
|
|
|
if self.group_stages_running(): |
|
|
|
|
group_stages = self.live_group_stages() |
|
|
|
|
matches = self.group_stages_matches() |
|
|
|
|
group_stages = self.broadcasted_group_stages() |
|
|
|
|
matches = self.broadcasted_group_stages_matches() |
|
|
|
|
else: |
|
|
|
|
# last_started_match = self.first_unfinished_match() |
|
|
|
|
current_round = self.round_to_show() |
|
|
|
|
@ -413,7 +414,7 @@ class Tournament(models.Model): |
|
|
|
|
matches.extend(previous_round.get_matches_recursive(True)) |
|
|
|
|
else: |
|
|
|
|
matches.extend(current_round.all_matches(True)) |
|
|
|
|
group_stages = self.live_group_stages() |
|
|
|
|
group_stages = self.broadcasted_group_stages() |
|
|
|
|
|
|
|
|
|
return matches, group_stages |
|
|
|
|
|
|
|
|
|
@ -471,16 +472,24 @@ class Tournament(models.Model): |
|
|
|
|
def round_for_index(self, index): |
|
|
|
|
return self.round_set.filter(index=index, parent=None).first() |
|
|
|
|
|
|
|
|
|
def group_stages_matches(self): |
|
|
|
|
def broadcasted_group_stages_matches(self): |
|
|
|
|
matches = [] |
|
|
|
|
for group_stage in self.groupstage_set.all(): |
|
|
|
|
group_stages = self.elected_broadcast_group_stages() |
|
|
|
|
group_stages.sort(key=lambda gs: (gs.index, gs.start_date is None, gs.start_date)) |
|
|
|
|
for group_stage in group_stages: |
|
|
|
|
matches.extend(group_stage.match_set.all()) |
|
|
|
|
matches = [m for m in matches if m.should_appear()] |
|
|
|
|
# matches.sort(key=lambda m: (m.non_null_start_date(), m.index), reverse=True) |
|
|
|
|
matches.sort(key=lambda m: (m.start_date is None, m.end_date is not None, m.start_date, m.index)) |
|
|
|
|
|
|
|
|
|
return matches |
|
|
|
|
|
|
|
|
|
def elected_broadcast_group_stages(self): |
|
|
|
|
group_stages = list(self.groupstage_set.all()) |
|
|
|
|
started = [gs for gs in group_stages if gs.starts_soon()] |
|
|
|
|
if len(started) > 0: |
|
|
|
|
return started |
|
|
|
|
else: |
|
|
|
|
return group_stages |
|
|
|
|
|
|
|
|
|
def display_rankings(self): |
|
|
|
|
if self.publish_rankings is True and self.end_date is not None: |
|
|
|
|
return True |
|
|
|
|
@ -587,7 +596,7 @@ class Tournament(models.Model): |
|
|
|
|
return date.replace(hour=8, minute=0, second=0, microsecond=0) |
|
|
|
|
|
|
|
|
|
def supposedly_in_progress(self): |
|
|
|
|
end = self.start_date + timedelta(days=self.day_duration + 2) |
|
|
|
|
end = self.start_date + timedelta(days=self.day_duration + 1) |
|
|
|
|
return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end |
|
|
|
|
|
|
|
|
|
def display_points_earned(self): |
|
|
|
|
|