From df0f28efb28f9089297459c794f435f0cb064121 Mon Sep 17 00:00:00 2001 From: Luca Date: Tue, 14 May 2024 22:59:44 +0200 Subject: [PATCH] feat(checkin): paginate checkin list --- shiftregister/team/templates/checkin_list.html | 5 +++-- shiftregister/team/views.py | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/shiftregister/team/templates/checkin_list.html b/shiftregister/team/templates/checkin_list.html index 7294294..9c0723f 100644 --- a/shiftregister/team/templates/checkin_list.html +++ b/shiftregister/team/templates/checkin_list.html @@ -5,7 +5,7 @@ {% block content %}

{{ title }}

- +
@@ -16,7 +16,7 @@ -{% for reg in object_list %} +{% for reg in page_obj %}
Name
@@ -42,4 +42,5 @@ {% endfor %}
+{% include "pagination.html" %} {% endblock %} diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 8b30e20..2bd041a 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -284,20 +284,23 @@ class RoomShiftList(ShiftList): class CheckinList(LoginRequiredMixin, ListView): - template_name = "checkin_list.html" model = Shift - title = "Ankommende Helfer:innen" + paginate_by = 30 + template_name = "checkin_list.html" + title = "Ankommende Helfer*innen" def get_queryset(self): return ( ShiftRegistration.objects.select_related("helper", "shift") .prefetch_related("shift__event__calendar") .filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED) - .order_by("shift__start_at")[:30] ) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) + context["page_range"] = context["paginator"].get_elided_page_range( + context["page_obj"].number + ) context["title"] = self.title return context