QUA-002, premiere moitie. **Ce commit ne fait que reformater** : aucun changement de comportement, aucune ligne de logique touchee. 72 fichiers, 4 restaient deja conformes. Il est isole exprès, pour que `git log -p` sur les commits voisins reste lisible. `quote-style = "preserve"` etait deja pose dans pyproject.toml, ce qui evite le brassage guillemets simples / doubles : le diff porte sur les retours a la ligne, l indentation des appels longs et les virgules finales, pas sur le style de chaine. Verification : 263 tests passent avant et apres, ruff check propre. L activation en CI arrive dans le commit suivant, separement, pour que ce diff-ci ne contienne rien d autre. Co-Authored-By: Claude Opus 5 <[email protected]>
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
"""Database seeding script for Team Tryouts application.
|
|
|
|
Wipes all data and creates an admin user. Run manually with:
|
|
python -m app.supporting_scripts.seed
|
|
"""
|
|
|
|
from app.extensions import db, hash_password
|
|
from app.models import Admin
|
|
|
|
|
|
def seed_database():
|
|
"""Delete all existing data and create a single admin account."""
|
|
|
|
# Delete all data in FK-safe order
|
|
print("Deleting existing data...")
|
|
tables = [
|
|
'one_on_one_requests',
|
|
'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',
|
|
'team_notes',
|
|
'personal_notes',
|
|
'user_gamertags',
|
|
'org_teams',
|
|
'users',
|
|
]
|
|
for table in tables:
|
|
db.session.execute(db.text(f'DELETE FROM {table}'))
|
|
db.session.commit()
|
|
print("[OK] All data deleted.")
|
|
|
|
# Create the admin user
|
|
admin = Admin(
|
|
username='admin',
|
|
password_hash=hash_password('password'),
|
|
role='admin',
|
|
full_name='Admin',
|
|
email='[email protected]',
|
|
)
|
|
db.session.add(admin)
|
|
db.session.commit()
|
|
|
|
print("[OK] Created admin user")
|
|
print("\n=== Admin Credentials ===")
|
|
print("Username: admin")
|
|
print("Password: password")
|
|
print("\n[SUCCESS] Database reset and seeded!")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
from app.app import create_app
|
|
|
|
app = create_app()
|
|
with app.app_context():
|
|
seed_database()
|