diff --git a/backend/app/main.py b/backend/app/main.py index 7625988..e57dae9 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -315,6 +315,15 @@ def bewerten( return eintrag +@app.delete("/api/watched/rating/{rating_id}") +def wertung_loeschen(rating_id: int): + """Der Host räumt eine einzelne Wertung weg.""" + if not watched.stimme_loeschen(rating_id): + raise HTTPException(status_code=404, detail="Wertung nicht gefunden") + events.senden("watched") + return {"removed": 1} + + @app.delete("/api/suggestions/alle") def runde_zuruecksetzen(): """Host leert die Runde: Vorschläge weg, Rad wieder leer.""" diff --git a/backend/app/watched.py b/backend/app/watched.py index 6e27de7..0c7da39 100644 --- a/backend/app/watched.py +++ b/backend/app/watched.py @@ -59,7 +59,7 @@ def alle(session_id): "SELECT * FROM watched ORDER BY watched_at DESC, id DESC" ).fetchall() stimmen = conn.execute( - "SELECT watched_id, session_id, stars, name FROM ratings " + "SELECT id, watched_id, session_id, stars, name FROM ratings " "ORDER BY created_at ASC" ).fetchall() @@ -75,7 +75,8 @@ def alle(session_id): { **dict(film), "ratings": [ - {"stars": s["stars"], "name": s["name"]} for s in eigene + {"id": s["id"], "stars": s["stars"], "name": s["name"]} + for s in eigene ], "average": round(sum(werte) / len(werte), 1) if werte else None, "count": len(werte), @@ -163,6 +164,14 @@ def bewerten(watched_id, session_id, stars, name=None): return {"watched_id": watched_id, "stars": stars} +def stimme_loeschen(rating_id): + """Der Host räumt eine einzelne Wertung weg.""" + with connect() as conn: + return conn.execute( + "DELETE FROM ratings WHERE id = ?", (rating_id,) + ).rowcount + + def ids(): """movie_ids der geschauten Filme, für die Detailansicht.""" with connect() as conn: diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 84713bd..6dd5851 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,5 +1,6 @@ diff --git a/frontend/src/components/MovieCard.vue b/frontend/src/components/MovieCard.vue index 998dde0..84a086a 100644 --- a/frontend/src/components/MovieCard.vue +++ b/frontend/src/components/MovieCard.vue @@ -4,6 +4,7 @@ import { posterUrl } from '../images' const props = defineProps({ movie: { type: Object, required: true }, + aufDemRad: { type: Boolean, default: false }, }) defineEmits(['open']) @@ -21,7 +22,13 @@ const meta = computed(() =>