From 3bfb293b73233eb727f10307f9f1964b07af75e8 Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Mon, 23 Oct 2023 17:19:30 -0700 Subject: [PATCH] Logged out circles --- totem/circles/filters.py | 7 +++++++ totem/circles/views.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/totem/circles/filters.py b/totem/circles/filters.py index af839d1b..c1d8a262 100644 --- a/totem/circles/filters.py +++ b/totem/circles/filters.py @@ -22,3 +22,10 @@ def upcoming_events_user_can_attend(user: User, limit: int = 3): if len(filtered_events) >= limit: break return filtered_events + + +def logged_out_sessions_list(): + events = CircleEvent.objects.filter(start__gte=timezone.now(), cancelled=False, open=True) + events = events.order_by("start") + events = events.filter(circle__published=True) + return events diff --git a/totem/circles/views.py b/totem/circles/views.py index dea42db9..e1451356 100644 --- a/totem/circles/views.py +++ b/totem/circles/views.py @@ -7,6 +7,7 @@ from totem.users.models import User from totem.utils.hash import basic_hash +from .filters import logged_out_sessions_list from .models import Circle, CircleEvent, CircleEventException ICS_QUERY_PARAM = "key" @@ -128,7 +129,7 @@ def list(request): if request.user.is_authenticated: context = _logged_in_list(request.user) else: - events = CircleEvent.objects.filter(start__gte=timezone.now()).order_by("start") + events = logged_out_sessions_list() context = {"events": events, "attending_events": []} return render(request, "circles/list.html", context=context)