minor: fix: явное указание типа to_template

This commit is contained in:
2026-04-21 01:05:11 +03:00
parent 20877dc98e
commit 1f0aaa7687
12 changed files with 23 additions and 25 deletions

View File

@@ -38,7 +38,7 @@ def blog_list_posts(request: HttpRequest, page: str = "0") -> HttpResponse:
except ValueError:
page = 0
dim_blogposts = [] # массив блог-постов для формирования списка
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
template = "blog/blog_list.html" # шаблон
in_list = NUM_BLOG_TIZER_IN_PAGE # длина списка блогов в выдачe
# проверяем нужно ли ставить кнопку BACK и куда она ссылается
@@ -141,7 +141,7 @@ def blog_post(request: HttpRequest, post_id: str = "0", page_back: str = None) -
back_page = int(request.GET["page-back"])
except (TypeError, KeyError):
back_page = 0
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
template = "blog/blog_post.html" # шаблон
q = BlogPosts.objects.get(id=post_id)

View File

@@ -16,7 +16,7 @@ def catalog_root(request: HttpRequest) -> HttpResponse:
"""
time_start = time.perf_counter()
# получаем из cookies последние визиты клиента
to_template = {
to_template: dict[str, object] = {
'LAST_VISIT': get_last_user_visit_list(get_last_user_visit_cookies(request)[:3]),
'LOG_VISIT': get_last_all_user_visit_list(),
'ticks': float(time.perf_counter() - time_start)}

View File

@@ -16,7 +16,7 @@ import pytils
def catalog_company(request: HttpRequest) -> HttpResponse:
time_start = time.perf_counter()
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
q_company = MerchantBrand.objects.raw('SELECT'
' oknardia_merchantbrand.id,'
' oknardia_merchantbrand.sMerchantName,'
@@ -72,7 +72,7 @@ def catalog_company(request: HttpRequest) -> HttpResponse:
def catalog_company_detail(request: HttpRequest, company_id: str, company_name_slug: str) -> HttpResponse:
time_start = time.perf_counter()
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
company_id = int(company_id)
q_by_id = MerchantBrand.objects.get(id=company_id)
if pytils.translit.slugify(q_by_id.sMerchantName) != company_name_slug:

View File

@@ -12,7 +12,7 @@ import pytils
def standard_opening(request: HttpRequest) -> HttpResponse:
time_start = time.perf_counter()
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
q_seria = Seria_Info.objects.raw('SELECT oknardia_seria_info.id, oknardia_seria_info.sName '
'FROM oknardia_seria_info '
'WHERE oknardia_seria_info.id = oknardia_seria_info.kRoot_id '

View File

@@ -215,8 +215,6 @@ def catalog_seria_info(request: HttpRequest, seria_name_translit: None, seria_id
seria_name = Seria_Info.objects.get(id=seria_id).sName
to_template.update({'THIS_SERIA_NAME': seria_name})
# to_template.update({'LOG_VISIT': GetLastAllUserVisitSeriaList(SeriaName),
# 'ticks': float(time.perf_counter()-time_start)})
_append_visit_context(to_template, request, time_start)
return render(request, light_template, to_template)

View File

@@ -61,7 +61,7 @@ def statistic_menu(request: HttpRequest) -> HttpResponse:
:return: HttpResponse -- исходящий http-ответ
"""
time_start = time()
to_template = {}
to_template: dict[str, object] = {}
seria_id, for_seria_nav = seria_nav(0)
to_template.update(for_seria_nav)
# проверяем какой JS с картами и PieCharts: упакованные или нет (откуда берётся не упакованный -- не помню)

View File

@@ -326,7 +326,7 @@ def report_one_win_price(request: HttpRequest, win_width_mm: str = '670', win_he
:return response: HttpResponse -- исходящий http-ответ
"""
time_start = time.perf_counter()
to_template = {}
to_template: dict[str, object] = {}
try:
# т.к. для вызова GetFlapDim4BigPictures нужно иметь внутри queryset поле iQuantity нельзя использовать
# простой запрос (см. следующую строку).
@@ -453,7 +453,7 @@ def next_one_win_price(request: HttpRequest, win_id='16', frame_begin_n="0"):
:return: HttpResponse --
"""
time_start = time.perf_counter()
to_template = report_price_frame(0, 1, 0, 0, int(frame_begin_n), 0, int(win_id))
to_template: dict[str, object] = report_price_frame(0, 1, 0, 0, int(frame_begin_n), 0, int(win_id))
to_template.update({'MOUNT_DIM_PER_OFFER': 1,
'WIN_ID': int(win_id),
'ticks': float(time.perf_counter() - time_start)})
@@ -472,7 +472,7 @@ def report_price(request: HttpRequest, build_id: str = "22427", apart_id: str =
"""
time_start = time.perf_counter()
msg = ""
to_template = {}
to_template: dict[str, object] = {}
try:
build_id = int(build_id)
apart_id = int(apart_id)
@@ -706,7 +706,7 @@ def next_price_frame(request: HttpRequest, apart_id: str = "1", mount_dim_per_o
# получаем данные для фрейма ценовых предложений
price_frame = report_price_frame(int(apart_id), int(mount_dim_per_offer), float(address_longitude),
float(address_latitude), int(frame_begin_n))
to_template = price_frame
to_template: dict[str, object] = price_frame
to_template.update({'APPARTMENT_ID': apart_id,
'MOUNT_DIM_PER_OFFER': mount_dim_per_offer,
'ADDRESS_LAT': address_latitude,

View File

@@ -81,7 +81,7 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
:return: HttpResponse --
"""
time_start = time.perf_counter()
to_template = {}
to_template: dict[str, object] = {}
try:
# Этот блок нужен для 302-переадресации, когда разные URL отдают одинаковые страницы.
# Например, такое происходит для страницы: /compare_offers/1,2 и /compare_offers/2,1
@@ -552,7 +552,7 @@ def show_rating_components(request: HttpRequest, win_set: str = "1") -> HttpResp
:return: HttpResponse --
"""
time_start = time.perf_counter()
to_template = {}
to_template: dict[str, object] = {}
try:
win_set = int(win_set)
except ValueError:

View File

@@ -35,7 +35,7 @@ def profiles_rating(request: HttpRequest) -> HttpResponse:
keys = [RANK_PVCP_HEAT_TRANSFER_NAME, RANK_PVCP_SOUNDPROOFING_NAME, RANK_PVCP_SEALS_NAME,
RANK_PVCP_HEIGHT_NAME, RANK_PVCP_G_THICKNESS_NAME, RANK_PVCP_THICKNESS_NAME,
RANK_PVCP_RABBET_NAME, RANK_PVCP_CAMERAS_NUM_NAME, RANK_PVCP_CAMERAS_POPULARITY_NAME]
to_template = {'KEYS': keys}
to_template: dict[str, object] = {'KEYS': keys}
for profile in q_pvc_profiles:
try:
received_json = json.loads(profile.sProfileDescription)

View File

@@ -64,7 +64,7 @@ def make_rating(request: HttpRequest) -> HttpResponse:
# ВЫЧИСЛЯЕМ РЕЙТИНГ ПРОФИЛЕЙ
# устанавливаем рейтинг всех профилей в базе в ноль
profile_all_num = PVCprofiles.objects.all().update(fProfileRating=0.0)
to_template = {'NUM_PROFILE_TOTAL': profile_all_num} # засовываем данные в шаблон
to_template: dict[str, object] = {'NUM_PROFILE_TOTAL': profile_all_num} # засовываем данные в шаблон
q = PVCprofiles.objects.raw("SELECT"
" oknardia_pvcprofiles.*,"
" COUNT(oknardia_priceoffer.id) AS NumOffer "

View File

@@ -38,7 +38,7 @@ def menu_login_logout(request: HttpRequest) -> HttpResponse:
# В дальнейшем, в случае высоких нагрузок на сервис, возможна простая деградация
# с помощью отключения этого блока. Также возможен перенос исполнения функционала
# LOGIN-LOGOUT на отдельный сервер.
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
template = "user_manager/login-logout.html" # шаблон для подгрузки GOOGLE CAPTCHA
if request.user.is_authenticated:
to_template.update({'LOGGED_USER': request.user.username})
@@ -56,7 +56,7 @@ def confirm_email(request: HttpRequest, user_id: str = "1", hash_part_12: str =
:return response: исходящий http-ответ
"""
time_start = time()
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
to_template.update({'CONFIRM_OK': "NO"})
template = "index.html" # шаблон, о том, что email не подтвержден
try:
@@ -100,7 +100,7 @@ def restore_password(request: HttpRequest, user_id: str = "1", hash_part_12: str
:return response: исходящий http-ответ
"""
time_start = time()
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
to_template.update({'CONFIRM_OK': "NO"})
template = "index.html" # шаблон, о том, что email не подтвержден
try:
@@ -138,7 +138,7 @@ def change_password(request: HttpRequest) -> HttpResponse:
if request.method != 'POST':
return HttpResponseRedirect("/")
try:
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
to_template.update({'CONFIRM_OK': "NO"})
template = "user_manager/popup_confirm_email_or_restore_password_bad.html" # шаблон, о том, что всякие ошибки
try:
@@ -189,7 +189,7 @@ def form_user_menu_processing(request: HttpRequest) -> HttpResponse:
return HttpResponseRedirect("/")
if request.POST['status'] == "":
return HttpResponseRedirect("/")
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
template = "user_manager/login-logout_after.html" # шаблон для подгрузки GOOGLE CAPTCHA
# БЛОК -- LOGOUT

View File

@@ -19,7 +19,7 @@ def main_init(request: HttpRequest) -> HttpResponse:
:param request: входящий http-запрос
:return response: исходящий http-ответ
"""
to_template = {} # словарь, для передачи шаблону
to_template: dict[str, object] = {} # словарь, для передачи шаблону
num_viz = 0 # как будто первый визит
# проверяем куки числа визита
if "NumVisit" in request.COOKIES:
@@ -55,7 +55,7 @@ def tariff(request: HttpRequest) -> HttpResponse:
:param request: входящий http-запрос
:return response: исходящий http-ответ
"""
to_template = {} # для передачи в шаблон
to_template: dict[str, object] = {} # для передачи в шаблон
if request.method == 'POST':
# print request.POST
if 'tariff' in request.POST and 'email_' in request.POST \
@@ -119,7 +119,7 @@ def get_address(request: HttpRequest) -> HttpResponse:
if 'address' not in request.POST:
return redirect("/")
addr = request.POST['address']
to_template = {}
to_template: dict[str, object] = {}
try:
q = Building_Info.objects.get(sAddress=addr)
# Если QuerySet не содержит GeoCode (такое бывает, что в Яндекс-Картах не было каких-то данных),