From 2dcf6d7c9e831d18b46e8c99dc136d8fd04b1869 Mon Sep 17 00:00:00 2001 From: magmaus3 Date: Mon, 31 Oct 2022 17:35:33 +0100 Subject: [PATCH] Fix bug related to arguments not being transferred over pages --- iwm_browser/main.py | 11 ++++++----- iwm_browser/templates/search.html | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/iwm_browser/main.py b/iwm_browser/main.py index 01ab96a..2046143 100644 --- a/iwm_browser/main.py +++ b/iwm_browser/main.py @@ -38,7 +38,7 @@ async def root(): async def search( q: Union[str, None] = None, p: int = 0, - sort: str = "average_Rating", + sort: str = "average_rating", dir: str = "desc", date: int = -1 ): @@ -46,7 +46,9 @@ async def search( limit = 10 if p is None: p = 0 - + + # Passed to the template + QueryValues = {"q": q, "p": p, "sort": sort, "dir": dir, "date": date} searchResults = None if q is not None: @@ -115,12 +117,11 @@ async def search( entryNumber = None return template.render( - searchValue=searchValue, - searchPage=p, searchResults=searchResults, THUMB_URL=THUMB_URL, entryLimit=limit, - entryNumber=entryNumber + entryNumber=entryNumber, + QueryValues=QueryValues ) @app.get("/level/{level_id}", response_class=HTMLResponse) diff --git a/iwm_browser/templates/search.html b/iwm_browser/templates/search.html index 3b2b37f..6a49c34 100644 --- a/iwm_browser/templates/search.html +++ b/iwm_browser/templates/search.html @@ -27,7 +27,7 @@
+ {% set searchPage = QueryValues['p'] %}

Page {{ searchPage+1 }}

- {% if not searchPage <= 0 %}Prev{% endif %} - {% if not entryNumber < entryLimit %}Next{% endif %} + {% if not searchPage <= 0 %}Prev{% endif %} + {% if not entryNumber < entryLimit %}Next{% endif %}
{% endif %}