From 97f24254349c0af06cd36118e270241b80047aef Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Sat, 22 Feb 2025 16:12:18 +0100 Subject: [PATCH] fix max number of rental item filters --- fet2020/rental/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fet2020/rental/views.py b/fet2020/rental/views.py index 3dc3a047..c43331c1 100644 --- a/fet2020/rental/views.py +++ b/fet2020/rental/views.py @@ -20,10 +20,10 @@ class RentalListView(ListView): rentalitem_filters = [] def get(self, request, *args, **kwargs): - # Get the rental items from the filter - self.rentalitem_filters = request.GET.getlist("rentalitems", []) + # Get the rental items from the filter (max. 4) + self.rentalitem_filters = request.GET.getlist("rentalitems", [])[:4] if not self.rentalitem_filters: - for rentalitem in RentalItem.objects.all(): + for rentalitem in RentalItem.objects.all()[:4]: self.rentalitem_filters.append(rentalitem.name) # Get the displayed month from the request @@ -98,8 +98,8 @@ class RentalListView(ListView): # Add rental items to the context for the filter context["rentalitems"] = RentalItem.objects.all() - # Add the (max. 4) selected rental items to the context for the filter - context["rentalitem_filters"] = {"rentalitems": self.rentalitem_filters[:4]} + # Add the selected rental items to the context for the filter + context["rentalitem_filters"] = {"rentalitems": self.rentalitem_filters} context["rental_dict"] = rental_dict