From 255ec5185855f697356a86c5582db29f5dd45a71 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 10 May 2026 20:15:45 +0200 Subject: [PATCH] fix: design-options fallback wenn Directus fields API nicht erreichbar Co-Authored-By: Claude Sonnet 4.6 --- app.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 9827875..7b3426c 100644 --- a/app.py +++ b/app.py @@ -1717,11 +1717,17 @@ def directus_db_pictures(): @app.route("/api/directus/db-pictures/design-options", methods=["GET"]) def directus_db_pictures_design_options(): token = request.headers.get("Authorization", "") - data, status = _directus("GET", "/fields/db_pictures/design", token) - if status != 200: - return jsonify({"choices": []}), 200 - choices = (data.get("data") or data).get("meta", {}).get("options", {}).get("choices", []) - return jsonify({"choices": choices}) + FALLBACK = [{"text": "Fall | Draw | Spring | Dream", "value": "fall_draw_spring_dream"}] + try: + data, status = _directus("GET", "/fields/db_pictures/design", token) + if status == 200: + field_data = data.get("data") or data + choices = field_data.get("meta", {}).get("options", {}).get("choices", []) + if choices: + return jsonify({"choices": choices}) + except Exception as e: + print(f"[design-options] Directus fetch failed: {e}") + return jsonify({"choices": FALLBACK}) @app.route("/api/directus/db-pictures/", methods=["PATCH"])