diff --git a/VERSION b/VERSION index 163dda9..5f798c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1135 \ No newline at end of file +1136 \ No newline at end of file diff --git a/backend/routes/admin.py b/backend/routes/admin.py index fac5a1c..c28813d 100644 --- a/backend/routes/admin.py +++ b/backend/routes/admin.py @@ -136,8 +136,13 @@ async def action_items(user=Depends(require_mod)): "SELECT COUNT(*) FROM users WHERE DATE(created_at)=DATE('now')" ).fetchone()[0] try: + # JOIN mit users, damit verwaiste Anfragen von gelöschten Usern + # nicht mehr im „Zu Erledigen"-Counter auftauchen (Liste filtert + # das via JOIN bereits, der Counter tat es früher nicht). upgrades_pending = conn.execute( - "SELECT COUNT(*) FROM upgrade_requests WHERE fulfilled_at IS NULL" + "SELECT COUNT(*) FROM upgrade_requests r " + "JOIN users u ON u.id = r.user_id " + "WHERE r.fulfilled_at IS NULL" ).fetchone()[0] except Exception: upgrades_pending = 0 @@ -457,6 +462,20 @@ async def delete_user(uid: int, user=Depends(require_admin)): raise HTTPException(404, "User nicht gefunden.") if target["id"] == user["id"]: raise HTTPException(400, "Du kannst deinen eigenen Account nicht löschen.") + # Hund-zentrierte Daten zuerst löschen, sonst hängt der FK an der Hunde-ID + dog_ids = [r["id"] for r in conn.execute( + "SELECT id FROM dogs WHERE user_id=?", (uid,)).fetchall()] + for did in dog_ids: + conn.execute("DELETE FROM diary WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM health WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM training_sessions WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM training_streaks WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM expenses WHERE dog_id=?", (did,)) + conn.execute("DELETE FROM dogs WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM upgrade_requests WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM push_subscriptions WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM notifications WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM forum_posts WHERE user_id=?", (uid,)) conn.execute("DELETE FROM users WHERE id=?", (uid,)) _audit(conn, user, "user_delete", f"user:{uid} ({target['name']})") diff --git a/backend/routes/profile.py b/backend/routes/profile.py index 2fe0e1d..3762413 100644 --- a/backend/routes/profile.py +++ b/backend/routes/profile.py @@ -164,6 +164,7 @@ async def delete_account(user=Depends(get_current_user)): conn.execute("DELETE FROM training_streaks WHERE dog_id=?", (did,)) conn.execute("DELETE FROM expenses WHERE dog_id=?", (did,)) conn.execute("DELETE FROM dogs WHERE user_id=?", (uid,)) + conn.execute("DELETE FROM upgrade_requests WHERE user_id=?", (uid,)) conn.execute("DELETE FROM push_subscriptions WHERE user_id=?", (uid,)) conn.execute("DELETE FROM notifications WHERE user_id=?", (uid,)) conn.execute("DELETE FROM forum_posts WHERE user_id=?", (uid,)) diff --git a/backend/static/index.html b/backend/static/index.html index de83c82..f5f69f4 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 17ac074..2927c34 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1135'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1136'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/landing.html b/backend/static/landing.html index b65790a..6134b9f 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index e847531..c0f53f5 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1135'; +const VER = '1136'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten