Commit 4c6602dc authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

feat: allow to customize the pagination with `default_items_per_page` variable

parent 77d9424c9491
Pipeline #95278 passed with stages
in 2 minutes and 44 seconds
......@@ -122,6 +122,7 @@ class ElasticSearchView(StartupView):
next_link = u" > "
middle_link = u" · " * 3
title = _("Search")
default_items_per_page = 10
def render_search_comp(self):
search_comp = self._cw.vreg["components"].select_or_none(
......@@ -133,7 +134,9 @@ class ElasticSearchView(StartupView):
def do_search(self, query_string):
get_connection(self._cw.vreg.config)
facet_selections = {}
items_per_page = int(self._cw.form.get("items_per_page", 10))
items_per_page = int(
self._cw.form.get("items_per_page", self.default_items_per_page)
)
start, stop = 0, items_per_page
for key, value in self._cw.form.items():
if key.startswith("es_"):
......@@ -271,7 +274,9 @@ class ElasticSearchView(StartupView):
)
else:
ul(t.li(t.a(self.previous_link)))
total_pages = min((response.hits.total.value // 10) + 2, 1000)
total_pages = min(
(response.hits.total.value // self.default_items_per_page) + 2, 1000
)
page_padding = 3
if current_page > page_padding:
......
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