From fc1654dedb99dbe6e0528a6ba67fd2dbdabcdfee Mon Sep 17 00:00:00 2001 From: SDE Date: Wed, 29 Nov 2023 16:52:20 +0300 Subject: [PATCH] 0.7.91 routes paging --- ArticlesApp/funcs.py | 4 ++-- RoutesApp/funcs.py | 13 ++++++++++--- RoutesApp/js_views.py | 3 ++- RoutesApp/views.py | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ArticlesApp/funcs.py b/ArticlesApp/funcs.py index 3331ecb..2d92211 100644 --- a/ArticlesApp/funcs.py +++ b/ArticlesApp/funcs.py @@ -1,7 +1,7 @@ from .models import * -elements_on_page = 10 +elements_on_page = 4 def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None): @@ -22,7 +22,7 @@ def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None): elif to_el: arts = arts[:to_el] else: - to_el = elements_on_page + 1 + to_el = elements_on_page arts = arts[:to_el] last_block = False diff --git a/RoutesApp/funcs.py b/RoutesApp/funcs.py index 481bf6a..0cd4c08 100644 --- a/RoutesApp/funcs.py +++ b/RoutesApp/funcs.py @@ -4,6 +4,9 @@ from django.utils.translation import gettext as _ from django.template.loader import render_to_string from datetime import datetime +elements_on_page = 25 + + def get_profile_new_route_page_html(request, data): form = RouteForm() @@ -199,14 +202,17 @@ def get_routes_Dict(user=None, data=None): elif to_el: routes = routes[:to_el] else: - to_el = 25 + to_el = elements_on_page routes = routes[:to_el] last_block = False if not to_el or to_el >= routes_count: last_block = True - + if routes_count - to_el > elements_on_page: + next_page_els_count = elements_on_page + else: + next_page_els_count = routes_count - to_el try: @@ -232,7 +238,8 @@ def get_routes_Dict(user=None, data=None): res_Dict.update({ 'routes': routes, 'last_block': last_block, - 'last_el': to_el + 'last_el': to_el, + 'next_page_els_count': next_page_els_count }) return res_Dict diff --git a/RoutesApp/js_views.py b/RoutesApp/js_views.py index 68dc8c2..3e57579 100644 --- a/RoutesApp/js_views.py +++ b/RoutesApp/js_views.py @@ -148,7 +148,8 @@ def find_routes_ajax(request): res_Dict = { 'html': html, - 'last_block': routes_Dict['last_block'] + 'last_block': routes_Dict['last_block'], + 'next_page_els_count': routes_Dict['next_page_els_count'], # 'form': RouteForm(initial=data) } diff --git a/RoutesApp/views.py b/RoutesApp/views.py index 19fab4e..d6163ef 100644 --- a/RoutesApp/views.py +++ b/RoutesApp/views.py @@ -32,7 +32,8 @@ def route_search_results_View(request): 'show_filter_and_results': True, 'owner_type': data['owner_type'], 'last_el': routes_Dict['last_el'], - 'page_type': 'routes' + 'page_type': 'routes', + 'next_page_els_count': routes_Dict['next_page_els_count'], } if 'from_address_point_txt' in routes_Dict: data.update({'from_address_point_txt': routes_Dict['from_address_point_txt']})