diff --git a/tournaments/views.py b/tournaments/views.py index c8203e5..e54e3ea 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -155,13 +155,20 @@ def future_tournaments(club_id): def index_new(request): + now = timezone.now() + thirty_days_ago = now - timedelta(days=30) + thirty_days_future = now + timedelta(days=30) club_id = request.GET.get('club') - tournaments = tournaments_query_new(Q(end_date__isnull=True), club_id, True, None) + tournaments = tournaments_query_new(Q(end_date__isnull=True, start_date__gte=thirty_days_ago, start_date__lte=thirty_days_future), club_id, True, None) display_tournament = [t for t in tournaments if t.display_tournament()] - live = [t for t in display_tournament if t.supposedly_in_progress()] - future = [t for t in display_tournament if t.starts_in_the_future()] - + live = [] + future = [] + for t in display_tournament: + if t.supposedly_in_progress(): + live.append(t) + elif t.starts_in_the_future(): + future.append(t) clean_ended_tournaments = tournaments_query_new(Q(end_date__isnull=False), club_id, False, 50) clean_ended_tournaments = [t for t in clean_ended_tournaments if t.display_tournament()] ended_tournaments = [t for t in display_tournament if t.should_be_over()]