Add tournament team positioning check for live view

apikeys
Razmig Sarkissian 4 months ago
parent 6e25edb545
commit 206ff43ae3
  1. 3
      tournaments/models/team_registration.py
  2. 7
      tournaments/models/tournament.py
  3. 4
      tournaments/views.py

@ -519,3 +519,6 @@ class TeamRegistration(TournamentSubModel):
if self.group_stage_position is not None: if self.group_stage_position is not None:
return False return False
return True return True
def is_positioned(self):
return self.bracket_position is not None or self.group_stage_position is not None

@ -1013,6 +1013,13 @@ class Tournament(BaseModel):
def will_start_soon(self, hour_delta=2): def will_start_soon(self, hour_delta=2):
return self.has_started(hour_delta=hour_delta) 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): def supposedly_in_progress(self):
start = self.start_date - timedelta(hours=1) start = self.start_date - timedelta(hours=1)
end = self.start_date + timedelta(days=self.day_duration + 1) end = self.start_date + timedelta(days=self.day_duration + 1)

@ -88,7 +88,7 @@ def index(request):
live = [] live = []
future = [] future = []
for t in display_tournament: for t in display_tournament:
if t.supposedly_in_progress(): if t.supposedly_in_progress() and t.are_teams_positioned():
live.append(t) live.append(t)
elif t.starts_in_the_future(): elif t.starts_in_the_future():
future.append(t) future.append(t)
@ -165,7 +165,7 @@ def finished_tournaments(club_id, limit=None):
def live_tournaments(club_id, limit=None): def live_tournaments(club_id, limit=None):
tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True, limit) 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): def future_tournaments(club_id, limit=None):
tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True, limit) tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True, limit)

Loading…
Cancel
Save