v1.0.52: _tmpl() helper — all template vars in all code paths (fix UndefinedError)

This commit is contained in:
2026-07-27 10:02:43 +04:00
parent 1786bc67dd
commit d79c78e530
2 changed files with 24 additions and 12 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ from routes.main import bp as main_bp
from routes.api import bp as api_bp
from routes.api_test import bp as api_test_bp
VERSION = "1.0.51"
VERSION = "1.0.52"
app = Flask(__name__, template_folder="templates", static_folder="static")
app.config["NUBES_API_ENDPOINT"] = os.getenv("NUBES_API_ENDPOINT", "https://lk-api-gateway-dev.ngcloud.ru/api/v1/svc")
+23 -11
View File
@@ -70,13 +70,31 @@ def index():
org = None
error = None
services = []
instances = []
instance_groups = {}
config = {}
action = request.form.get("action", "")
def _tmpl(**overrides):
"""Собрать контекст шаблона со всеми обязательными переменными."""
ctx = {
"organization": org,
"error": error,
"env_token_masked": _mask(env_token),
"has_user_token": bool(user_token),
"client_id": _client_id(active_token),
"token_info": _token_info(active_token),
"config": config,
"services": services,
"instances": instances,
"instance_groups": instance_groups,
}
ctx.update(overrides)
return render_template("index.html", **ctx)
if action == "clear":
resp = make_response(render_template("index.html",
organization=None, error=None,
env_token_masked=_mask(env_token),
has_user_token=False))
resp = make_response(_tmpl(organization=None, error=None, has_user_token=False))
resp.delete_cookie("token")
return resp
@@ -121,13 +139,7 @@ def index():
else:
error = "Токен невалиден или просрочен"
return render_template("index.html",
organization=org, error=error,
env_token_masked=_mask(env_token),
has_user_token=bool(user_token),
client_id=_client_id(active_token),
token_info=_token_info(active_token),
instance_groups=instance_groups)
return _tmpl()
@bp.route("/api/operations/<int:svc_id>")