Skip to content

Commit

Permalink
clean up of code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-gray-tangent committed Jul 10, 2024
1 parent b6d7890 commit 1046333
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/app/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# from pprint import pprint
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db.models import Count
from django.http import HttpResponse
Expand Down Expand Up @@ -229,6 +228,10 @@ def institutions(request):


def search(request):
page_number = request.GET.get("page", "1")
if not page_number.isdigit():
page_number = "1"

f = DocumentFileFilter(request.GET, queryset=DocumentFile.objects.all())

template = "app/search.html"
Expand All @@ -237,16 +240,13 @@ def search(request):

print(paginator)

page_number = request.GET.get("page")

try:
page_obj = paginator.page(page_number)
except PageNotAnInteger:
page_obj = paginator.page(1)
except EmptyPage:
page_obj = paginator.page(paginator.num_pages)

print(page_obj)
# Update the context with the page object
context = {
"search_results": paginator.page(page_obj.number),
Expand Down
2 changes: 1 addition & 1 deletion app/general/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Meta:

def filter_search(self, queryset, name, value):
if value:
queue = SearchQuery(value)
queue = SearchQuery(value.strip())
search_rank = SearchRank(F("search_vector"), queue)
search_headline = SearchHeadline("document_data", queue)
queryset = (
Expand Down

0 comments on commit 1046333

Please sign in to comment.