remodulation du projet et des classes
This commit is contained in:
@@ -0,0 +1,460 @@
|
||||
"""Database seeding script for Team Tryouts application.
|
||||
|
||||
Creates sample data using the polymorphic User subclasses:
|
||||
Admin, Manager, Coach, Player, Scout.
|
||||
"""
|
||||
|
||||
from app.extensions import db, hash_password
|
||||
from app.models import (
|
||||
Admin, Manager, Coach, Player, Scout,
|
||||
Tryout, TryoutRegistration, Evaluation, Team, TeamMember,
|
||||
OrgTeam, TeamPlayer,
|
||||
PlayerDisponibility, CoachAvailability,
|
||||
UserGamertag, TeamNote, PersonalNote,
|
||||
Match, MatchParticipant,
|
||||
BaseAvailability, BaseMatch, BaseParticipant,
|
||||
)
|
||||
from datetime import datetime, timedelta, time
|
||||
import random
|
||||
|
||||
|
||||
def seed_database():
|
||||
"""Seed the database with sample data for development and testing."""
|
||||
|
||||
# Clear existing data (order matters for FK constraints)
|
||||
for table in ['player_disponibilities', 'coach_availabilities',
|
||||
'match_participants', 'team_match_participants',
|
||||
'matches', 'team_matches',
|
||||
'team_players', 'team_members', 'teams',
|
||||
'evaluations', 'tryout_registrations', 'tryouts',
|
||||
'org_team_coaches', 'org_team_managers',
|
||||
'org_teams', 'user_gamertags',
|
||||
'personal_notes', 'team_notes',
|
||||
'one_on_one_requests',
|
||||
'users']:
|
||||
db.session.execute(db.text(f'DELETE FROM {table}'))
|
||||
db.session.commit()
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Staff users (Admin, Manager, Coach, Scout)
|
||||
# -----------------------------------------------------------------------
|
||||
admin = Admin(
|
||||
username='admin', password_hash=hash_password('password'),
|
||||
role='admin', full_name='Sarah Johnson',
|
||||
email='[email protected]', phone='555-0101')
|
||||
db.session.add(admin)
|
||||
|
||||
manager1 = Manager(
|
||||
username='manager1', password_hash=hash_password('password'),
|
||||
role='manager', full_name='Mike Williams',
|
||||
email='[email protected]', phone='555-0102')
|
||||
db.session.add(manager1)
|
||||
|
||||
manager2 = Manager(
|
||||
username='manager2', password_hash=hash_password('password'),
|
||||
role='manager', full_name='Emily Davis',
|
||||
email='[email protected]', phone='555-0103')
|
||||
db.session.add(manager2)
|
||||
|
||||
coach1 = Coach(
|
||||
username='coach1', password_hash=hash_password('password'),
|
||||
role='coach', full_name='Coach Thompson',
|
||||
email='[email protected]', phone='555-0104',
|
||||
discord_user_id='484107446298738689')
|
||||
db.session.add(coach1)
|
||||
|
||||
coach2 = Coach(
|
||||
username='coach2', password_hash=hash_password('password'),
|
||||
role='coach', full_name='Coach Martinez',
|
||||
email='[email protected]', phone='555-0105')
|
||||
db.session.add(coach2)
|
||||
|
||||
coach3 = Coach(
|
||||
username='coach3', password_hash=hash_password('password'),
|
||||
role='coach', full_name='Coach Anderson',
|
||||
email='[email protected]', phone='555-0106')
|
||||
db.session.add(coach3)
|
||||
|
||||
scout = Scout(
|
||||
username='scout1', password_hash=hash_password('password'),
|
||||
role='scout', full_name='Alex Rivera',
|
||||
email='[email protected]', phone='555-0107')
|
||||
db.session.add(scout)
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Players
|
||||
# -----------------------------------------------------------------------
|
||||
player_data = [
|
||||
{'username': 'jplayer1', 'full_name': 'nordjan', 'email': '[email protected]',
|
||||
'games': 'Valorant, Counter-Strike 2, Rainbow Six Siege, Rocket League, Overwatch 2',
|
||||
'discord_username': 'nordjan', 'discord_user_id': '484107446298738689',
|
||||
'league_os_profile': 'https://leagueos.gg/player/nordjan'},
|
||||
{'username': 'jplayer2', 'full_name': 'Emma Garcia', 'email': '[email protected]',
|
||||
'games': 'League of Legends,Valorant',
|
||||
'discord_username': 'EmmaG#4452', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/emmagarcia'},
|
||||
{'username': 'jplayer3', 'full_name': 'Liam Brown', 'email': '[email protected]',
|
||||
'games': 'Apex Legends,Fortnite',
|
||||
'discord_username': 'LiamB#8103', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/liambrown'},
|
||||
{'username': 'jplayer4', 'full_name': 'Sophia Lee', 'email': '[email protected]',
|
||||
'games': 'Overwatch 2,Valorant',
|
||||
'discord_username': 'SophiaL#3327', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/sophialee'},
|
||||
{'username': 'jplayer5', 'full_name': 'Noah Taylor', 'email': '[email protected]',
|
||||
'games': 'Counter-Strike 2,Rainbow Six Siege',
|
||||
'discord_username': 'NoahT#6614', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/noahtaylor'},
|
||||
{'username': 'jplayer6', 'full_name': 'Olivia Martin', 'email': '[email protected]',
|
||||
'games': 'Rocket League,Fortnite',
|
||||
'discord_username': 'OliviaM#2298', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/oliviamartin'},
|
||||
{'username': 'jplayer7', 'full_name': 'Ethan Clark', 'email': '[email protected]',
|
||||
'games': 'Valorant,Apex Legends',
|
||||
'discord_username': 'EthanC#7743', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/ethanclark'},
|
||||
{'username': 'jplayer8', 'full_name': 'Ava White', 'email': '[email protected]',
|
||||
'games': 'League of Legends,Counter-Strike 2',
|
||||
'discord_username': 'AvaW#5561', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/avawhite'},
|
||||
{'username': 'jplayer9', 'full_name': 'Mason Hall', 'email': '[email protected]',
|
||||
'games': 'Call of Duty,Rocket League',
|
||||
'discord_username': 'MasonH#1189', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/masonhall'},
|
||||
{'username': 'jplayer10', 'full_name': 'Isabella Adams', 'email': '[email protected]',
|
||||
'games': 'Overwatch 2,Dota 2',
|
||||
'discord_username': 'IsabellaA#4437', 'discord_user_id': '',
|
||||
'league_os_profile': 'https://leagueos.gg/player/isabellaadams'},
|
||||
]
|
||||
|
||||
players = []
|
||||
for i, data in enumerate(player_data, start=10):
|
||||
p = Player(
|
||||
username=data['username'], password_hash=hash_password('password'),
|
||||
role='player', full_name=data['full_name'],
|
||||
email=data['email'], phone=f'555-01{i:02d}',
|
||||
games=data['games'],
|
||||
discord_username=data['discord_username'],
|
||||
discord_user_id=data['discord_user_id'],
|
||||
league_os_profile=data['league_os_profile'])
|
||||
db.session.add(p)
|
||||
players.append(p)
|
||||
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {7 + 10} users (7 staff + 10 players)")
|
||||
|
||||
# Map for easy reference
|
||||
coaches = [coach1, coach2, coach3]
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Gamertags
|
||||
# -----------------------------------------------------------------------
|
||||
gt_map = [
|
||||
(players[0], 'Valorant', 'nordjan#bad', None),
|
||||
(players[0], 'Counter-Strike 2', 'nordjan', None),
|
||||
(players[0], 'Rainbow Six Siege', 'nordjan', 'Ubisoft'),
|
||||
(players[0], 'Rocket League', 'nordjiano', 'Epic'),
|
||||
(players[0], 'Overwatch 2', 'nordjan', 'PC'),
|
||||
(players[1], 'League of Legends', 'emmagarcia_lol', None),
|
||||
(players[1], 'Valorant', 'emmagarcia_val', None),
|
||||
(players[2], 'Apex Legends', 'liambrown_apex', 'PC'),
|
||||
(players[2], 'Fortnite', 'liambrown_fn', 'PC'),
|
||||
(players[3], 'Overwatch 2', 'sophialee_ow', 'PC'),
|
||||
(players[3], 'Valorant', 'sophialee_val', None),
|
||||
(players[4], 'Counter-Strike 2', 'noahtaylor_cs', None),
|
||||
(players[4], 'Rainbow Six Siege', 'noahtaylor_r6', 'Ubisoft'),
|
||||
(players[5], 'Rocket League', 'oliviamartin_rl', 'Epic'),
|
||||
(players[5], 'Fortnite', 'oliviamartin_fn', 'PC'),
|
||||
(players[6], 'Valorant', 'ethanclark_val', None),
|
||||
(players[6], 'Apex Legends', 'ethanclark_apex', 'PC'),
|
||||
(players[7], 'League of Legends', 'avawhite_lol', None),
|
||||
(players[7], 'Counter-Strike 2', 'avawhite_cs', None),
|
||||
(players[8], 'Call of Duty', 'masonhall_cod', 'PC'),
|
||||
(players[8], 'Rocket League', 'masonhall_rl', 'Epic'),
|
||||
(players[9], 'Overwatch 2', 'isabellaadams_ow', 'PC'),
|
||||
(players[9], 'Dota 2', 'isabellaadams_dota', None),
|
||||
]
|
||||
for p, game, tag, platform in gt_map:
|
||||
db.session.add(UserGamertag(user_id=p.id, game=game, gamertag=tag, platform=platform))
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(gt_map)} gamertags")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Organisation Teams
|
||||
# -----------------------------------------------------------------------
|
||||
org_teams_data = [
|
||||
{'name': 'Rocket League main', 'coach': coaches[0], 'creator': admin},
|
||||
{'name': 'CS2', 'coach': coaches[1], 'creator': admin},
|
||||
{'name': 'Valorant', 'coach': coaches[2], 'creator': admin},
|
||||
{'name': 'Rocket League acad', 'coach': None, 'creator': manager1},
|
||||
]
|
||||
|
||||
org_teams = []
|
||||
for data in org_teams_data:
|
||||
ot = OrgTeam(
|
||||
name=data['name'],
|
||||
coach_id=data['coach'].id if data['coach'] else None,
|
||||
created_by=data['creator'].id)
|
||||
db.session.add(ot)
|
||||
org_teams.append(ot)
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(org_teams)} organisation teams")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Tryouts
|
||||
# -----------------------------------------------------------------------
|
||||
tryouts_data = [
|
||||
{'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'],
|
||||
status=data['status'], max_players=15,
|
||||
created_by=data['creator'].id,
|
||||
target_org_team_id=data['target_team'].id if data['target_team'] else None)
|
||||
db.session.add(t)
|
||||
tryouts.append(t)
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(tryouts)} tryouts")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Registrations
|
||||
# -----------------------------------------------------------------------
|
||||
reg_assignments = [
|
||||
(tryouts[0], players[:3]),
|
||||
(tryouts[1], players[3:5]),
|
||||
(tryouts[2], players),
|
||||
]
|
||||
regs = []
|
||||
for tryout, plist in reg_assignments:
|
||||
for player in plist:
|
||||
reg = TryoutRegistration(
|
||||
tryout_id=tryout.id, player_id=player.id,
|
||||
status=random.choice(['registered', 'attended', 'attended', 'no_show']))
|
||||
db.session.add(reg)
|
||||
regs.append(reg)
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(regs)} registrations")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Evaluations
|
||||
# -----------------------------------------------------------------------
|
||||
eval_count = 0
|
||||
rl_positions = ['None needed', 'None', 'N/A']
|
||||
for player in players[:8]:
|
||||
for coach in coaches:
|
||||
if random.random() > 0.3:
|
||||
ms = [random.randint(4, 10) for _ in range(9)]
|
||||
overall = round(sum(ms) / 9, 1)
|
||||
db.session.add(Evaluation(
|
||||
tryout_id=tryouts[0].id, player_id=player.id,
|
||||
evaluator_id=coach.id,
|
||||
mecanics_score=ms[0], cohesion_score=ms[1],
|
||||
communication_score=ms[2], gamesense_score=ms[3],
|
||||
versatility_score=ms[4], discipline_score=ms[5],
|
||||
analysis_score=ms[6], sport_ethics_score=ms[7],
|
||||
mental_score=ms[8], 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(rl_positions)))
|
||||
eval_count += 1
|
||||
|
||||
val_positions = ['Controller', 'Initiator', 'Duelist', 'Sentinel']
|
||||
for player in players[:6]:
|
||||
for coach in coaches[:2]:
|
||||
ms = [random.randint(3, 10) for _ in range(9)]
|
||||
overall = round(sum(ms) / 9, 1)
|
||||
db.session.add(Evaluation(
|
||||
tryout_id=tryouts[2].id, player_id=player.id,
|
||||
evaluator_id=coach.id,
|
||||
mecanics_score=ms[0], cohesion_score=ms[1],
|
||||
communication_score=ms[2], gamesense_score=ms[3],
|
||||
versatility_score=ms[4], discipline_score=ms[5],
|
||||
analysis_score=ms[6], sport_ethics_score=ms[7],
|
||||
mental_score=ms[8], overall_score=overall,
|
||||
comments=f"{'Excellent' if overall > 8 else 'Solid'} display of skills during the camp.",
|
||||
position_recommendation=random.choice(val_positions)))
|
||||
eval_count += 1
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {eval_count} evaluations")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Tryout-specific teams
|
||||
# -----------------------------------------------------------------------
|
||||
team1 = Team(tryout_id=tryouts[2].id, name='Alpha Team', created_by=admin.id)
|
||||
team2 = Team(tryout_id=tryouts[2].id, name='Bravo Team', created_by=admin.id)
|
||||
db.session.add(team1)
|
||||
db.session.add(team2)
|
||||
db.session.commit()
|
||||
|
||||
val_positions = ['Controller', 'Initiator', 'Duelist', 'Sentinel']
|
||||
team_members_tuples = [
|
||||
(team1, players[0]), (team1, players[1]),
|
||||
(team1, players[2]), (team1, players[3]),
|
||||
(team2, players[4]), (team2, players[5]),
|
||||
]
|
||||
for t, p in team_members_tuples:
|
||||
db.session.add(TeamMember(team_id=t.id, player_id=p.id,
|
||||
position=random.choice(val_positions)))
|
||||
db.session.commit()
|
||||
print("[OK] Created 2 tryout-specific teams with player assignments")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Org-team player assignments
|
||||
# -----------------------------------------------------------------------
|
||||
assignments = [
|
||||
(org_teams[0], players[0], 'starter'),
|
||||
(org_teams[0], players[1], 'starter'),
|
||||
(org_teams[0], players[2], 'substitute'),
|
||||
(org_teams[1], players[3], 'starter'),
|
||||
(org_teams[1], players[4], 'starter'),
|
||||
(org_teams[1], players[5], 'substitute'),
|
||||
(org_teams[2], players[6], 'starter'),
|
||||
(org_teams[2], players[7], 'substitute'),
|
||||
]
|
||||
for team, player, status in assignments:
|
||||
db.session.add(TeamPlayer(player_id=player.id, org_team_id=team.id, status=status))
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(assignments)} org-team player assignments")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Disponibilities
|
||||
# -----------------------------------------------------------------------
|
||||
time_slots = [(17, 0), (17, 30), (18, 0), (18, 30), (19, 0), (19, 30),
|
||||
(20, 0), (20, 30), (21, 0), (21, 30), (22, 0), (22, 30), (23, 0)]
|
||||
disp_count = 0
|
||||
for player in players:
|
||||
for day in range(7):
|
||||
num = random.randint(3, 8)
|
||||
for hour, minute in random.sample(time_slots, min(num, len(time_slots))):
|
||||
end_h, end_m = hour, minute + 30
|
||||
if end_m >= 60:
|
||||
end_m -= 60; end_h += 1
|
||||
db.session.add(PlayerDisponibility(
|
||||
player_id=player.id, day_of_week=day,
|
||||
start_time=time(hour, minute), end_time=time(end_h, end_m)))
|
||||
disp_count += 1
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {disp_count} player disponibilities")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Coach availabilities
|
||||
# -----------------------------------------------------------------------
|
||||
coach_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)]
|
||||
ca_count = 0
|
||||
for coach, _ in zip(coaches[:3], org_teams[:3]):
|
||||
days = [0, 1, 2, 3, 4] if coach.id == coaches[2].id else [0, 1, 2, 3, 4, 5]
|
||||
for day in days:
|
||||
num = random.randint(3, 5)
|
||||
for hour, minute in random.sample(coach_slots, min(num, len(coach_slots))):
|
||||
end_h, end_m = hour, minute + 30
|
||||
if end_m >= 60:
|
||||
end_m -= 60; end_h += 1
|
||||
db.session.add(CoachAvailability(
|
||||
coach_id=coach.id, day_of_week=day,
|
||||
start_time=time(hour, minute), end_time=time(end_h, end_m)))
|
||||
ca_count += 1
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {ca_count} coach availabilities")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Team notes
|
||||
# -----------------------------------------------------------------------
|
||||
notes = [
|
||||
(org_teams[0], coaches[0],
|
||||
'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!'),
|
||||
(org_teams[1], coaches[1],
|
||||
'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.'),
|
||||
(org_teams[2], coaches[2],
|
||||
'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 team, coach, content in notes:
|
||||
db.session.add(TeamNote(org_team_id=team.id, coach_id=coach.id, content=content))
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(notes)} team notes")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Personal notes
|
||||
# -----------------------------------------------------------------------
|
||||
pnotes = [
|
||||
(players[0], coaches[0], 'Your mechanics are improving! Focus on staying calm during high-pressure situations. Keep practicing those flip resets.'),
|
||||
(players[0], coaches[0], 'Good positioning in last scrim. Work on your kickoffs - consistency will help the team.'),
|
||||
(players[1], coaches[0], 'Your aerial game is strong. Try to be more aggressive on the ball when you have space.'),
|
||||
(players[3], coaches[1], 'Need to work on your smoke grenade placement. Practice pre-aiming and strafe stopping.'),
|
||||
(players[4], coaches[1], 'Good clutch performance! Keep your utility management consistent throughout rounds.'),
|
||||
(players[6], coaches[2], 'Your aim trainer routine is paying off. Work on your agent abilities usage timing.'),
|
||||
(players[7], coaches[2], 'Focus on communication in matches. Call out enemy positions clearly and ask for help when needed.'),
|
||||
]
|
||||
for player, coach, content in pnotes:
|
||||
db.session.add(PersonalNote(player_id=player.id, coach_id=coach.id, content=content))
|
||||
db.session.commit()
|
||||
print(f"[OK] Created {len(pnotes)} personal notes")
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Matches
|
||||
# -----------------------------------------------------------------------
|
||||
team1 = Team.query.filter_by(name='Alpha Team').first()
|
||||
team2 = Team.query.filter_by(name='Bravo Team').first()
|
||||
|
||||
m1 = Match(tryout_id=tryouts[0].id, title='Alpha vs Bravo',
|
||||
date=tryouts[0].date, start_time=time(18, 0), end_time=time(18, 30),
|
||||
match_type='team_vs_team', created_by=admin.id,
|
||||
team1_id=team1.id if team1 else None, team2_id=team2.id if team2 else None)
|
||||
m2 = Match(tryout_id=tryouts[0].id, title='Bravo vs Alpha',
|
||||
date=tryouts[0].date, start_time=time(19, 0), end_time=time(19, 30),
|
||||
match_type='team_vs_team', created_by=admin.id,
|
||||
team1_id=team2.id if team2 else None, team2_id=team1.id if team1 else None)
|
||||
m3 = Match(tryout_id=tryouts[1].id, title='Scrimmage',
|
||||
date=tryouts[1].date, start_time=time(17, 0), end_time=time(17, 30),
|
||||
match_type='player_scrim', created_by=admin.id)
|
||||
m4 = Match(tryout_id=tryouts[2].id, title='Team Alpha Scrim',
|
||||
date=tryouts[2].date, start_time=time(18, 30), end_time=time(19, 0),
|
||||
match_type='player_vs_player', created_by=admin.id)
|
||||
db.session.add_all([m1, m2, m3, m4])
|
||||
db.session.commit()
|
||||
print("[OK] Created 4 matches")
|
||||
|
||||
# Match participants
|
||||
for player in players[3:5]:
|
||||
db.session.add(MatchParticipant(match_id=m3.id, player_id=player.id))
|
||||
for player in players[:2]:
|
||||
db.session.add(MatchParticipant(match_id=m4.id, player_id=player.id, team_side=1))
|
||||
for player in players[2:4]:
|
||||
db.session.add(MatchParticipant(match_id=m4.id, player_id=player.id, team_side=2))
|
||||
db.session.commit()
|
||||
print("[OK] Created match participants")
|
||||
|
||||
print("\n[SUCCESS] Database seeded successfully!")
|
||||
print("\n=== Login Credentials ===")
|
||||
print("Admin: username='admin', password='password'")
|
||||
print("Manager: username='manager1', password='password'")
|
||||
print("Coach: username='coach1', password='password'")
|
||||
print("Player: username='jplayer1', password='password'")
|
||||
print("Scout: username='scout1', password='password'")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from app.app import create_app
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
seed_database()
|
||||
Reference in New Issue
Block a user