first commit
Build and deploy / build-and-push (push) Successful in 17s
Build and deploy / deploy (push) Successful in 10s

This commit is contained in:
william
2026-08-21 16:23:49 +02:00
committed by william
commit 3f4ebc4527
248 changed files with 10180 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
from ..connection import connect
from ..slugify import slugify
from ..definitions.get_definition import get_definition
def relation_options(slug, related_definition_id):
"""Lignes existantes d'un objet lié, pour peupler un <select> de relation."""
related = get_definition(slug, related_definition_id)
conn = connect(slug)
rows = conn.execute(f"SELECT * FROM {related['table_name']} ORDER BY id").fetchall()
conn.close()
display_field = related["fields"][0]["name"] if related["fields"] else "id"
display_col = slugify(display_field).replace("-", "_")
options = []
for r in rows:
r = dict(r)
label = r.get(display_col, f"#{r['id']}")
options.append({"id": r["id"], "label": f"{label} (#{r['id']})"})
return options