Ajout d'une catégorie jeux dans le tryouts, chacun des jeux offre des rôles différents pour les membres d'équipes. Remodelage du code un peu et ajout de docu

This commit is contained in:
cedrick2711
2026-07-15 21:27:18 -04:00
parent a129f218b6
commit 195f3ce312
29 changed files with 1501 additions and 269 deletions
+88 -51
View File
@@ -1,3 +1,9 @@
"""Database seeding script for Team Tryouts application.
This module provides functions to seed the database with sample data including
users, tryouts, teams, evaluations, and player disponibilities.
"""
from sqlalchemy import text
from extensions import db, hash_password
from models import User, Tryout, TryoutRegistration, Evaluation, Team, TeamMember, OrgTeam, PlayerDisponibility, UserGamertag
@@ -6,6 +12,20 @@ import random
def seed_database():
"""Seed the database with sample data for development and testing.
Creates sample users with different roles (president, manager, coach, player, scout),
organization teams, tryouts, registrations, evaluations, and player disponibilities.
All existing data is cleared before seeding.
The function creates:
- 7 admin users (president, 2 managers, 3 coaches, 1 scout)
- 10 player users with E-Sports profiles
- 4 organization teams
- 4 tryouts
- Registrations and evaluations
- Player disponibilities for match scheduling
"""
# Clear existing data
db.session.execute(text('DELETE FROM player_disponibilities'))
db.session.execute(text('DELETE FROM match_participants'))
@@ -33,9 +53,9 @@ def seed_database():
# Create players with E-Sports profile data (gamertags per game)
player_data = [
{'username': 'jplayer1', 'full_name': 'James Wilson', 'email': 'james@email.com', 'games': 'Valorant,Counter-Strike 2',
'gamertags': {'Valorant': 'jameswilson_val', 'Counter-Strike 2': 'jameswilson_cs'},
'discord': 'JamesW#7291', 'league_os': 'https://leagueos.gg/player/jameswilson'},
{'username': 'jplayer1', 'full_name': 'nordjan', 'email': 'nordjan27@gmail.com', 'games': 'Valorant,Counter-Strike 2, Rainbow Six Siege, Rocket League, Overwatch 2',
'gamertags': {'Valorant': 'nordjan#bad', 'Counter-Strike 2': 'nordjan', 'Rainbow Six Siege': 'n0rd-vpn', 'Rocket League': 'nordjiano'},
'discord': 'nordjan', 'league_os': 'https://leagueos.gg/player/nordjan'},
{'username': 'jplayer2', 'full_name': 'Emma Garcia', 'email': '[email protected]', 'games': 'League of Legends,Valorant',
'gamertags': {'League of Legends': 'emmagarcia_lol', 'Valorant': 'emmagarcia_val'},
'discord': 'EmmaG#4452', 'league_os': 'https://leagueos.gg/player/emmagarcia'},
@@ -139,10 +159,10 @@ def seed_database():
# Create Organization Teams (OrgTeams)
org_teams_data = [
{'name': 'Varsity', 'coach': coaches[0], 'creator': president},
{'name': 'Junior Varsity', 'coach': coaches[1], 'creator': president},
{'name': 'U14 Development', 'coach': coaches[2], 'creator': president},
{'name': 'Select Team', 'coach': None, 'creator': president},
{'name': 'Rocket League main', 'coach': coaches[0], 'creator': president},
{'name': 'CS2', 'coach': coaches[1], 'creator': president},
{'name': 'Valorant', 'coach': coaches[2], 'creator': president},
{'name': 'Rocket League acad', 'coach': None, 'creator': manager1},
]
org_teams = []
@@ -159,16 +179,16 @@ def seed_database():
# Create tryouts
tryouts_data = [
{'title': 'Spring Season Tryouts', 'date': datetime.utcnow() - timedelta(days=5), 'location': 'Main Stadium', 'description': 'Tryouts for the spring competitive season. All positions welcome.', 'status': 'in_progress', 'creator': manager1, 'target_team': org_teams[0]},
{'title': 'Fall Select Team Trials', 'date': datetime.utcnow() + timedelta(days=20), 'location': 'Training Center', 'description': 'Trials for the fall select team. High skill level required.', 'status': 'upcoming', 'creator': manager1, 'target_team': org_teams[3]},
{'title': 'Youth Development Camp', 'date': datetime.utcnow() - timedelta(days=20), 'location': 'Community Field', 'description': 'Development camp for younger players to showcase their skills.', 'status': 'completed', 'creator': manager2, 'target_team': org_teams[2]},
{'title': 'Winter Indoor Showcase', 'date': datetime.utcnow() - timedelta(days=2), 'location': 'Indoor Arena', 'description': 'Indoor showcase event for scouting and team selection.', 'status': 'in_progress', 'creator': manager2, 'target_team': org_teams[1]},
{'title': 'Rocket Leauge Tryouts', 'game': 'Rocket League', 'date': datetime.utcnow(), 'location': 'En ligne', 'description': 'Tryouts for the spring competitive season. All positions welcome.', 'status': 'in_progress', 'creator': manager1, 'target_team': org_teams[0]},
{'title': 'CS2 Tryouts', 'game': 'Counter-Strike 2', 'date': datetime.utcnow() + timedelta(days=4), 'location': 'En ligne', 'description': 'Trials for the fall select team. High skill level required.', 'status': 'upcoming', 'creator': manager1, 'target_team': org_teams[3]},
{'title': 'Valorant Tryouts', 'game': 'Valorant', 'date': datetime.utcnow() - timedelta(days=2), 'location': 'En ligne', 'description': 'Séléction pour l\'équipe de Valorant', 'status': 'in_progress', 'creator': manager2, 'target_team': org_teams[2]},
]
tryouts = []
for data in tryouts_data:
t = Tryout(
title=data['title'],
game=data['game'],
date=data['date'].date(),
location=data['location'],
description=data['description'],
@@ -184,10 +204,9 @@ def seed_database():
# Register players for tryouts
registrations_data = [
(tryouts[0], players[:8]),
(tryouts[1], players),
(tryouts[2], players[:6]),
(tryouts[3], players[2:9]),
(tryouts[0], players[:3]),
(tryouts[1], players[3:5]),
(tryouts[2], players)
]
regs = []
@@ -196,7 +215,7 @@ def seed_database():
reg = TryoutRegistration(
tryout_id=tryout.id,
player_id=player.id,
status=random.choice(['registered', 'attended', 'attended'])
status=random.choice(['registered', 'attended', 'attended', 'no_show'])
)
db.session.add(reg)
regs.append(reg)
@@ -205,55 +224,71 @@ def seed_database():
# Create evaluations (for in_progress and completed tryouts)
eval_data = []
# Spring tryout - some evaluations
# Spring tryout (Rocket League) - some evaluations
rl_positions = ['None needed', 'None', 'N/A']
for player in players[:8]:
for coach in coaches:
if random.random() > 0.3:
speed = random.randint(4, 10)
agility = random.randint(4, 10)
technique = random.randint(3, 10)
teamwork = random.randint(5, 10)
attitude = random.randint(5, 10)
overall = round((speed + agility + technique + teamwork + attitude) / 5, 1)
positions = ['Forward', 'Midfield', 'Defense', 'Goalie', 'Wing', 'Center']
mecanics = random.randint(4, 10)
cohesion = random.randint(4, 10)
communication = random.randint(3, 10)
gamesense = random.randint(5, 10)
versatility = random.randint(5, 10)
discipline = random.randint(4, 10)
analysis = random.randint(4, 10)
sport_ethics = random.randint(5, 10)
mental = random.randint(5, 10)
overall = round((mecanics + cohesion + communication + gamesense + versatility + discipline + analysis + sport_ethics + mental) / 9, 1)
eval_entry = Evaluation(
tryout_id=tryouts[0].id,
player_id=player.id,
evaluator_id=coach.id,
speed_score=speed,
agility_score=agility,
technique_score=technique,
teamwork_score=teamwork,
attitude_score=attitude,
mecanics_score=mecanics,
cohesion_score=cohesion,
communication_score=communication,
gamesense_score=gamesense,
versatility_score=versatility,
discipline_score=discipline,
analysis_score=analysis,
sport_ethics_score=sport_ethics,
mental_score=mental,
overall_score=overall,
comments=f"{'Great' if overall > 7 else 'Good'} performance. {'Shows promise.' if overall > 6 else 'Needs improvement in some areas.'}",
position_recommendation=random.choice(positions)
position_recommendation=random.choice(rl_positions)
)
db.session.add(eval_entry)
eval_data.append(eval_entry)
# Completed tryout - full evaluations
# Completed tryout (Valorant) - full evaluations
val_positions = ['Controller', 'Initiator', 'Duelist', 'Sentinel']
for player in players[:6]:
for coach in coaches[:2]:
speed = random.randint(3, 10)
agility = random.randint(3, 10)
technique = random.randint(3, 10)
teamwork = random.randint(4, 10)
attitude = random.randint(4, 10)
overall = round((speed + agility + technique + teamwork + attitude) / 5, 1)
positions = ['Forward', 'Midfield', 'Defense', 'Goalie', 'Wing', 'Center']
mecanics = random.randint(3, 10)
cohesion = random.randint(3, 10)
communication = random.randint(3, 10)
gamesense = random.randint(4, 10)
versatility = random.randint(4, 10)
discipline = random.randint(3, 10)
analysis = random.randint(3, 10)
sport_ethics = random.randint(4, 10)
mental = random.randint(4, 10)
overall = round((mecanics + cohesion + communication + gamesense + versatility + discipline + analysis + sport_ethics + mental) / 9, 1)
eval_entry = Evaluation(
tryout_id=tryouts[2].id,
player_id=player.id,
evaluator_id=coach.id,
speed_score=speed,
agility_score=agility,
technique_score=technique,
teamwork_score=teamwork,
attitude_score=attitude,
mecanics_score=mecanics,
cohesion_score=cohesion,
communication_score=communication,
gamesense_score=gamesense,
versatility_score=versatility,
discipline_score=discipline,
analysis_score=analysis,
sport_ethics_score=sport_ethics,
mental_score=mental,
overall_score=overall,
comments=f"{'Excellent' if overall > 8 else 'Solid'} display of skills during the camp.",
position_recommendation=random.choice(positions)
position_recommendation=random.choice(val_positions)
)
db.session.add(eval_entry)
eval_data.append(eval_entry)
@@ -268,14 +303,15 @@ def seed_database():
db.session.add(team2)
db.session.commit()
# Assign players to teams
# Assign players to teams (Valorant tryout uses Valorant positions)
val_positions = ['Controller', 'Initiator', 'Duelist', 'Sentinel']
team_members_data = [
(team1.id, players[0].id, 'Forward'),
(team1.id, players[1].id, 'Midfield'),
(team1.id, players[2].id, 'Defense'),
(team1.id, players[3].id, 'Goalie'),
(team2.id, players[4].id, 'Midfield'),
(team2.id, players[5].id, 'Forward'),
(team1.id, players[0].id, random.choice(val_positions)),
(team1.id, players[1].id, random.choice(val_positions)),
(team1.id, players[2].id, random.choice(val_positions)),
(team1.id, players[3].id, random.choice(val_positions)),
(team2.id, players[4].id, random.choice(val_positions)),
(team2.id, players[5].id, random.choice(val_positions)),
]
for team_id, player_id, position in team_members_data:
tm = TeamMember(team_id=team_id, player_id=player_id, position=position)
@@ -340,6 +376,7 @@ def seed_database():
print("Player: username='jplayer1', password='password'")
print("Scout: username='scout1', password='password'")
if __name__ == '__main__':
from app import create_app
app = create_app()