feat: Eigene Stoffe am Lebensmittel anlegen
Deploy Development / deploy (push) Successful in 1m8s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 22s

EPA-Chips und mg/µg vom Etikett; fehlende Parameter ohne Admin.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-09-13 15:47:49 +02:00
1 parent a5adff6196
commit d35087ad84
9 files changed
+246 -29

No files matched your search

+21 -1
View File
@@ -52,6 +52,12 @@ class SuggestBatchBody(BaseModel):
limit: int = 3
class UserAttributeCreate(BaseModel):
name_de: str
unit: str = "g"
attr_key: Optional[str] = None
def _pid(session: dict, x_profile_id: Optional[str] = None) -> str:
return x_profile_id or session["profile_id"]
@@ -100,12 +106,26 @@ def search_foods(
@router.get("/attributes")
def list_food_attributes(
q: str = "",
keys: str = "",
limit: int = 40,
session: dict = Depends(require_auth),
):
from data_layer.food_attributes import list_numeric_attributes
key_list = [p.strip() for p in (keys or "").split(",") if p.strip()]
with get_db() as conn:
return list_numeric_attributes(get_cursor(conn), q, limit=limit)
return list_numeric_attributes(get_cursor(conn), q, limit=limit, keys=key_list or None)
@router.post("/attributes")
def create_food_attribute(body: UserAttributeCreate, session: dict = Depends(require_auth)):
from data_layer.food_attributes import create_extension_attribute
try:
with get_db() as conn:
return create_extension_attribute(
get_cursor(conn), body.name_de, body.unit, body.attr_key
)
except ValueError as e:
raise HTTPException(400, str(e)) from e
@router.post("/foods/suggest-batch")