Merge remote-tracking branch 'origin/main'

This commit is contained in:
2023-11-29 16:55:24 +03:00
10 changed files with 45 additions and 20 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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 = []

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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']})

View File

@@ -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}`)
//

View File

@@ -19,9 +19,9 @@
<div class="clear_both"></div>
{% if last_block == False %}
{% if last_block == False and next_page_els_count %}
<div class="text-align-center">
<button class="button-find-more-routes" id="{{ last_el }}" onclick="load_routes(this)">{% trans "Показать ещё 10" %}</button>
<button class="button-find-more-routes" id="{{ last_el }}" onclick="load_routes(this,null,{{ next_page_els_count }})">{% trans "Показать ещё" %}<span class="col_vo_els_f_load"> {{ next_page_els_count }}</span></button>
<div class="width-100 text-align-center mb-10">
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
</div>

View File

@@ -36,10 +36,10 @@
{% include 'blocks/articles/b_news_elements_content.html' %}
{% endwith %}
{# boris edited #}
{% if last_block == False %}
{% if last_block == False and next_page_els_count %}
<div class="text-align-center">
{% csrf_token %}
<button class="button-find-more-routes" id="{{ last_el }}" onclick="load_routes(this,'news')">{% trans "Показать ещё 2" %}</button>
<button class="button-find-more-routes" id="{{ last_el }}" onclick="load_routes(this,'news',{{ next_page_els_count }})">{% trans "Показать ещё" %}<span class="col_vo_els_f_load"> {{ next_page_els_count }}</span></button>
<div class="width-100 text-align-center mb-10">
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
</div>