diff --git a/app/app/views.py b/app/app/views.py index 4a15de11..f8cc1b29 100644 --- a/app/app/views.py +++ b/app/app/views.py @@ -1,6 +1,3 @@ -import os - -from django.contrib.postgres.search import SearchHeadline, SearchQuery, SearchRank from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.db.models import Count from django.http import HttpResponse @@ -230,45 +227,6 @@ def institutions(request): return render(request, template_name=template, context=context) -def search(request): - q = request.GET.get("q") - - if q: - queue = SearchQuery(q) - search_headline = SearchHeadline("document_data", queue) - - documents = ( - DocumentFile.objects.annotate(rank=SearchRank("search_vector", queue)) - .annotate(search_headline=search_headline) - .filter(search_vector=queue) - .order_by("-rank") - ) - - else: - documents = None - - # Create a Paginator instance with the documents and the number of items per page - paginator = Paginator(documents, 10) if documents else None # Show 10 documents per page - - # Get the page number from the request's GET parameters - page_number = request.GET.get("page") - - # Use the get_page method to get the Page object for that page number - page_obj = paginator.get_page(page_number) if paginator else None - - feature_flag = os.getenv("FEATURE_FLAG", False) - - template = "app/search.html" - context = { - "documents": page_obj, - "current_page": "search", - "document_count": len(documents) if documents else 0, - "feature_flag": feature_flag, - } - - return render(request, template_name=template, context=context) - - def search(request): page_number = request.GET.get("page", "1") if not page_number.isdigit():