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

View File

@ -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