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