v1.0.52: _tmpl() helper — all template vars in all code paths (fix UndefinedError)
This commit is contained in:
+23
-11
@@ -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>")
|
||||
|
||||
Reference in New Issue
Block a user