From fed824fbb111e1596d3616cfc799165bb187863e Mon Sep 17 00:00:00 2001 From: jbperrin Date: Fri, 17 Jul 2026 15:44:03 +0200 Subject: [PATCH] fix: use __dataclass_fields__ instead of hasattr to load config - fixes printers list being ignored --- backend/services/config_service.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/services/config_service.py b/backend/services/config_service.py index 7d9144d..6400eb7 100644 --- a/backend/services/config_service.py +++ b/backend/services/config_service.py @@ -128,13 +128,13 @@ class ConfigService: cfg = Config() if "app" in raw: - cfg.app = AppConfig(**{k: v for k, v in raw["app"].items() if hasattr(AppConfig, k)}) + cfg.app = AppConfig(**{k: v for k, v in raw["app"].items() if k in AppConfig.__dataclass_fields__}) if "photobooth" in raw: - cfg.photobooth = PhotoboothConfig(**{k: v for k, v in raw["photobooth"].items() if hasattr(PhotoboothConfig, k)}) + cfg.photobooth = PhotoboothConfig(**{k: v for k, v in raw["photobooth"].items() if k in PhotoboothConfig.__dataclass_fields__}) if "button" in raw: - cfg.button = ButtonConfig(**{k: v for k, v in raw["button"].items() if hasattr(ButtonConfig, k)}) + cfg.button = ButtonConfig(**{k: v for k, v in raw["button"].items() if k in ButtonConfig.__dataclass_fields__}) if "leds" in raw: led_raw = raw["leds"] @@ -150,13 +150,13 @@ class ConfigService: ) if "print" in raw: - cfg.print = PrintConfig(**{k: v for k, v in raw["print"].items() if hasattr(PrintConfig, k)}) + cfg.print = PrintConfig(**{k: v for k, v in raw["print"].items() if k in PrintConfig.__dataclass_fields__}) if "gallery" in raw: - cfg.gallery = GalleryConfig(**{k: v for k, v in raw["gallery"].items() if hasattr(GalleryConfig, k)}) + cfg.gallery = GalleryConfig(**{k: v for k, v in raw["gallery"].items() if k in GalleryConfig.__dataclass_fields__}) if "event" in raw: - cfg.event = EventConfig(**{k: v for k, v in raw["event"].items() if hasattr(EventConfig, k)}) + cfg.event = EventConfig(**{k: v for k, v in raw["event"].items() if k in EventConfig.__dataclass_fields__}) cfg.button_actions = raw.get("button_actions", { 1: {"label": "Photo normale", "photobooth_index": 0},