fix max number of rental item filters
This commit is contained in:
@@ -20,10 +20,10 @@ class RentalListView(ListView):
|
|||||||
rentalitem_filters = []
|
rentalitem_filters = []
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
# Get the rental items from the filter
|
# Get the rental items from the filter (max. 4)
|
||||||
self.rentalitem_filters = request.GET.getlist("rentalitems", [])
|
self.rentalitem_filters = request.GET.getlist("rentalitems", [])[:4]
|
||||||
if not self.rentalitem_filters:
|
if not self.rentalitem_filters:
|
||||||
for rentalitem in RentalItem.objects.all():
|
for rentalitem in RentalItem.objects.all()[:4]:
|
||||||
self.rentalitem_filters.append(rentalitem.name)
|
self.rentalitem_filters.append(rentalitem.name)
|
||||||
|
|
||||||
# Get the displayed month from the request
|
# Get the displayed month from the request
|
||||||
@@ -98,8 +98,8 @@ class RentalListView(ListView):
|
|||||||
# Add rental items to the context for the filter
|
# Add rental items to the context for the filter
|
||||||
context["rentalitems"] = RentalItem.objects.all()
|
context["rentalitems"] = RentalItem.objects.all()
|
||||||
|
|
||||||
# Add the (max. 4) selected rental items to the context for the filter
|
# Add the selected rental items to the context for the filter
|
||||||
context["rentalitem_filters"] = {"rentalitems": self.rentalitem_filters[:4]}
|
context["rentalitem_filters"] = {"rentalitems": self.rentalitem_filters}
|
||||||
|
|
||||||
context["rental_dict"] = rental_dict
|
context["rental_dict"] = rental_dict
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user