Régler problèmes d'affichage des matchs récents:
Ajout des match qui arrivent pour les coach, president et manager Légèrement alléger la quantité de pages (merge certaines ensembles)
This commit is contained in:
@@ -156,8 +156,9 @@ class User(UserMixin, db.Model):
|
||||
def can_manage_this_tryout(self, tryout):
|
||||
"""Check if user can manage a specific tryout.
|
||||
|
||||
Presidents can manage all tryouts. Managers can manage their own tryouts.
|
||||
Coaches can manage tryouts targeting their coached team.
|
||||
Presidents can manage all tryouts. Managers can manage their own tryouts
|
||||
or tryouts where they are assigned as manager. Coaches can manage tryouts
|
||||
targeting their coached team or where they are assigned as coach.
|
||||
|
||||
Args:
|
||||
tryout: The Tryout object to check permissions for.
|
||||
@@ -167,12 +168,14 @@ class User(UserMixin, db.Model):
|
||||
"""
|
||||
if self.role == 'president':
|
||||
return True
|
||||
if self.role == 'manager' and tryout.created_by == self.id:
|
||||
if self.role == 'manager' and (tryout.created_by == self.id or tryout.manager_id == 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
|
||||
if tryout.coach_id == self.id:
|
||||
return True
|
||||
return False
|
||||
|
||||
def can_manage_this_org_team(self, org_team):
|
||||
@@ -392,6 +395,8 @@ class Tryout(db.Model):
|
||||
max_players: Maximum number of players allowed.
|
||||
created_by: Foreign key to the creating manager/president.
|
||||
target_org_team_id: Foreign key to target organization team.
|
||||
manager_id: Foreign key to the assigned manager.
|
||||
coach_id: Foreign key to the assigned coach.
|
||||
created_at: Timestamp of creation.
|
||||
"""
|
||||
__tablename__ = 'tryouts'
|
||||
@@ -405,9 +410,13 @@ class Tryout(db.Model):
|
||||
max_players = db.Column(db.Integer, nullable=True)
|
||||
created_by = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
|
||||
target_org_team_id = db.Column(db.Integer, db.ForeignKey('org_teams.id'), nullable=True)
|
||||
manager_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
|
||||
coach_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
creator = db.relationship('User', backref='created_tryouts')
|
||||
creator = db.relationship('User', foreign_keys=[created_by], backref='created_tryouts')
|
||||
manager = db.relationship('User', foreign_keys=[manager_id], backref='managed_tryouts')
|
||||
coach = db.relationship('User', foreign_keys=[coach_id], backref='coached_tryouts')
|
||||
registrations = db.relationship('TryoutRegistration', backref='tryout', lazy='dynamic')
|
||||
evaluations = db.relationship('Evaluation', backref='tryout', lazy='dynamic')
|
||||
teams = db.relationship('Team', backref='tryout', lazy='dynamic')
|
||||
|
||||
Reference in New Issue
Block a user