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:
12
app.py
12
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", "")
|
||||
FALLBACK = [{"text": "Fall | Draw | Spring | Dream", "value": "fall_draw_spring_dream"}]
|
||||
try:
|
||||
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", [])
|
||||
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/<pic_id>", methods=["PATCH"])
|
||||
|
||||
Reference in New Issue
Block a user