Implement SERVER_NAME handling in raw mode for services_service_page

This commit is contained in:
Théophile Diot 2025-01-14 17:16:47 +01:00
parent 57080e4637
commit 855ddaf9f3
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -195,6 +195,16 @@ def services_service_page(service: str):
del variables["csrf_token"]
mode = request.args.get("mode", "easy")
if mode == "raw":
server_name = variables.get("SERVER_NAME", variables.get("OLD_SERVER_NAME", "")).split(" ")[0]
for variable, value in variables.copy().items():
if variable.endswith("_SERVER_NAME") and variable != "OLD_SERVER_NAME":
server_name = value.split(" ")[0]
for variable in variables.copy():
if variable.startswith(f"{server_name}_"):
variables[variable.replace(f"{server_name}_", "", 1)] = variables.pop(variable)
is_draft = variables.pop("IS_DRAFT", "no") == "yes"
def update_service(service: str, variables: Dict[str, str], is_draft: bool, mode: str):
@ -267,12 +277,6 @@ def services_service_page(service: str):
if "checksum" in data:
db_custom_configs[db_custom_config]["checksum"] = data["checksum"]
if mode == "raw":
server_name = variables.get("SERVER_NAME", old_server_name).split(" ")[0]
for variable, value in variables.copy().items():
if variable.startswith(f"{server_name}_"):
variables[variable.replace(f"{server_name}_", "", 1)] = value
if mode != "easy" or service != "new":
# Remove already existing fields
for variable, value in variables.copy().items():