From 9f21a02aa12ad1e714706f79b993f4a668fa9369 Mon Sep 17 00:00:00 2001 From: StephDriver <5330770+StephDriver@users.noreply.github.com> Date: Fri, 12 Sep 2025 15:23:25 +0100 Subject: [PATCH 1/7] a11y: #4839 full-text-search add pagination --- src/journal/views.py | 23 ++++++++++++++++++- .../templates/journal/full-text-search.html | 6 +++-- .../templates/journal/full-text-search.html | 6 +++-- .../templates/journal/full-text-search.html | 5 +++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/journal/views.py b/src/journal/views.py index 32109a44e9..0311ea0e0b 100755 --- a/src/journal/views.py +++ b/src/journal/views.py @@ -2220,6 +2220,9 @@ def full_text_search(request): search_term, keyword, sort, form, redir = logic.handle_search_controls( request, ) + + form.id = "search_form" + if search_term: form.is_valid() articles = submission_models.Article.objects.search( @@ -2229,12 +2232,30 @@ def full_text_search(request): site=request.site_object, ) + paginate_by = request.GET.get("paginate_by", 25) + if paginate_by == "all": + paginate_by = len(articles) if articles else 25 + + paginator = Paginator(articles, paginate_by) + page_number = request.GET.get("page") + + try: + page_obj = paginator.get_page(page_number) + except (EmptyPage, PageNotAnInteger): + page_obj = paginator.get_page(1) + template = "journal/full-text-search.html" context = { - "articles": articles, + "articles": page_obj, + "page_obj": page_obj, + "is_paginated": page_obj.has_other_pages(), + "paginate_by": paginate_by, "article_search": search_term, "keyword": keyword, "form": form, + "facet_form": form, + "order_by_choices": form.fields["sort"].choices, + "order_by": sort, } return render(request, template, context) diff --git a/src/themes/OLH/templates/journal/full-text-search.html b/src/themes/OLH/templates/journal/full-text-search.html index 8a9b80526c..6cb8abfc35 100644 --- a/src/themes/OLH/templates/journal/full-text-search.html +++ b/src/themes/OLH/templates/journal/full-text-search.html @@ -27,12 +27,14 @@
{% trans 'No articles to display' %}.
{% endfor %} - + {% if articles %} + {% include "elements/pagination.html" with form_id=facet_form.id %} + {% endif %}