Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
|
||||||
|
elements_on_page = 4
|
||||||
|
|
||||||
def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None):
|
def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None):
|
||||||
|
|
||||||
if request_Data:
|
if request_Data:
|
||||||
@@ -20,17 +22,23 @@ def get_articles(art_kwargs, request_Data=None, from_el=None, to_el=None):
|
|||||||
elif to_el:
|
elif to_el:
|
||||||
arts = arts[:to_el]
|
arts = arts[:to_el]
|
||||||
else:
|
else:
|
||||||
to_el = 3
|
to_el = elements_on_page
|
||||||
arts = arts[:to_el]
|
arts = arts[:to_el]
|
||||||
|
|
||||||
last_block = False
|
last_block = False
|
||||||
if not to_el or to_el >= el_count:
|
if not to_el or to_el >= el_count:
|
||||||
last_block = True
|
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 = {
|
Dict = {
|
||||||
'articles': arts,
|
'articles': arts,
|
||||||
'last_block': last_block,
|
'last_block': last_block,
|
||||||
'last_el': to_el
|
'last_el': to_el,
|
||||||
|
'next_page_els_count': next_page_els_count
|
||||||
}
|
}
|
||||||
|
|
||||||
return Dict
|
return Dict
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ def get_articles_block_ajax(request):
|
|||||||
|
|
||||||
res_Dict = {
|
res_Dict = {
|
||||||
'html': html,
|
'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)
|
# 'form': RouteForm(initial=data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ def ArticlesPageView(request, year=None):
|
|||||||
|
|
||||||
|
|
||||||
Dict = get_articles(art_kwargs=kwargs)
|
Dict = get_articles(art_kwargs=kwargs)
|
||||||
|
Dict.update({
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
t = loader.get_template('pages/p_articles.html')
|
t = loader.get_template('pages/p_articles.html')
|
||||||
return get_inter_http_respose(t, Dict, request)
|
return get_inter_http_respose(t, Dict, request)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
__author__ = 'SDE'
|
__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
|
pages_count = elements_count / next_page_els_count
|
||||||
if elements_count % elements_on_page > 0:
|
if elements_count % next_page_els_count > 0:
|
||||||
pages_count = pages_count + 1
|
pages_count = pages_count + 1
|
||||||
|
|
||||||
pages = []
|
pages = []
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ from django.utils.translation import gettext as _
|
|||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
elements_on_page = 25
|
||||||
|
|
||||||
|
|
||||||
def get_profile_new_route_page_html(request, data):
|
def get_profile_new_route_page_html(request, data):
|
||||||
|
|
||||||
form = RouteForm()
|
form = RouteForm()
|
||||||
@@ -199,14 +202,17 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
elif to_el:
|
elif to_el:
|
||||||
routes = routes[:to_el]
|
routes = routes[:to_el]
|
||||||
else:
|
else:
|
||||||
to_el = 25
|
to_el = elements_on_page
|
||||||
routes = routes[:to_el]
|
routes = routes[:to_el]
|
||||||
|
|
||||||
last_block = False
|
last_block = False
|
||||||
if not to_el or to_el >= routes_count:
|
if not to_el or to_el >= routes_count:
|
||||||
last_block = True
|
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:
|
try:
|
||||||
|
|
||||||
@@ -232,7 +238,8 @@ def get_routes_Dict(user=None, data=None):
|
|||||||
res_Dict.update({
|
res_Dict.update({
|
||||||
'routes': routes,
|
'routes': routes,
|
||||||
'last_block': last_block,
|
'last_block': last_block,
|
||||||
'last_el': to_el
|
'last_el': to_el,
|
||||||
|
'next_page_els_count': next_page_els_count
|
||||||
})
|
})
|
||||||
return res_Dict
|
return res_Dict
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,8 @@ def find_routes_ajax(request):
|
|||||||
|
|
||||||
res_Dict = {
|
res_Dict = {
|
||||||
'html': html,
|
'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)
|
# 'form': RouteForm(initial=data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ def route_search_results_View(request):
|
|||||||
'show_filter_and_results': True,
|
'show_filter_and_results': True,
|
||||||
'owner_type': data['owner_type'],
|
'owner_type': data['owner_type'],
|
||||||
'last_el': routes_Dict['last_el'],
|
'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:
|
if 'from_address_point_txt' in routes_Dict:
|
||||||
data.update({'from_address_point_txt': routes_Dict['from_address_point_txt']})
|
data.update({'from_address_point_txt': routes_Dict['from_address_point_txt']})
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ standart_page_iterator = 1
|
|||||||
separator_iterator = 1
|
separator_iterator = 1
|
||||||
iterator_f_check = 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
|
let local_page_iterator = standart_page_iterator
|
||||||
if (!news){
|
if (!news){
|
||||||
local_page_iterator = page_iterator
|
local_page_iterator = page_iterator
|
||||||
}
|
}
|
||||||
let number_last_route = el.id
|
let number_last_route = el.id
|
||||||
let incrase = 2
|
// let incrase = 2
|
||||||
if (!news){
|
// if (!news){
|
||||||
incrase = 10
|
// incrase = 10
|
||||||
}
|
// }
|
||||||
let data_d = {
|
let data_d = {
|
||||||
'from_el':parseInt(number_last_route),
|
'from_el':parseInt(number_last_route),
|
||||||
'to_el':parseInt(number_last_route) + incrase
|
'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_parent = el.closest(".block_w_paging")
|
||||||
let place_ins = place_ins_parent.querySelector(`.page_paging_elements_${local_page_iterator}`)
|
let place_ins = place_ins_parent.querySelector(`.page_paging_elements_${local_page_iterator}`)
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
<div class="clear_both"></div>
|
<div class="clear_both"></div>
|
||||||
|
|
||||||
{% if last_block == False %}
|
{% if last_block == False and next_page_els_count %}
|
||||||
<div class="text-align-center">
|
<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">
|
<div class="width-100 text-align-center mb-10">
|
||||||
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
|
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,10 +36,10 @@
|
|||||||
{% include 'blocks/articles/b_news_elements_content.html' %}
|
{% include 'blocks/articles/b_news_elements_content.html' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{# boris edited #}
|
{# boris edited #}
|
||||||
{% if last_block == False %}
|
{% if last_block == False and next_page_els_count %}
|
||||||
<div class="text-align-center">
|
<div class="text-align-center">
|
||||||
{% csrf_token %}
|
{% 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">
|
<div class="width-100 text-align-center mb-10">
|
||||||
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
|
<img class="loader_f_loading_routes" src="{% static "img/svg/loader.svg" %}">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user