diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 617926c..5c21961 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -932,7 +932,7 @@ class Tournament(models.Model): # end = self.start_date + timedelta(days=self.day_duration + 1) # return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end - timezoned_datetime = timezone.localtime(self.start_date) + timezoned_datetime = self.local_start_date() end = timezoned_datetime + timedelta(days=self.day_duration + 1) now = timezone.now() @@ -946,6 +946,15 @@ class Tournament(models.Model): return start <= now <= end + def starts_in_the_future(self): + # tomorrow = datetime.now().date() + timedelta(days=1) + + timezoned_datetime = self.local_start_date() + start = timezoned_datetime.replace(hour=0, minute=0) + now = timezone.now() + + return start >= now + def should_be_over(self): if self.end_date is not None: return True diff --git a/tournaments/views.py b/tournaments/views.py index 7f9400e..2a82a98 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -150,9 +150,8 @@ def live_tournaments(club_id): return [t for t in tournaments if t.display_tournament() and t.supposedly_in_progress()] def future_tournaments(club_id): - tomorrow = datetime.now().date() + timedelta(days=1) - tournaments = tournaments_query(Q(end_date__isnull=True, start_date__gte=tomorrow), club_id, True) - return [t for t in tournaments if t.display_tournament()] + tournaments = tournaments_query(Q(end_date__isnull=True), club_id, True) + return [t for t in tournaments if t.display_tournament() and t.starts_in_the_future()] def tournament_info(request, tournament_id): tournament = get_object_or_404(Tournament, pk=tournament_id)