Fix logic when saving a service in the UI

This commit is contained in:
Théophile Diot 2023-04-26 14:21:54 +02:00
parent 479f18b175
commit 63ba001805
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 5 additions and 9 deletions

View File

@ -463,7 +463,7 @@ def services():
del variables["OLD_SERVER_NAME"]
# Edit check fields and remove already existing ones
config = app.config["CONFIG"].get_config(methods=True)
config = app.config["CONFIG"].get_config(methods=False)
for variable, value in deepcopy(variables).items():
if variable.endswith("SCHEMA"):
del variables[variable]
@ -474,19 +474,15 @@ def services():
elif value == "off":
value = "no"
config_setting = config.get(
f"{variables['SERVER_NAME'].split(' ')[0]}_{variable}", None
)
if variable in variables and (
request.form["operation"] == "edit"
and variable != "SERVER_NAME"
and config_setting is not None
and value == config_setting["value"]
variable != "SERVER_NAME"
and value == config.get(variable, None)
or not value.strip()
):
del variables[variable]
print(variables, flush=True)
if len(variables) <= 1:
flash(
f"{variables['SERVER_NAME'].split(' ')[0]} was not edited because no values were changed."