UI web : statut de connexion HelloFresh + checkbox recettes premium
- Carte « Connexion HelloFresh » (pastille + bouton Rafraîchir) via un nouvel endpoint GET /api/auth-status (auth.auth_status, vérifié contre l'API, déporté dans un thread pour ne pas figer la boucle asyncio). - Checkbox « Recettes premium » : réglage persistant allow_premium dans config/prefs.json (load/save_allow_premium dans filter.py), exposé par /api/config et piloté par PUT /api/allow-premium. - Le réglage devient le défaut côté MCP : hf_propose inclut/écarte les premium selon la case (le signale dans allow_premium/note), hf_confirm_selection reprend ce défaut quand allow_premium n'est pas passé explicitement. - .dockerignore ajouté. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -58,13 +58,17 @@ def remove_exclude(term: str) -> list[str]:
|
||||
|
||||
def load_prefs() -> dict:
|
||||
if not PREFS_PATH.exists():
|
||||
return {"liked": [], "disliked": []}
|
||||
return {"liked": [], "disliked": [], "allow_premium": False}
|
||||
data = json.loads(PREFS_PATH.read_text(encoding="utf-8"))
|
||||
return {"liked": data.get("liked", []), "disliked": data.get("disliked", [])}
|
||||
return {
|
||||
"liked": data.get("liked", []),
|
||||
"disliked": data.get("disliked", []),
|
||||
"allow_premium": bool(data.get("allow_premium", False)),
|
||||
}
|
||||
|
||||
|
||||
def save_prefs(liked: list[str], disliked: list[str]) -> dict:
|
||||
"""Écrit liked/disliked en préservant le commentaire éventuel du fichier."""
|
||||
"""Écrit liked/disliked en préservant le reste du fichier (commentaire, allow_premium)."""
|
||||
existing = {}
|
||||
if PREFS_PATH.exists():
|
||||
existing = json.loads(PREFS_PATH.read_text(encoding="utf-8"))
|
||||
@@ -74,6 +78,21 @@ def save_prefs(liked: list[str], disliked: list[str]) -> dict:
|
||||
return {"liked": liked, "disliked": disliked}
|
||||
|
||||
|
||||
def load_allow_premium() -> bool:
|
||||
"""Réglage : True si les recettes à supplément (premium) sont autorisées par défaut."""
|
||||
return load_prefs()["allow_premium"]
|
||||
|
||||
|
||||
def save_allow_premium(value: bool) -> bool:
|
||||
"""Persiste le réglage `allow_premium` en préservant le reste de prefs.json."""
|
||||
existing = {}
|
||||
if PREFS_PATH.exists():
|
||||
existing = json.loads(PREFS_PATH.read_text(encoding="utf-8"))
|
||||
existing["allow_premium"] = bool(value)
|
||||
PREFS_PATH.write_text(json.dumps(existing, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
||||
return bool(value)
|
||||
|
||||
|
||||
# --- application aux recettes ----------------------------------------------
|
||||
def _exclusion_haystack(recipe: Recipe) -> str:
|
||||
"""Champs FAISANT FOI pour l'exclusion : ingrédients, allergènes, nom, accroche.
|
||||
|
||||
Reference in New Issue
Block a user