feat: Stoffe nach BLS-Gruppen sortieren und aufklappbar listen
Deploy Development / deploy (push) Successful in 1m4s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 21s

Energie und Makros zuerst, restliche Naehrstoffgruppen zuklappbar, damit die Liste bedienbar bleibt.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-14 13:09:44 +02:00
1 parent 94ddf84262
commit 44e3e216ab
6 files changed
+230 -95

No files matched your search

+4 -15
View File
@@ -300,7 +300,7 @@ def admin_update_manual_food(food_id: str, body: ManualFoodCreate, session: dict
@router.get("/attributes")
def admin_list_attributes(session: dict = Depends(require_admin)):
from bls.attribute_labels import MACRO_KEYS, label_is_placeholder
from bls.attribute_labels import annotate_attribute, sort_attributes
with get_db() as conn:
cur = get_cursor(conn)
@@ -309,17 +309,9 @@ def admin_list_attributes(session: dict = Depends(require_admin)):
SELECT id, attr_key, name_de, name_en, unit, category, data_type, origin, sort_order
FROM food_attributes
WHERE is_active = true
ORDER BY origin, sort_order, attr_key
"""
)
rows = []
for r in cur.fetchall():
row = r2d(r)
key = row.get("attr_key")
row["is_macro"] = key in MACRO_KEYS
row["needs_label"] = label_is_placeholder(row.get("name_de"), key)
rows.append(row)
return rows
return sort_attributes([annotate_attribute(r2d(r)) for r in cur.fetchall()])
@router.post("/attributes/fill-labels")
@@ -398,11 +390,8 @@ def admin_update_attribute(attr_id: int, body: AttributeUpdate, session: dict =
row = cur.fetchone()
if not row:
raise HTTPException(404, "Stoff nicht gefunden")
from bls.attribute_labels import MACRO_KEYS, label_is_placeholder
out = r2d(row)
out["is_macro"] = out.get("attr_key") in MACRO_KEYS
out["needs_label"] = label_is_placeholder(out.get("name_de"), out.get("attr_key"))
return out
from bls.attribute_labels import annotate_attribute
return annotate_attribute(r2d(row))
def _write_manual_macros(cur, food_id: str, macros: dict | None) -> None: