From 1fba7b90feb50ec43d3d355dd8e54f834e648810 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 3 Sep 2024 17:08:38 +0100 Subject: Fix for tabbed filter in resource list page Previously the link selected on the tabbed filter navbar in resources list would filter the featured resources too. This fixes that. --- pyblackbird_cc/resources/views.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'pyblackbird_cc/resources') diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index ab12b64..1f68768 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -121,18 +121,19 @@ def index(request): categories = ResourceCategory.objects.all() category = request.GET.get('category', 'all') - if category != 'all': - resource_objs = resource_objs.filter(main_resource_category__name=category) - resource_list = [_extract_metadata_from_resource(r) for r in resource_objs] - paginator = Paginator(resource_list, 20) - page_number = request.GET.get('page') - page_obj = paginator.get_page(page_number) # Create a separate queryset for Featured resources featured_resources = [r for r in resource_list if r.feature_slot] featured_resources = sorted(featured_resources, key=lambda resource: resource.feature_slot) + if category != 'all': + resource_list = [r for r in resource_list if r.main_resource_category_name == category] + + paginator = Paginator(resource_list, 20) + page_number = request.GET.get('page') + page_obj = paginator.get_page(page_number) + context = { "page_obj": page_obj, "categories": categories, -- cgit v1.2.3