Laurent 9 months ago
commit 299c2519e6
  1. 2
      tournaments/models/group_stage.py
  2. 3
      tournaments/models/match.py
  3. 23
      tournaments/models/tournament.py

@ -140,7 +140,7 @@ class GroupStage(models.Model):
return False return False
def is_completed(self): def is_completed(self):
return not self.match_set.filter(end_date__isnull=True).exists() return not self.match_set.filter(end_date__isnull=True).exists() and self.match_set.count() > 0
class LiveGroupStage: class LiveGroupStage:
def __init__(self, title, step, index): def __init__(self, title, step, index):

@ -137,6 +137,9 @@ class Match(models.Model):
team = Team(None, image, names, scores, weight, is_winner, walk_out) team = Team(None, image, names, scores, weight, is_winner, walk_out)
return team return team
def is_ready(self):
return self.team_scores.count() == 2
def live_teams(self): def live_teams(self):
#print('player names from match') #print('player names from match')
##return map(lambda ts: ts.player_names(), self.team_scores.all()) ##return map(lambda ts: ts.player_names(), self.team_scores.all())

@ -900,7 +900,28 @@ class Tournament(models.Model):
timezoned_datetime = timezone.localtime(self.start_date) timezoned_datetime = timezone.localtime(self.start_date)
end = timezoned_datetime + timedelta(days=self.day_duration + 1) end = timezoned_datetime + timedelta(days=self.day_duration + 1)
now = timezone.now() now = timezone.now()
return now >= end and self.is_build_and_not_empty() return now >= end and self.is_build_and_not_empty() and self.nearly_over()
def nearly_over(self):
# First check group stages if they exist
if self.groupstage_set.count() > 0:
# Check if all group stages are completed
for group_stage in self.groupstage_set.all():
if group_stage.is_completed():
return True
# If no group stages, check semi-finals
if self.round_set.count() > 0:
# Get round with index 1 (semi-finals) and no parent
semifinals = self.round_set.filter(index=1, parent=None).first()
if semifinals:
# Check if any match in semi-finals has started
for match in semifinals.match_set.all():
if match.start_date is not None and match.is_ready():
return True
return False
return False
def display_points_earned(self): def display_points_earned(self):
return self.federal_level_category != FederalLevelCategory.UNLISTED and self.hide_points_earned is False return self.federal_level_category != FederalLevelCategory.UNLISTED and self.hide_points_earned is False

Loading…
Cancel
Save