fix: design-options fallback wenn Directus fields API nicht erreichbar
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
16
app.py
16
app.py
@@ -1717,11 +1717,17 @@ def directus_db_pictures():
|
|||||||
@app.route("/api/directus/db-pictures/design-options", methods=["GET"])
|
@app.route("/api/directus/db-pictures/design-options", methods=["GET"])
|
||||||
def directus_db_pictures_design_options():
|
def directus_db_pictures_design_options():
|
||||||
token = request.headers.get("Authorization", "")
|
token = request.headers.get("Authorization", "")
|
||||||
data, status = _directus("GET", "/fields/db_pictures/design", token)
|
FALLBACK = [{"text": "Fall | Draw | Spring | Dream", "value": "fall_draw_spring_dream"}]
|
||||||
if status != 200:
|
try:
|
||||||
return jsonify({"choices": []}), 200
|
data, status = _directus("GET", "/fields/db_pictures/design", token)
|
||||||
choices = (data.get("data") or data).get("meta", {}).get("options", {}).get("choices", [])
|
if status == 200:
|
||||||
return jsonify({"choices": choices})
|
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/<pic_id>", methods=["PATCH"])
|
@app.route("/api/directus/db-pictures/<pic_id>", methods=["PATCH"])
|
||||||
|
|||||||
Reference in New Issue
Block a user