diff --git a/client/blueprints/maker.py b/client/blueprints/maker.py index 348df36..b40089e 100644 --- a/client/blueprints/maker.py +++ b/client/blueprints/maker.py @@ -27,15 +27,15 @@ def recipe_list(): resp = api_client.get("/api/recipes", params=params) - if resp.get("error"): + if isinstance(resp, dict) and resp.get("error"): flash(_("Errore nel caricamento delle ricette: %(error)s", error=resp.get("detail", "")), "error") recipes = [] total = 0 pages = 0 else: - recipes = resp.get("items", []) - total = resp.get("total", 0) - pages = resp.get("pages", 1) + recipes = resp.get("items", []) if isinstance(resp, dict) else resp + total = resp.get("total", 0) if isinstance(resp, dict) else len(recipes) + pages = resp.get("pages", 1) if isinstance(resp, dict) else 1 return render_template( "maker/recipe_list.html", diff --git a/client/blueprints/measure.py b/client/blueprints/measure.py index 76de545..fc8ad9c 100644 --- a/client/blueprints/measure.py +++ b/client/blueprints/measure.py @@ -21,7 +21,7 @@ def select_recipe(): """Recipe selection page with search and barcode support.""" # Load recipes from API resp = api_client.get("/api/recipes", params={"per_page": 100}) - if resp.get("error"): + if isinstance(resp, dict) and resp.get("error"): flash( _("Errore nel caricamento delle ricette: %(detail)s", detail=resp.get("detail", "")), @@ -78,7 +78,7 @@ def task_list(recipe_id: int): # Load tasks for this recipe tasks_resp = api_client.get(f"/api/recipes/{recipe_id}/tasks") - if tasks_resp.get("error"): + if isinstance(tasks_resp, dict) and tasks_resp.get("error"): flash( _("Errore nel caricamento dei task: %(detail)s", detail=tasks_resp.get("detail", "")), @@ -154,7 +154,7 @@ def task_complete(recipe_id: int): "/api/measurements", params={"version_id": version_id}, ) - if not meas_resp.get("error"): + if not (isinstance(meas_resp, dict) and meas_resp.get("error")): measurements = ( meas_resp if isinstance(meas_resp, list) else meas_resp.get("items", []) diff --git a/client/templates/base.html b/client/templates/base.html index fcf45fd..170b175 100644 --- a/client/templates/base.html +++ b/client/templates/base.html @@ -90,7 +90,7 @@ {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}