From 2fce92acf8816d288a08e02e6c69ca1900e6f7f4 Mon Sep 17 00:00:00 2001 From: SDE Date: Tue, 29 Aug 2023 17:06:15 +0300 Subject: [PATCH] 0.6.1 routes filter pagination --- RoutesApp/funcs.py | 9 ++++++++- RoutesApp/js_views.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/RoutesApp/funcs.py b/RoutesApp/funcs.py index 346847a..f654761 100644 --- a/RoutesApp/funcs.py +++ b/RoutesApp/funcs.py @@ -39,6 +39,8 @@ def get_routes_Dict(user=None, data=None): to_el = int(val) routes = Route.objects.filter(**kwargs).order_by('-modifiedDT') + routes_count = routes.count() + if from_el and to_el: routes = routes[from_el:to_el] elif from_el: @@ -48,6 +50,10 @@ def get_routes_Dict(user=None, data=None): else: routes = routes[:25] + last_block_routes = False + if to_el and to_el >= routes_count: + last_block_routes = True + res_Dict = {} try: @@ -72,7 +78,8 @@ def get_routes_Dict(user=None, data=None): print(msg) res_Dict = { - 'routes': routes + 'routes': routes, + 'last_block_routes': last_block_routes } return res_Dict diff --git a/RoutesApp/js_views.py b/RoutesApp/js_views.py index 53cda2f..e1c97a1 100644 --- a/RoutesApp/js_views.py +++ b/RoutesApp/js_views.py @@ -169,6 +169,7 @@ def find_routes_ajax(request): res_Dict = { 'html': html, + 'last_block_routes': routes_Dict['last_block_routes'] # 'form': RouteForm(initial=data) }