diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py index 5d323ba..092cb3e 100644 --- a/tournaments/models/group_stage.py +++ b/tournaments/models/group_stage.py @@ -97,8 +97,8 @@ class GroupStage(models.Model): def starts_soon(self): if self.start_date: - early_start = self.start_date - timedelta(minute=30) - return datetime.now() > early_start + early_start = self.start_date - timedelta(minutes=30) + return timezone.now() > early_start else: return False diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index b2c60dd..cc4e479 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -400,11 +400,10 @@ class Tournament(models.Model): matches = [] group_stages = [] - if self.group_stages_running(): + if len(self.groupstage_set.all()) > 0 and self.no_bracket_match_has_started(): group_stages = self.live_group_stages() matches = self.broadcasted_group_stages_matches() else: - # last_started_match = self.first_unfinished_match() current_round = self.round_to_show() if current_round: previous_round = self.round_for_index(current_round.index + 1) @@ -418,6 +417,14 @@ class Tournament(models.Model): return matches, group_stages + def no_bracket_match_has_started(self): + matches = [] + for round in self.round_set.all(): + for match in round.match_set.all(): + if match.started(): + return False + return True + def all_matches(self, hide_empty_matches): matches = [] for round in self.round_set.all(): @@ -437,6 +444,7 @@ class Tournament(models.Model): def group_stages_running(self): if len(self.groupstage_set.all()) > 0: + # check le debut des match de Round matches = self.group_stage_matches() running_group_stage_matches = [m for m in matches if m.end_date is None] return len(running_group_stage_matches) > 0