"""Coach — evaluates, schedules matches, manages their own org teams.""" from app.models.user_model.user import User class Coach(User): """Coach — evaluates, schedules matches, manages their own org teams. Every question about *which* teams or tryouts belong to this coach is delegated to ``app.permissions``. Two of the three methods below used to answer it themselves, each considering a different subset of the two ways a coach can be attached to a team: ``can_manage_this_tryout`` ignored the legacy ``coach_id`` column when checking the target team, and ``get_visible_tryouts`` ignored it entirely. A coach attached only by that column therefore saw an empty calendar (ARCH-002). """ __mapper_args__ = {'polymorphic_identity': 'coach'} def can_evaluate(self): return True def can_schedule_matches(self): return True def can_manage_tryouts(self): return True def can_manage_this_tryout(self, tryout): from app.permissions import coach_manages_tryout return coach_manages_tryout(self, tryout) def can_manage_this_org_team(self, org_team): if org_team.coaches.filter_by(id=self.id).first(): return True return org_team.coach_id == self.id def get_visible_tryouts(self): from app.permissions import coach_tryouts return coach_tryouts(self)