File size: 2,241 Bytes
08ec4c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a3570e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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")