|
|
|
@ -16,26 +16,22 @@ def index(request):
|
|
|
|
|
def shift_overview(request):
|
|
|
|
|
context = {}
|
|
|
|
|
context["running_shifts"] = (
|
|
|
|
|
reg.shift
|
|
|
|
|
for reg in ShiftRegistration.objects.annotate(
|
|
|
|
|
shift_end=ExpressionWrapper(
|
|
|
|
|
F("shift__start_at") + F("shift__duration"),
|
|
|
|
|
shift
|
|
|
|
|
for shift in Shift.objects.annotate(
|
|
|
|
|
end_at=ExpressionWrapper(
|
|
|
|
|
F("start_at") + F("duration"),
|
|
|
|
|
output_field=DateTimeField(),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.filter(shift__start_at__lte=timezone.now(), shift_end__gte=timezone.now())
|
|
|
|
|
.order_by("shift__start_at")
|
|
|
|
|
.filter(start_at__lte=timezone.now(), end_at__gte=timezone.now())
|
|
|
|
|
.order_by("start_at")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# probably can do some distinct/group by stuff but not sure how tih django queries
|
|
|
|
|
context["next_shifts"] = (
|
|
|
|
|
next(
|
|
|
|
|
iter(
|
|
|
|
|
Shift.objects.filter(room=room, start_at__gt=timezone.now()).order_by(
|
|
|
|
|
"start_at"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
Shift.objects.filter(room=room, start_at__gt=timezone.now())
|
|
|
|
|
.order_by("start_at")
|
|
|
|
|
.first()
|
|
|
|
|
for room in Room.objects.all()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|