fix: Alpine.js x-data broken by inner double quotes + API list response crash

- Extract JSON data to <script> tags instead of tojson_attr in x-data attributes
- Remove literal " from CSS selector in x-data (meta[name=csrf-token])
- Move Alpine.js defer script after extra_js block in base.html
- Add isinstance(resp, dict) guard before .get("error") in measure.py and maker.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adriano
2026-02-07 20:13:22 +01:00
parent 004f794c75
commit 2453e552fb
5 changed files with 16 additions and 14 deletions
+3 -3
View File
@@ -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", [])