diff --git a/tournaments/models/team_registration.py b/tournaments/models/team_registration.py index deb7ed3..a40af2f 100644 --- a/tournaments/models/team_registration.py +++ b/tournaments/models/team_registration.py @@ -519,3 +519,6 @@ class TeamRegistration(TournamentSubModel): if self.group_stage_position is not None: return False return True + + def is_positioned(self): + return self.bracket_position is not None or self.group_stage_position is not None diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index e831d46..11b22a1 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1013,6 +1013,13 @@ class Tournament(BaseModel): def will_start_soon(self, hour_delta=2): return self.has_started(hour_delta=hour_delta) + def are_teams_positioned(self): + teams = self.teams(True) + filtered_teams = [t for t in teams if t.is_positioned()] + if len(filtered_teams) > 3: + return True + return False + def supposedly_in_progress(self): start = self.start_date - timedelta(hours=1) end = self.start_date + timedelta(days=self.day_duration + 1) diff --git a/tournaments/views.py b/tournaments/views.py index 6391888..39b3817 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -88,7 +88,7 @@ def index(request): live = [] future = [] for t in display_tournament: - if t.supposedly_in_progress(): + if t.supposedly_in_progress() and t.are_teams_positioned(): live.append(t) elif t.starts_in_the_future(): future.append(t) @@ -165,7 +165,7 @@ def finished_tournaments(club_id, limit=None): def live_tournaments(club_id, limit=None): tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True, limit) - return [t for t in tournaments if t.display_tournament() and t.supposedly_in_progress()] + return [t for t in tournaments if t.display_tournament() and t.supposedly_in_progress() and t.are_teams_positioned()] def future_tournaments(club_id, limit=None): tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True, limit)