Feature: Trainingsprotokoll-Tab in Übungen, kein Tagebuch-Spam

- Neuer Tab 'Protokoll' in der Übungen-Seite: zeigt alle Trainingseinheiten
  chronologisch nach Datum gruppiert (Heute/Gestern/Datum-Label)
- Jede Einheit: Übungsname, Wdh., Erfolgs-Emoji, Stimmung, Sterne, Notiz, TOP-Badge
- 'Weitere laden' Pagination (30 Einheiten pro Seite)
- Backend: Training erstellt keine Tagebuch-Einträge mehr (weder bei ist_top noch manuell)
- Frontend: 'Als Meilenstein ins Tagebuch' Checkbox komplett entfernt
- onDogChange setzt Verlauf-State zurück
This commit is contained in:
rene 2026-05-19 18:17:50 +02:00
parent d2c2c59abb
commit cc841ef6d7
2 changed files with 167 additions and 82 deletions

View file

@ -326,7 +326,7 @@ class SessionCreate(BaseModel):
hund_stimmung: str = "aufmerksam"
zufriedenheit: int = 3
notiz: Optional[str] = None
tagebuch_eintrag: bool = False
tagebuch_eintrag: bool = False # ignoriert — Training hat eigenes Protokoll
@router.post("/sessions")
@ -363,42 +363,6 @@ async def log_session(body: SessionCreate, user=Depends(get_current_user)):
# Badges prüfen
new_badges = _check_badges(conn, uid, dog_name)
# Tagebucheintrag erstellen?
diary_entry_id = None
if body.tagebuch_eintrag or ist_top:
stimmung_label = STIMMUNGS_LABELS.get(body.hund_stimmung, body.hund_stimmung)
if ist_top:
titel = f"\U0001f3af {body.exercise_name} \u2014 Top-Training!"
else:
titel = f"\U0001f3af Training: {body.exercise_name}"
text_parts = [
f"{body.wiederholungen} Wiederholungen \u00b7 "
f"Erfolgsquote: {body.erfolgsquote}% \u00b7 "
f"Stimmung: {stimmung_label}"
]
if body.notiz:
text_parts.append(f"\n\n{body.notiz}")
eintrag_text = "".join(text_parts)
diary_cur = conn.execute(
"""
INSERT INTO diary (dog_id, datum, typ, titel, text)
VALUES (?,?,?,?,?)
""",
(body.dog_id, datum, "training", titel, eintrag_text)
)
diary_entry_id = diary_cur.lastrowid
conn.execute(
"INSERT OR IGNORE INTO diary_dogs (diary_id, dog_id) VALUES (?,?)",
(diary_entry_id, body.dog_id)
)
conn.execute(
"UPDATE training_sessions SET diary_entry_id=? WHERE id=?",
(diary_entry_id, session_id)
)
session = {
"id": session_id,
"user_id": uid,
@ -412,14 +376,12 @@ async def log_session(body: SessionCreate, user=Depends(get_current_user)):
"zufriedenheit": body.zufriedenheit,
"notiz": body.notiz,
"ist_top": bool(ist_top),
"diary_entry_id": diary_entry_id,
}
return {
"session": session,
"ist_top": bool(ist_top),
"badges": new_badges,
"diary_entry_id": diary_entry_id,
}