Fix profile not updating
This commit is contained in:
+27
-5
@@ -756,17 +756,39 @@ async def start(
|
|||||||
templates_dir = config.get("templates_dir", os.path.join(pkg_dir, "templates"))
|
templates_dir = config.get("templates_dir", os.path.join(pkg_dir, "templates"))
|
||||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(templates_dir))
|
env = jinja2.Environment(loader=jinja2.FileSystemLoader(templates_dir))
|
||||||
|
|
||||||
# Build host access summary for this user
|
# Build host access summary for this user.
|
||||||
|
# Merge live hosts with config-only hosts (not yet seen) so the profile
|
||||||
|
# reflects the config file immediately after a reload.
|
||||||
|
from . import config as config_mod
|
||||||
owned, managed, monitored = [], [], []
|
owned, managed, monitored = [], [], []
|
||||||
if current_user:
|
if current_user:
|
||||||
for hostname, host in sorted(hbdclass.Host.hosts.items()):
|
# Collect all known hostnames: live + configured
|
||||||
if host.is_owner(current_user.username):
|
cfg_hostnames = set(config.get("hosts", {}).keys())
|
||||||
|
live_hostnames = set(hbdclass.Host.hosts.keys())
|
||||||
|
all_hostnames = sorted(cfg_hostnames | live_hostnames)
|
||||||
|
|
||||||
|
for hostname in all_hostnames:
|
||||||
|
live_host = hbdclass.Host.hosts.get(hostname)
|
||||||
|
if live_host is not None:
|
||||||
|
# Use live object — it has apply_access already called
|
||||||
|
is_own = live_host.is_owner(current_user.username)
|
||||||
|
is_mgr = not is_own and live_host.is_manager(current_user.username)
|
||||||
|
is_mon = not is_own and not is_mgr and live_host.is_monitor(current_user.username)
|
||||||
|
else:
|
||||||
|
# Config-only host — read access directly from config
|
||||||
|
access = config_mod.get_host_access(config, hostname)
|
||||||
|
is_own = access["owner"] == current_user.username
|
||||||
|
is_mgr = current_user.username in access["managers"]
|
||||||
|
is_mon = current_user.username in access["monitors"]
|
||||||
|
|
||||||
|
if is_own:
|
||||||
owned.append(hostname)
|
owned.append(hostname)
|
||||||
elif host.is_manager(current_user.username):
|
elif is_mgr:
|
||||||
managed.append(hostname)
|
managed.append(hostname)
|
||||||
elif host.is_monitor(current_user.username):
|
elif is_mon:
|
||||||
monitored.append(hostname)
|
monitored.append(hostname)
|
||||||
|
|
||||||
|
|
||||||
# Resolve notification channel configs for display
|
# Resolve notification channel configs for display
|
||||||
notif_channels = []
|
notif_channels = []
|
||||||
if current_user:
|
if current_user:
|
||||||
|
|||||||
Reference in New Issue
Block a user