|
|
|
@ -20,20 +20,16 @@ def index(request):
|
|
|
|
|
context["my_shifts"] = helper.shiftregistration_set.filter(
|
|
|
|
|
shift__start_at__gt=timezone.now()
|
|
|
|
|
).order_by("shift__start_at")
|
|
|
|
|
context["current_shift"] = next(
|
|
|
|
|
iter(
|
|
|
|
|
helper.shiftregistration_set.annotate(
|
|
|
|
|
shift_end=ExpressionWrapper(
|
|
|
|
|
F("shift__start_at") + F("shift__duration"),
|
|
|
|
|
output_field=DateTimeField(),
|
|
|
|
|
)
|
|
|
|
|
context["current_shift"] = (
|
|
|
|
|
helper.shiftregistration_set.annotate(
|
|
|
|
|
shift_end=ExpressionWrapper(
|
|
|
|
|
F("shift__start_at") + F("shift__duration"),
|
|
|
|
|
output_field=DateTimeField(),
|
|
|
|
|
)
|
|
|
|
|
.filter(
|
|
|
|
|
shift__start_at__lte=timezone.now(), shift_end__gte=timezone.now()
|
|
|
|
|
)
|
|
|
|
|
.order_by("shift__start_at")[:1]
|
|
|
|
|
),
|
|
|
|
|
None,
|
|
|
|
|
)
|
|
|
|
|
.filter(shift__start_at__lte=timezone.now(), shift_end__gte=timezone.now())
|
|
|
|
|
.order_by("shift__start_at")
|
|
|
|
|
.first()
|
|
|
|
|
)
|
|
|
|
|
free_shifts = (
|
|
|
|
|
Shift.objects.annotate(reg_count=Count("shiftregistration"))
|
|
|
|
|