Fix distractor_words special=m2m in Directus via eigenen Endpoint
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
18
app.py
18
app.py
@@ -1262,6 +1262,24 @@ def delete_word_item(w_id: str):
|
||||
return jsonify({"error": "Delete failed"}), status
|
||||
|
||||
|
||||
@app.route("/api/fix-distractor-field", methods=["POST"])
|
||||
def fix_distractor_field():
|
||||
"""Setzt special=m2m auf questions.distractor_words (einmalig)."""
|
||||
token = request.headers.get("Authorization", "")
|
||||
# Directus erfordert den vollen Payload beim Patchen von special
|
||||
payload = {
|
||||
"meta": {
|
||||
"special": ["m2m"],
|
||||
"interface": "list-m2m",
|
||||
"options": {"template": "{{words_id.title_de}}"},
|
||||
"hidden": False,
|
||||
"note": "Ablenker-Wörter (thematisch passend, aber nicht die Antwort)",
|
||||
}
|
||||
}
|
||||
data, status = _directus("PATCH", "/fields/questions/distractor_words", token, payload)
|
||||
return jsonify({"ok": status in (200, 201), "status": status, "data": data})
|
||||
|
||||
|
||||
@app.route("/api/setup-schema", methods=["POST"])
|
||||
def setup_directus_schema():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user