|
|
|
@ -20,9 +20,10 @@ def index(request):
|
|
|
|
|
if request.session.get("last_seen_shift"):
|
|
|
|
|
del request.session["last_seen_shift"]
|
|
|
|
|
|
|
|
|
|
# dont show shifts starting in <60 minutes?
|
|
|
|
|
# currently only sorts by date
|
|
|
|
|
context = {}
|
|
|
|
|
context = {
|
|
|
|
|
"days": Shift.objects.datetimes("start_at", "day"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if request.helper:
|
|
|
|
|
context["my_future_shifts"] = (
|
|
|
|
|
reg.shift
|
|
|
|
@ -42,29 +43,24 @@ def index(request):
|
|
|
|
|
help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(required_helpers=0) & Q(
|
|
|
|
|
room__required_helpers__gt=F("reg_count")
|
|
|
|
|
)
|
|
|
|
|
free_shifts = (
|
|
|
|
|
Shift.with_reg_count()
|
|
|
|
|
.filter(
|
|
|
|
|
help_wanted,
|
|
|
|
|
start_at__gt=timezone.now(),
|
|
|
|
|
deleted=False,
|
|
|
|
|
)
|
|
|
|
|
.order_by("start_at")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if request.helper:
|
|
|
|
|
# dont show shifts starting in <60 minutes?
|
|
|
|
|
# currently only sorts by date
|
|
|
|
|
free_shifts = (
|
|
|
|
|
Shift.with_reg_count()
|
|
|
|
|
.filter(
|
|
|
|
|
help_wanted,
|
|
|
|
|
start_at__date=day.date(),
|
|
|
|
|
start_at__gt=timezone.now(),
|
|
|
|
|
deleted=False,
|
|
|
|
|
)
|
|
|
|
|
.filter(~Q(shiftregistration__helper=request.helper))
|
|
|
|
|
.order_by("start_at")
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
context["free_shifts"] = free_shifts
|
|
|
|
|
context["free_shifts"] = list(map(lambda qs: list(qs), filter(lambda qs: qs.exists(), free_shifts)))
|
|
|
|
|
return render(request, "shiftlist.html", context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|