fix: пре-рендер шаблоны не должны попадать в репозиторий

This commit is contained in:
2026-04-22 00:03:06 +03:00
parent 91b4d635da
commit cf24fab53a

View File

@@ -93,10 +93,17 @@ def catalog_seria_info(
except (ObjectDoesNotExist, ValueError): except (ObjectDoesNotExist, ValueError):
return redirect("/catalog/") return redirect("/catalog/")
# Если есть "облегченный" шаблон с частичным pre-render, используем его. # В DEV отключаем pre-render cache: всегда рендерим «тяжелый» шаблон напрямую,
light_template = f"{PATH_FOR_SERIA_INFO_HTML_INCLUDE}{seria_id}_id.html" # чтобы тестировать актуальную серверную логику, а не сохраненный html-файл.
light_template_w_path = f"{TEMPLATES[0]['DIRS'][0]}/{light_template}" if DEBUG:
is_hard_template = not os.path.isfile(light_template_w_path) light_template = "seria_info/all_seria_info_pre_light.html"
light_template_w_path = ""
is_hard_template = True
else:
# В PROD используем существующий pre-render include при наличии на диске.
light_template = f"{PATH_FOR_SERIA_INFO_HTML_INCLUDE}{seria_id}_id.html"
light_template_w_path = f"{TEMPLATES[0]['DIRS'][0]}/{light_template}"
is_hard_template = not os.path.isfile(light_template_w_path)
to_template: dict[str, object] = {} to_template: dict[str, object] = {}
# Получаем все уникальные проемы серии и сразу добавляем iQuantity=1 # Получаем все уникальные проемы серии и сразу добавляем iQuantity=1
@@ -206,10 +213,11 @@ def catalog_seria_info(
to_template.update(for_seria_nav) to_template.update(for_seria_nav)
to_template.update(seria_info_year(seria_id)) to_template.update(seria_info_year(seria_id))
to_template.update(seria_info_geo_code(seria_id)) to_template.update(seria_info_geo_code(seria_id))
string_prerender = render_to_string("seria_info/all_seria_info_pre_light.html", to_template) if not DEBUG:
with open(light_template_w_path, "w", encoding="utf-8") as file: string_prerender = render_to_string("seria_info/all_seria_info_pre_light.html", to_template)
file.write(string_prerender) with open(light_template_w_path, "w", encoding="utf-8") as file:
touch_reload_wsgi(light_template_w_path) file.write(string_prerender)
touch_reload_wsgi(light_template_w_path)
else: else:
to_template.update({"THIS_SERIA_NAME": q_seria.sName}) to_template.update({"THIS_SERIA_NAME": q_seria.sName})