régler problème ou les coachs ne voyait pas leur tryouts
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Coach — evaluates, schedules matches, manages their own org team."""
|
||||
from app.models.user_model.user import User
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
class Coach(User):
|
||||
@@ -38,8 +39,8 @@ class Coach(User):
|
||||
def get_visible_tryouts(self):
|
||||
from app.models.tryout.tryout import Tryout
|
||||
team_ids = [t.id for t in self.coached_org_teams.all()]
|
||||
if not team_ids:
|
||||
return Tryout.query.filter(Tryout.id == -1).all() # empty
|
||||
return Tryout.query.filter(
|
||||
Tryout.target_org_team_id.in_(team_ids)
|
||||
).order_by(Tryout.date).all()
|
||||
conditions = []
|
||||
if team_ids:
|
||||
conditions.append(Tryout.target_org_team_id.in_(team_ids))
|
||||
conditions.append(Tryout.coach_id == self.id)
|
||||
return Tryout.query.filter(db.or_(*conditions)).order_by(Tryout.date).all()
|
||||
|
||||
@@ -143,9 +143,7 @@ def view_tryout(tryout_id):
|
||||
elif isinstance(current_user, Manager) and tryout.created_by == current_user.id:
|
||||
can_view = True
|
||||
elif isinstance(current_user, Coach):
|
||||
org_team = OrgTeam.query.filter_by(coach_id=current_user.id).first()
|
||||
if org_team and tryout.target_org_team_id == org_team.id:
|
||||
can_view = True
|
||||
can_view = current_user.can_manage_this_tryout(tryout)
|
||||
elif isinstance(current_user, Player):
|
||||
is_registered = TryoutRegistration.query.filter_by(
|
||||
tryout_id=tryout_id, player_id=current_user.id).first() is not None
|
||||
|
||||
Reference in New Issue
Block a user