2
0
Fork 0

feat(checkin): paginate checkin list

This commit is contained in:
Luca 2024-05-14 22:59:44 +02:00
parent 54f11c74cb
commit df0f28efb2
2 changed files with 9 additions and 5 deletions

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h3 class="title">{{ title }}</h3> <h3 class="title">{{ title }}</h3>
<table class="table"> <table class="table is-fullwidth">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@ -16,7 +16,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for reg in object_list %} {% for reg in page_obj %}
<tr> <tr>
<td> <td>
<a href="{% url 'team:helper' reg.helper.pk %}"> <a href="{% url 'team:helper' reg.helper.pk %}">
@ -42,4 +42,5 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% include "pagination.html" %}
{% endblock %} {% endblock %}

View File

@ -284,20 +284,23 @@ class RoomShiftList(ShiftList):
class CheckinList(LoginRequiredMixin, ListView): class CheckinList(LoginRequiredMixin, ListView):
template_name = "checkin_list.html"
model = Shift model = Shift
title = "Ankommende Helfer:innen" paginate_by = 30
template_name = "checkin_list.html"
title = "Ankommende Helfer*innen"
def get_queryset(self): def get_queryset(self):
return ( return (
ShiftRegistration.objects.select_related("helper", "shift") ShiftRegistration.objects.select_related("helper", "shift")
.prefetch_related("shift__event__calendar") .prefetch_related("shift__event__calendar")
.filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED) .filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED)
.order_by("shift__start_at")[:30]
) )
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["page_range"] = context["paginator"].get_elided_page_range(
context["page_obj"].number
)
context["title"] = self.title context["title"] = self.title
return context return context