diff options
author | Matthew Lemon <y@yulqen.org> | 2024-09-03 17:08:38 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-09-03 17:08:38 +0100 |
commit | 1fba7b90feb50ec43d3d355dd8e54f834e648810 (patch) | |
tree | fedeb3214966a068fabfac602c36d1872be39686 /pyblackbird_cc/resources | |
parent | cc78f9e3b20c1e46d1b6c59ecbe45a819c1765c6 (diff) |
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.
Diffstat (limited to 'pyblackbird_cc/resources')
-rw-r--r-- | pyblackbird_cc/resources/views.py | 13 |
1 files changed, 7 insertions, 6 deletions
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, |