From faf0c62426cc4a6f464596af94440ef888ac283d Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 28 Mar 2020 17:38:10 -0700 Subject: [PATCH] Check if limit is falsey to avoid useless prevnext buttons. If limit is 0 then you get prev and next links which also have limit 0 and are pointless to click. --- .../etiquette_flask/backend/endpoints/photo_endpoints.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index 9f7614d..9a85702 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -415,7 +415,8 @@ def get_search_core(): offset = search_kwargs['offset'] or 0 original_params = request.args.to_dict() original_params['limit'] = limit - if len(photos) == limit: + + if limit and len(photos) == limit: next_params = original_params.copy() next_params['offset'] = offset + limit next_params = helpers.dict_to_params(next_params) @@ -423,7 +424,7 @@ def get_search_core(): else: next_page_url = None - if offset > 0: + if limit and offset > 0: prev_params = original_params.copy() prev_offset = max(0, offset - limit) if prev_offset > 0: