-
{{ shift.room.name }}
+
{% include "partials/shift_box.html" %}
diff --git a/shiftregister/team/urls.py b/shiftregister/team/urls.py
index 2ca83eb..f8a4296 100644
--- a/shiftregister/team/urls.py
+++ b/shiftregister/team/urls.py
@@ -7,6 +7,7 @@ urlpatterns = [
path("", views.shift_overview, name="index"),
path("overview/", views.shift_overview, name="shift_overview"),
path("shifts/", views.ShiftList.as_view(), name="shift_all"),
+ path("room_shifts/
", views.RoomShiftList.as_view(), name="shift_room"),
path("free_shifts/", views.FreeShiftList.as_view(), name="shift_free"),
path("shift/", views.shift_detail, name="shift"),
path("helper/", views.HelperDetail.as_view(), name="helper"),
diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py
index 5407426..0683684 100644
--- a/shiftregister/team/views.py
+++ b/shiftregister/team/views.py
@@ -40,7 +40,7 @@ def shift_overview(request):
Shift.objects.filter(room=room, start_at__gt=timezone.now(), deleted=False)
.order_by("start_at")
.first()
- for room in Room.objects.all()
+ for room in Room.objects.all().order_by("name")
),
)
@@ -187,7 +187,7 @@ class ShiftList(LoginRequiredMixin, ListView):
return context
def get_ordering(self):
- return ("start_at", "room_id")
+ return ("start_at", "room__name")
class FreeShiftList(ShiftList):
@@ -210,7 +210,29 @@ class FreeShiftList(ShiftList):
end_at__gte=timezone.now(),
deleted=False,
)
- .order_by("start_at", "room_id")
+ .order_by("start_at", "room__name")
+ )
+
+
+class RoomShiftList(ShiftList):
+ def get_context_data(self, **kwargs):
+ room = get_object_or_404(Room, pk=self.kwargs["pk"])
+ context = super().get_context_data(**kwargs)
+ context["title"] = f"Schichten fuer {room.name}"
+ return context
+
+ def get_queryset(self):
+ room = get_object_or_404(Room, pk=self.kwargs["pk"])
+ help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(
+ required_helpers=0
+ ) & Q(room__required_helpers__gt=F("reg_count"))
+ return (
+ Shift.with_reg_count()
+ .filter(
+ deleted=False,
+ room=room,
+ )
+ .order_by("start_at", "room__name")
)