modification des permissions de coach: Voit uniquement les tryouts de ses équipes.
Evaluer un joueur retourne à la page précédente au lieu de la page des evaluations
This commit is contained in:
@@ -65,6 +65,28 @@ class User(UserMixin, db.Model):
|
||||
def can_manage_teams(self):
|
||||
return self.role in ['president', 'manager']
|
||||
|
||||
def can_manage_this_tryout(self, tryout):
|
||||
"""Check if user can manage a specific tryout (president, or manager/coach in charge of it)."""
|
||||
if self.role == 'president':
|
||||
return True
|
||||
if self.role == 'manager' and tryout.created_by == self.id:
|
||||
return True
|
||||
if self.role == 'coach':
|
||||
org_team = OrgTeam.query.filter_by(coach_id=self.id).first()
|
||||
if org_team and tryout.target_org_team_id == org_team.id:
|
||||
return True
|
||||
return False
|
||||
|
||||
def can_manage_this_org_team(self, org_team):
|
||||
"""Check if user can manage a specific org team (president, or manager/coach in charge of it)."""
|
||||
if self.role == 'president':
|
||||
return True
|
||||
if self.role == 'manager':
|
||||
return True # Managers can manage all org teams (create/edit/delete)
|
||||
if self.role == 'coach' and org_team.coach_id == self.id:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
|
||||
Reference in New Issue
Block a user