Compare commits
2 Commits
0340f9bb7d
...
de124440a4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de124440a4 | ||
|
|
622907d426 |
29
app.py
29
app.py
@@ -149,7 +149,36 @@ def directus_picture_words(pic_id):
|
||||
else: # POST
|
||||
body = request.get_json(force=True, silent=True) or {}
|
||||
words = body.get("words", [])
|
||||
|
||||
# Junction + Relationen idempotent einrichten
|
||||
_ensure_junction("words_pictures", "words_id", "pictures_id", token)
|
||||
_directus("PATCH", "/fields/pictures/linked_words", token, {
|
||||
"type": "alias",
|
||||
"meta": {"special": ["m2m"], "interface": "list-m2m",
|
||||
"options": {"template": "{{words_id.title_de}}"}},
|
||||
})
|
||||
_directus("PATCH", "/fields/words/linked_pictures", token, {
|
||||
"type": "alias",
|
||||
"meta": {"special": ["m2m"], "interface": "list-m2m",
|
||||
"options": {"template": "{{pictures_id.media}}"}},
|
||||
})
|
||||
_directus("POST", "/relations", token, {
|
||||
"collection": "words_pictures", "field": "words_id",
|
||||
"related_collection": "words",
|
||||
"schema": {"on_delete": "CASCADE"},
|
||||
"meta": {"junction_field": "pictures_id",
|
||||
"one_field": "linked_pictures",
|
||||
"one_deselect_action": "nullify"},
|
||||
})
|
||||
_directus("POST", "/relations", token, {
|
||||
"collection": "words_pictures", "field": "pictures_id",
|
||||
"related_collection": "pictures",
|
||||
"schema": {"on_delete": "CASCADE"},
|
||||
"meta": {"junction_field": "words_id",
|
||||
"one_field": "linked_words",
|
||||
"one_deselect_action": "nullify"},
|
||||
})
|
||||
|
||||
saved = 0
|
||||
for entry in words:
|
||||
title_de = (entry.get("title_de") or "").strip()
|
||||
|
||||
Reference in New Issue
Block a user