|
|
from app import create_app, db |
|
|
from app.models import ( |
|
|
User, |
|
|
Metal, |
|
|
UserMetal, |
|
|
Transaction, |
|
|
ReferralCommission, |
|
|
Notification, |
|
|
) |
|
|
|
|
|
app = create_app() |
|
|
|
|
|
|
|
|
@app.shell_context_processor |
|
|
def make_shell_context(): |
|
|
return { |
|
|
"db": db, |
|
|
"User": User, |
|
|
"Metal": Metal, |
|
|
"UserMetal": UserMetal, |
|
|
"Transaction": Transaction, |
|
|
"ReferralCommission": ReferralCommission, |
|
|
"Notification": Notification, |
|
|
} |
|
|
|
|
|
|
|
|
@app.cli.command() |
|
|
def init_db(): |
|
|
db.create_all() |
|
|
print("Database initialized.") |
|
|
|
|
|
|
|
|
@app.cli.command() |
|
|
def create_admin(): |
|
|
admin = User(phone="+22812345678", country_code="+228", password="admin123") |
|
|
admin.is_admin = True |
|
|
db.session.add(admin) |
|
|
db.session.commit() |
|
|
print(f"Admin user created with referral code: {admin.referral_code}") |
|
|
|
|
|
|
|
|
@app.cli.command() |
|
|
def create_sample_metals(): |
|
|
metals_data = [ |
|
|
{ |
|
|
"name": "Lingot d'Or Premium", |
|
|
"description": "Lingot d'or pur 24 carats, investissement sécurisé", |
|
|
"price": 5000, |
|
|
"daily_gain": 450, |
|
|
"cycle_days": 60, |
|
|
"image_url": "/static/images/gold-bar.jpg", |
|
|
}, |
|
|
{ |
|
|
"name": "Diamant Brut", |
|
|
"description": "Diamant naturel de haute qualité", |
|
|
"price": 10000, |
|
|
"daily_gain": 850, |
|
|
"cycle_days": 90, |
|
|
"image_url": "/static/images/diamond.jpg", |
|
|
}, |
|
|
{ |
|
|
"name": "Argent Sterling", |
|
|
"description": "Lingot d'argent sterling 925", |
|
|
"price": 2500, |
|
|
"daily_gain": 200, |
|
|
"cycle_days": 45, |
|
|
"image_url": "/static/images/silver-bar.jpg", |
|
|
}, |
|
|
{ |
|
|
"name": "Platine Pur", |
|
|
"description": "Lingot de platine pur, investissement rare", |
|
|
"price": 15000, |
|
|
"daily_gain": 1200, |
|
|
"cycle_days": 120, |
|
|
"image_url": "/static/images/platinum-bar.jpg", |
|
|
}, |
|
|
] |
|
|
|
|
|
for metal_data in metals_data: |
|
|
metal = Metal(**metal_data) |
|
|
db.session.add(metal) |
|
|
|
|
|
db.session.commit() |
|
|
print("Sample metals created.") |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
app.run(debug=False,host="0.0.0.0") |
|
|
|