UI web d'admin + garde-fou recettes premium (supplément hors abonnement)
- Refus des recettes payantes (chargeSetting) à la sélection, override allow_premium - Recipe.surcharge_cents/is_premium exposés dans summary(); propose() les exclut - hellofresh/webui.py : page d'admin + API JSON montées sur FastMCP (/, /api/*) édition à chaud des excludes et préférences (liked/disliked)
This commit is contained in:
@@ -228,15 +228,23 @@ class HelloFreshClient:
|
||||
if not courses:
|
||||
return []
|
||||
id_index: dict[str, int] = {}
|
||||
charge_by_id: dict[str, dict] = {}
|
||||
ids: list[str] = []
|
||||
for c in courses:
|
||||
rid = (c.get("recipe") or {}).get("id")
|
||||
if rid and rid not in id_index:
|
||||
id_index[rid] = c.get("index")
|
||||
cs = c.get("chargeSetting")
|
||||
if isinstance(cs, dict):
|
||||
charge_by_id[rid] = cs
|
||||
ids.append(rid)
|
||||
recipes = self._fetch_details(ids)
|
||||
for r in recipes:
|
||||
r.course_index = id_index.get(r.id)
|
||||
cs = charge_by_id.get(r.id)
|
||||
if cs:
|
||||
r.surcharge_cents = int(cs.get("amount") or 0)
|
||||
r.surcharge_reason = str(cs.get("reason") or "")
|
||||
return _dedupe_by_name(recipes)
|
||||
|
||||
def _fetch_details(self, ids: list[str]) -> list[Recipe]:
|
||||
|
||||
Reference in New Issue
Block a user