summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md2
-rw-r--r--ishtar_common/static/js/ishtar.js2
-rw-r--r--ishtar_common/views_item.py7
3 files changed, 7 insertions, 4 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 98e351fa2..f89952de4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,7 +6,7 @@ v3.1.2 - 2021-03-01
### Bug fixes ###
- tables: pinned search do not overload click on shortcuts
-
+- gallery: fix pagination
v3.1.1 - 2021-02-28
--------------------
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js
index 686156083..2b962c607 100644
--- a/ishtar_common/static/js/ishtar.js
+++ b/ishtar_common/static/js/ishtar.js
@@ -1288,7 +1288,7 @@ var render_gallery = function(data_table, table_name, nb_select, gallery_id){
var idx_page = 1;
if (page_current < 5){
while (idx_page <= 5){
- if (idx_page < page_total){
+ if (idx_page <= page_total){
html += render_paginate_button(idx_page, page_current);
}
idx_page += 1;
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index c562a5634..621b56136 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -1910,7 +1910,7 @@ def get_item(model, func_name, default_name, extra_request_keys=None,
if row_nb and data_type.startswith("json"):
try:
start = int(request_items.get('start'))
- page_nb = start / row_nb + 1
+ page_nb = start // row_nb + 1
assert page_nb >= 1
except (TypeError, ValueError, AssertionError):
start = 0
@@ -2038,6 +2038,9 @@ def get_item(model, func_name, default_name, extra_request_keys=None,
if full == 'shortcut':
data = json.dumps(rows)
else:
+ total = (
+ items_nb // row_nb + (1 if items_nb % row_nb else 0)
+ ) if row_nb else items_nb
data = json.dumps({
"recordsTotal": items_nb,
"recordsFiltered": items_nb,
@@ -2045,7 +2048,7 @@ def get_item(model, func_name, default_name, extra_request_keys=None,
"table-cols": table_cols,
"pinned-search": pinned_search,
"page": page_nb,
- "total": (items_nb / row_nb + 1) if row_nb else items_nb,
+ "total": total,
})
return HttpResponse(data, content_type='application/json')
elif data_type == "csv":