From e7029e4002be9989fec8bdd0bf93904a83d9318f Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 16 May 2022 23:12:28 +0200 Subject: [PATCH] Force 'my_future_shifts' query and reformat code --- shiftregister/app/views.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index fd66db7..83be945 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -25,7 +25,7 @@ def index(request): } if request.helper: - context["my_future_shifts"] = ( + context["my_future_shifts"] = list( reg.shift for reg in request.helper.shiftregistration_set.filter( shift__start_at__gt=timezone.now(), @@ -58,9 +58,14 @@ def index(request): for day in Shift.objects.datetimes("start_at", "day") ) if request.helper: - free_shifts = (day.filter(~Q(shiftregistration__helper=request.helper)) for day in free_shifts) + free_shifts = ( + day.filter(~Q(shiftregistration__helper=request.helper)) + for day in free_shifts + ) - context["free_shifts"] = list(map(lambda qs: list(qs), filter(lambda qs: qs.exists(), free_shifts))) + context["free_shifts"] = list( + map(lambda qs: list(qs), filter(lambda qs: qs.exists(), free_shifts)) + ) return render(request, "shiftlist.html", context)