Ajout de fonctionnalités:

Ajout de notes personnels et de notes d'équipe avec historique.
Ajout de prise de rendez-vous avec un coach selon ses disponibilités
This commit is contained in:
cedrick2711
2026-07-16 20:34:56 -04:00
parent b02fe29e30
commit 24fcc9a048
24 changed files with 2625 additions and 264 deletions
+135 -2
View File
@@ -6,7 +6,7 @@ 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
from models import User, Tryout, TryoutRegistration, Evaluation, Team, TeamMember, OrgTeam, PlayerDisponibility, UserGamertag, CoachAvailability, TeamNote, PersonalNote, Match, MatchParticipant
from datetime import datetime, timedelta, time
import random
@@ -363,8 +363,141 @@ def seed_database():
db.session.add(d)
disponibilities.append(d)
# Create sample coach availabilities
coach_availabilities = []
coach_avail_time_slots = [(16, 0), (16, 30), (17, 0), (17, 30), (18, 0), (18, 30), (19, 0), (19, 30), (20, 0), (20, 30), (21, 0), (21, 30)]
# Only coaches with teams get availabilities
for coach, org_team in zip(coaches[:3], org_teams[:3]):
if coach.id == coaches[2].id: # Skip coach3 as they don't have all days
days_available = [0, 1, 2, 3, 4] # Mon-Fri
else:
days_available = [0, 1, 2, 3, 4, 5] # Mon-Sat
for day in days_available:
num_slots = random.randint(3, 5)
chosen_slots = random.sample(coach_avail_time_slots, min(num_slots, len(coach_avail_time_slots)))
for hour, minute in chosen_slots:
start_time = time(hour, minute)
end_minute = minute + 30
end_hour = hour
if end_minute >= 60:
end_minute -= 60
end_hour += 1
end_time = time(end_hour, end_minute)
ca = CoachAvailability(
coach_id=coach.id,
day_of_week=day,
start_time=start_time,
end_time=end_time
)
db.session.add(ca)
coach_availabilities.append(ca)
db.session.commit()
print(f"[OK] Created {len(disponibilities)} player disponibilities")
print(f"[OK] Created {len(coach_availabilities)} coach availabilities")
# Create team notes for each org team
team_notes_data = [
{
'team': org_teams[0],
'coach': coaches[0],
'content': 'Team, focus on rotation and positioning during scrims. We need to improve our mechanical consistency and work on post-platoon transitions. Remember to communicate clearly and stay positive!'
},
{
'team': org_teams[1],
'coach': coaches[1],
'content': 'Great progress this week! Keep working on your smoke lineups and utility usage. Individual practice on aim trainers is paying off. Next week we focus on map control and trading.'
},
{
'team': org_teams[2],
'coach': coaches[2],
'content': 'Agent comp needs work. Make sure to stick to your roles and trust your teammates. Work on your crosshair placement and pre-aim common angles. Team chemistry is key!'
},
]
for note_data in team_notes_data:
note = TeamNote(
org_team_id=note_data['team'].id,
coach_id=note_data['coach'].id,
content=note_data['content']
)
db.session.add(note)
db.session.commit()
print(f"[OK] Created {len(team_notes_data)} team notes")
# Create personal notes for players
personal_notes_data = [
{'player': players[0], 'coach': coaches[0], 'content': 'Your mechanics are improving! Focus on staying calm during high-pressure situations. Keep practicing those flip resets.'},
{'player': players[0], 'coach': coaches[0], 'content': 'Good positioning in last scrim. Work on your kickoffs - consistency will help the team.'},
{'player': players[1], 'coach': coaches[0], 'content': 'Your aerial game is strong. Try to be more aggressive on the ball when you have space.'},
{'player': players[3], 'coach': coaches[1], 'content': 'Need to work on your smoke grenade placement. Practice pre-aiming and strafe stopping.'},
{'player': players[4], 'coach': coaches[1], 'content': 'Good clutch performance! Keep your utility management consistent throughout rounds.'},
{'player': players[6], 'coach': coaches[2], 'content': 'Your aim trainer routine is paying off. Work on your agent abilities usage timing.'},
{'player': players[7], 'coach': coaches[2], 'content': 'Focus on communication in matches. Call out enemy positions clearly and ask for help when needed.'},
]
for note_data in personal_notes_data:
note = PersonalNote(
player_id=note_data['player'].id,
coach_id=note_data['coach'].id,
content=note_data['content']
)
db.session.add(note)
db.session.commit()
print(f"[OK] Created {len(personal_notes_data)} personal notes")
# Create sample matches for tryouts (for calendar testing)
matches_data = [
{'tryout': tryouts[0], 'title': 'Alpha vs Bravo', 'date': tryouts[0].date, 'start_time': time(18, 0), 'end_time': time(18, 30), 'match_type': 'team_vs_team', 'team1_id': team1.id if 'team1' in dir() else None},
{'tryout': tryouts[0], 'title': 'Bravo vs Alpha', 'date': tryouts[0].date, 'start_time': time(19, 0), 'end_time': time(19, 30), 'match_type': 'team_vs_team'},
{'tryout': tryouts[1], 'title': 'Scrimmage', 'date': tryouts[1].date, 'start_time': time(17, 0), 'end_time': time(17, 30), 'match_type': 'player_scrim'},
{'tryout': tryouts[2], 'title': 'Team Alpha Scrim', 'date': tryouts[2].date, 'start_time': time(18, 30), 'end_time': time(19, 0), 'match_type': 'player_vs_player'},
]
# Re-fetch teams after commit
team1 = Team.query.filter_by(name='Alpha Team').first()
team2 = Team.query.filter_by(name='Bravo Team').first()
matches = []
for i, m_data in enumerate(matches_data):
m = Match(
tryout_id=m_data['tryout'].id,
title=m_data['title'],
date=m_data['date'],
start_time=m_data['start_time'],
end_time=m_data['end_time'],
match_type=m_data['match_type'],
created_by=president.id,
team1_id=m_data.get('team1_id') or (team1.id if i < 2 else None),
team2_id=team2.id if i < 2 else None
)
db.session.add(m)
matches.append(m)
db.session.commit()
print(f"[OK] Created {len(matches)} matches")
# Add match participants for scrim matches
player_scrim_match = matches[2] if len(matches) > 2 else None
if player_scrim_match:
for player in players[3:5]:
mp = MatchParticipant(match_id=player_scrim_match.id, player_id=player.id)
db.session.add(mp)
pvp_match = matches[3] if len(matches) > 3 else None
if pvp_match and team1:
for player in players[:2]:
mp = MatchParticipant(match_id=pvp_match.id, player_id=player.id, team_side=1)
db.session.add(mp)
for player in players[2:4]:
mp = MatchParticipant(match_id=pvp_match.id, player_id=player.id, team_side=2)
db.session.add(mp)
db.session.commit()
print("[OK] Created match participants")
print("\n[SUCCESS] Database seeded successfully!")
print("\n=== Login Credentials ===")