progression 50% pour evolution des joueurs
CI - Security, Lint & Tests / validate (push) Failing after 1m13s

This commit is contained in:
cedrick2711
2026-09-05 11:30:13 -04:00
parent cf551867c9
commit f468217745
22 changed files with 2235 additions and 8 deletions
+70
View File
@@ -343,3 +343,73 @@ def coach_manages_tryout(coach, tryout):
if tryout.target_org_team_id:
return tryout.target_org_team_id in coach_org_team_ids(coach)
return False
# ---------------------------------------------------------------------------
# Player Evolution — Objectives
# ---------------------------------------------------------------------------
def can_view_objectives(user):
"""Whether the user may view the objectives list.
Everyone except regular players without any context can browse objectives.
Players see only their own.
"""
return True
def can_manage_objectives(user):
"""Whether the user may create, edit, or delete objectives.
Presidents, managers, and coaches may manage objectives. Players are
read-only.
"""
from app.models import Admin, Coach, Manager
return isinstance(user, (Admin, Manager, Coach))
def can_manage_objective(user, objective):
"""Whether the user may edit or delete a specific objective.
Presidents and managers may manage any objective. A coach may manage
objectives assigned to their players or their teams.
"""
from app.models import Admin, Coach, Manager
if isinstance(user, (Admin, Manager)):
return True
if isinstance(user, Coach):
if objective.player_id and objective.player_id in coach_player_ids(user):
return True
if objective.team_id and objective.team_id in coach_org_team_ids(user):
return True
return False
def can_view_objective(user, objective):
"""Whether the user may view this objective's detail page.
Presidents, managers, and coaches may view any they manage.
A player may view only their own assigned objectives.
Everyone else may view objectives they created.
"""
from app.models import Admin, Coach, Manager, Player
if isinstance(user, (Admin, Manager)):
return True
if isinstance(user, Coach):
return can_manage_objective(user, objective)
if isinstance(user, Player):
return objective.player_id == user.id
return objective.created_by == user.id
def can_add_objective_entry(user, objective):
"""Whether the user may record a KPI measurement on this objective.
The same as can_view_objective — the assigned player may record
their own measurements on their own objectives.
"""
return can_view_objective(user, objective)