diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-03-01 16:48:08 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-03-01 16:51:12 +0100 |
commit | a456cce506cbbcffb86bb150540e14df26fe604b (patch) | |
tree | b08190aec4c470d96e49c3bda2cef0b5adb64f9d /ishtar_common | |
parent | f85af6310ff8743e343316915ed4bc9de979cd22 (diff) | |
download | Ishtar-a456cce506cbbcffb86bb150540e14df26fe604b.tar.bz2 Ishtar-a456cce506cbbcffb86bb150540e14df26fe604b.zip |
Gallery: fix pagination
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 2 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 7 |
2 files changed, 6 insertions, 3 deletions
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": |