Phase 0a Mandantenfähigkeit
Deploy Development / deploy (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 3m38s

This commit is contained in:
Lars committed 2026-05-05 16:12:17 +02:00
1 parent 0748990328
commit 0c044249d9
15 files changed
+982 -193

No files matched your search

+30 -8
View File
@@ -16,6 +16,7 @@ from pydantic import BaseModel, Field, model_validator
from db import get_db, get_cursor, r2d
from auth import require_auth
from club_tenancy import exercise_visible_to_profile, is_platform_admin
logger = logging.getLogger(__name__)
@@ -592,9 +593,24 @@ def list_exercises(
where = ["1=1"]
params = []
# Visibility Filter (private nur für Owner)
where.append("(e.visibility = 'official' OR e.visibility = 'club' OR e.created_by = %s)")
params.append(profile_id)
# Mandanten-Sichtbarkeit: official / eigene private / club nur eigene Vereine (Plattform-Admin: alles)
role = session.get("role")
if not is_platform_admin(role):
where.append(
"""(
e.visibility = 'official'
OR (e.visibility = 'private' AND e.created_by = %s)
OR (
e.visibility = 'club'
AND e.club_id IS NOT NULL
AND EXISTS (
SELECT 1 FROM club_members cm
WHERE cm.profile_id = %s AND cm.club_id = e.club_id AND cm.status = 'active'
)
)
)"""
)
params.extend([profile_id, profile_id])
vis_list = _merge_str_any(visibility_any, visibility)
if vis_list:
@@ -754,12 +770,18 @@ def get_exercise(
cur = get_cursor(conn)
exercise = enrich_exercise_detail(exercise_id, cur)
if not exercise:
raise HTTPException(status_code=404, detail="Übung nicht gefunden")
if not exercise:
raise HTTPException(status_code=404, detail="Übung nicht gefunden")
# Permission Check (private nur für Owner)
if exercise["visibility"] == "private" and exercise["created_by"] != profile_id:
raise HTTPException(status_code=403, detail="Keine Berechtigung für diese Übung")
if not exercise_visible_to_profile(
cur,
profile_id,
exercise["visibility"],
exercise.get("club_id"),
exercise.get("created_by"),
session.get("role"),
):
raise HTTPException(status_code=403, detail="Keine Berechtigung für diese Übung")
return exercise