Commit 30d1caef authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

[pagination] Number of items per page as query parameter

parent c16822595d81
Pipeline #27938 passed with stage
in 2 minutes and 22 seconds
......@@ -127,7 +127,8 @@ class ElasticSearchView(StartupView):
def do_search(self, query_string):
get_connection(self._cw.vreg.config)
facet_selections = {}
start, stop = 0, 10
items_per_page = int(self._cw.form.get("items_per_page", 10))
start, stop = 0, items_per_page
for key, value in self._cw.form.items():
if key.startswith("es_"):
if isinstance(value, list):
......@@ -139,8 +140,8 @@ class ElasticSearchView(StartupView):
facet_selections[key.replace("es_", "")] = value
if key == "page":
try:
start = (max(int(value) - 1, 0)) * 10
stop = start + 10
start = (max(int(value) - 1, 0)) * items_per_page
stop = start + items_per_page
except ValueError:
pass
search = self.customize_search(query_string, facet_selections, start, stop)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment