Files
fleet-management/create_admin.py
T
alro65 5b7b41aa50 Initial commit: Fleet Management app with security hardening and background launcher
- Flask app with SQLAlchemy, Flask-Login, Flask-Mail
- Admin/owner roles, vessel management, charters, work orders
- Background launcher (Iniciar.vbs) runs server without terminal window
- Root redirect fixed: / → /login
- debug=False, use_reloader=False for pythonw.exe compatibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 02:54:10 -04:00

32 lines
1.1 KiB
Python

from app import create_app, db
from app.models import User, Company
from werkzeug.security import generate_password_hash
app = create_app()
with app.app_context():
# Verificar si ya existe la compañía
company = Company.query.filter_by(email='admin@fleet.com').first()
if not company:
company = Company(name='Al & Al Management LLC', type='management', email='admin@fleet.com')
db.session.add(company)
db.session.commit()
print("Compañía creada")
else:
print("Compañía ya existe")
# Verificar si ya existe el usuario
user = User.query.filter_by(email='admin@fleet.com').first()
if not user:
user = User(
name='Administrador',
email='admin@fleet.com',
password_hash=generate_password_hash('admin123'),
company_id=company.id,
role='admin'
)
db.session.add(user)
db.session.commit()
print("Usuario admin creado: admin@fleet.com / admin123")
else:
print("Usuario admin ya existe: admin@fleet.com / admin123")