diff --git a/ArticlesApp/funcs.py b/ArticlesApp/funcs.py index ec356b5..2d92211 100644 --- a/ArticlesApp/funcs.py +++ b/ArticlesApp/funcs.py @@ -1,6 +1,8 @@ from .models import * +elements_on_page = 4 + def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None): if request_Data: @@ -20,17 +22,23 @@ def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None): elif to_el: arts = arts[:to_el] else: - to_el = 3 + to_el = elements_on_page arts = arts[:to_el] last_block = False if not to_el or to_el >= el_count: last_block = True + if el_count - to_el > elements_on_page: + next_page_els_count = elements_on_page + else: + next_page_els_count = el_count - to_el + Dict = { 'articles': arts, 'last_block': last_block, - 'last_el': to_el + 'last_el': to_el, + 'next_page_els_count': next_page_els_count } return Dict diff --git a/ArticlesApp/js_views.py b/ArticlesApp/js_views.py index eccc45f..f82bf78 100644 --- a/ArticlesApp/js_views.py +++ b/ArticlesApp/js_views.py @@ -37,7 +37,8 @@ def get_articles_block_ajax(request): res_Dict = { 'html': html, - 'last_block': Dict['last_block'] + 'last_block': Dict['last_block'], + 'next_page_els_count': Dict['next_page_els_count'], # 'form': RouteForm(initial=data) } diff --git a/ArticlesApp/views.py b/ArticlesApp/views.py index 735532c..ea4f70c 100644 --- a/ArticlesApp/views.py +++ b/ArticlesApp/views.py @@ -79,6 +79,9 @@ def ArticlesPageView(request, year=None): Dict = get_articles(art_kwargs=kwargs) + Dict.update({ + + }) t = loader.get_template('pages/p_articles.html') return get_inter_http_respose(t, Dict, request) diff --git a/BaseModels/paging.py b/BaseModels/paging.py index d1f8168..b80f121 100644 --- a/BaseModels/paging.py +++ b/BaseModels/paging.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- __author__ = 'SDE' -def get_paging_Dict(request, elements_count, elements_on_page, from_page, to_page=None): +def get_paging_Dict(request, elements_count, next_page_els_count, from_page, to_page=None): - pages_count = elements_count / elements_on_page - if elements_count % elements_on_page > 0: + pages_count = elements_count / next_page_els_count + if elements_count % next_page_els_count > 0: pages_count = pages_count + 1 pages = [] 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']}) diff --git a/static/js/dynamic_loading_routes.js b/static/js/dynamic_loading_routes.js index 0f76d95..87b4fb8 100644 --- a/static/js/dynamic_loading_routes.js +++ b/static/js/dynamic_loading_routes.js @@ -3,16 +3,16 @@ standart_page_iterator = 1 separator_iterator = 1 iterator_f_check = 1 -function load_routes (el,news=null) { +function load_routes (el,news=null,incrase) { let local_page_iterator = standart_page_iterator if (!news){ local_page_iterator = page_iterator } let number_last_route = el.id - let incrase = 2 - if (!news){ - incrase = 10 - } + // let incrase = 2 + // if (!news){ + // incrase = 10 + // } let data_d = { 'from_el':parseInt(number_last_route), 'to_el':parseInt(number_last_route) + incrase @@ -58,6 +58,10 @@ function load_routes (el,news=null) { // // + if (data.next_page_els_count){ + document.querySelector(".col_vo_els_f_load").innerHTML = ` ${data.next_page_els_count}` + } + let place_ins_parent = el.closest(".block_w_paging") let place_ins = place_ins_parent.querySelector(`.page_paging_elements_${local_page_iterator}`) // diff --git a/templates/blocks/b_find_route_form.html b/templates/blocks/b_find_route_form.html index d4a0a47..d4e4ed1 100644 --- a/templates/blocks/b_find_route_form.html +++ b/templates/blocks/b_find_route_form.html @@ -19,9 +19,9 @@
- {% if last_block == False %} + {% if last_block == False and next_page_els_count %}