2
0
Fork 0

Force 'my_future_shifts' query and reformat code

This commit is contained in:
Luca 2022-05-16 23:12:28 +02:00
parent 6d2d70e0d5
commit e7029e4002
1 changed files with 8 additions and 3 deletions

View File

@ -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)