feat: enhance role permissions and UI for clubs and training planning
Deploy Development / deploy (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Failing after 1m55s

- Updated role permissions to allow trainers and users to create clubs and training groups.
- Modified database insertion logic to reflect the correct role for trainers during registration.
- Enhanced frontend components to display appropriate messages and buttons based on user roles.
- Improved user guidance in the Clubs and Training Planning pages, emphasizing the need for clubs and groups before planning training sessions.
This commit is contained in:
Lars committed 2026-04-28 19:46:09 +02:00
1 parent 1f2a4595cd
commit 69b26fc928
5 files changed
+136 -50

No files matched your search

+12 -7
View File
@@ -82,10 +82,10 @@ def get_club(club_id: int, session=Depends(require_auth)):
# ── Create Club ───────────────────────────────────────────────────────
@router.post("/clubs")
def create_club(data: dict, session=Depends(require_auth)):
"""Create new club (admin only)."""
"""Create new club (Admin oder Trainer — MVP ohne separates Vereins-Onboarding)."""
role = session.get('role')
if role not in ['admin', 'superadmin']:
raise HTTPException(403, "Nur Admins dürfen Vereine erstellen")
if role not in ['admin', 'superadmin', 'trainer', 'user']:
raise HTTPException(403, "Keine Berechtigung, Vereine anzulegen")
name = data.get('name')
if not name:
@@ -395,10 +395,11 @@ def get_training_group(group_id: int, session=Depends(require_auth)):
# ── Create Training Group ─────────────────────────────────────────────
@router.post("/groups")
def create_training_group(data: dict, session=Depends(require_auth)):
"""Create new training group (admin or trainer)."""
"""Create new training group (admin, trainer oder normaler Nutzer mit Vereinsbezug)."""
profile_id = session["profile_id"]
role = session.get('role')
if role not in ['admin', 'superadmin', 'trainer']:
raise HTTPException(403, "Nur Admins und Trainer dürfen Gruppen erstellen")
if role not in ['admin', 'superadmin', 'trainer', 'user']:
raise HTTPException(403, "Keine Berechtigung, Trainingsgruppen anzulegen")
club_id = data.get('club_id')
name = data.get('name')
@@ -406,6 +407,10 @@ def create_training_group(data: dict, session=Depends(require_auth)):
if not club_id or not name:
raise HTTPException(400, "club_id und name sind Pflichtfelder")
trainer_id = data.get('trainer_id')
if trainer_id in (None, "", 0) and role in ("trainer", "user"):
trainer_id = profile_id
with get_db() as conn:
cur = get_cursor(conn)
@@ -436,7 +441,7 @@ def create_training_group(data: dict, session=Depends(require_auth)):
data.get('time_start'),
data.get('time_end'),
data.get('location'),
data.get('trainer_id'),
trainer_id,
data.get('co_trainer_ids'),
data.get('status', 'active')
))