Skip to content

Commit

Permalink
Fix multisite settings being returned by get_config even when MULTISI…
Browse files Browse the repository at this point in the history
…TE setting is set to "no"
  • Loading branch information
TheophileDiot committed Jun 17, 2024
1 parent c15954f commit f84ec98
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1586,25 +1586,24 @@ def get_non_default_settings(
if global_value.context == "multisite":
multisite.add(setting_id)

is_multisite = config.get("MULTISITE", {"value": "no"})["value"] == "yes" if methods else config.get("MULTISITE", "no") == "yes"

services = session.query(Services).with_entities(Services.id, Services.is_draft)

if not with_drafts:
services = services.filter_by(is_draft=False)

servers = ""
for service in services:
if not global_only:
if not global_only and is_multisite:
servers = ""
for service in services:
config[f"{service.id}_IS_DRAFT"] = "yes" if service.is_draft else "no"
if methods:
config[f"{service.id}_IS_DRAFT"] = {"value": config[f"{service.id}_IS_DRAFT"], "global": False, "method": "default"}
for key in multisite:
config[f"{service.id}_{key}"] = config[key]
servers += f"{service.id} "
servers = servers.strip()

config["SERVER_NAME"] = servers if not methods else {"value": servers, "global": True, "method": "default"}
servers += f"{service.id} "
servers = servers.strip()

if not global_only and (config.get("MULTISITE", {"value": "no"})["value"] == "yes" if methods else config.get("MULTISITE", "no") == "yes"):
# Define the join operation
j = join(Services, Services_settings, Services.id == Services_settings.service_id)
j = j.join(Settings, Settings.id == Services_settings.setting_id)
Expand Down Expand Up @@ -1643,6 +1642,10 @@ def get_non_default_settings(
config[f"{result.service_id}_{result.setting_id}" + (f"_{result.suffix}" if result.multiple and result.suffix else "")] = (
value if not methods else {"value": value, "global": False, "method": result.method}
)
else:
servers = " ".join(service.id for service in services)

config["SERVER_NAME"] = servers if not methods else {"value": servers, "global": True, "method": "default"}

return config

Expand Down

0 comments on commit f84ec98

Please sign in to comment.