diff --git a/backend/routes/dogs.py b/backend/routes/dogs.py index 74b6d5b..0b09ae2 100644 --- a/backend/routes/dogs.py +++ b/backend/routes/dogs.py @@ -361,8 +361,9 @@ async def get_pflege_tipps(dog_id: int, user=Depends(get_current_user)): (f"%{dog['rasse']}%",) ).fetchone() - # Fell-Typ ableiten + # Fell-Typ und Pflegeart ableiten fell_filter = None + fell_pflege_art_filter = None if rasse_info: beschr = (rasse_info["beschreibung"] or "").lower() if any(w in beschr for w in ["lockig", "wellig", "kraus", "pudel", "doodle"]): @@ -374,6 +375,12 @@ async def get_pflege_tipps(dog_id: int, user=Depends(get_current_user)): elif rasse_info["groesse"] in ("gross", "sehr_gross"): fell_filter = "doppel" + # Pflegeart: Trimmen vs. Schneiden + if any(w in beschr for w in ["trimm", "hand-stripping", "stripping", "rauhhaar", "drahthaar", "rauhaar"]): + fell_pflege_art_filter = "trimmen" + elif any(w in beschr for w in ["schneid", "geschoren", "schere", "clipper"]): + fell_pflege_art_filter = "schneiden" + with db() as conn: alle_tipps = conn.execute( "SELECT * FROM pflege_tipps ORDER BY kategorie, titel" @@ -388,10 +395,15 @@ async def get_pflege_tipps(dog_id: int, user=Depends(get_current_user)): result = [] for t in alle_tipps: t = dict(t) - # Fell-Filter + # Fell-Typ-Filter if fell_filter and t["fell_typ"] and t["fell_typ"] != "alle": if fell_filter not in t["fell_typ"].split(","): continue + # Pflegeart-Filter: Trimm-Tipps nicht bei Schneidehunden und umgekehrt + tipp_art = t.get("fell_pflege_art") + if tipp_art and tipp_art != "alle" and fell_pflege_art_filter: + if tipp_art != fell_pflege_art_filter: + continue t["schritte"] = _json.loads(t["schritte"] or "[]") t["saisonal_aktuell"] = bool(t["saison"] and heute_saison in t["saison"]) result.append(t) @@ -403,9 +415,10 @@ async def get_pflege_tipps(dog_id: int, user=Depends(get_current_user)): tipp_des_tages = (saisonal or result)[day_hash % len(saisonal or result)] if result else None return { - "dog_name": dog["name"], - "rasse_name": rasse_info["name"] if rasse_info else dog["rasse"], - "tipp_des_tages": tipp_des_tages, - "tipps": result, - "kategorien": list(dict.fromkeys(t["kategorie"] for t in result)), + "dog_name": dog["name"], + "rasse_name": rasse_info["name"] if rasse_info else dog["rasse"], + "tipp_des_tages": tipp_des_tages, + "tipps": result, + "kategorien": list(dict.fromkeys(t["kategorie"] for t in result)), + "fell_pflege_art": fell_pflege_art_filter, # 'schneiden' | 'trimmen' | None } diff --git a/backend/static/js/pages/diary.js b/backend/static/js/pages/diary.js index d21aeed..706d561 100644 --- a/backend/static/js/pages/diary.js +++ b/backend/static/js/pages/diary.js @@ -700,6 +700,22 @@ window.Page_diary = (() => { +