forked from imwilsonxu/fbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
69 lines (54 loc) · 1.61 KB
/
manage.py
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
# -*- coding: utf-8 -*-
import os
from flask.ext.script import Manager
from fbone import create_app
from fbone.extensions import db
from fbone.user import User, UserDetail, ADMIN, USER, ACTIVE
app = create_app()
manager = Manager(app)
project_root_path = os.path.join(os.path.dirname(app.root_path))
@manager.command
def run():
"""Run local server."""
app.run()
@manager.command
def initdb():
"""Init/reset database."""
db.drop_all()
db.create_all()
# Init/reset data.
demo = User(
name=u'demo',
email=u'[email protected]',
password=u'123456',
role_id=USER,
status_id=ACTIVE,
user_detail=UserDetail(
age=10,
url=u'http://demo.example.com',
deposit=100.00,
location=u'Hangzhou',
bio=u'Demo Guy is ... hmm ... just a demo guy.'),
)
admin = User(
name=u'admin',
email=u'[email protected]',
password=u'123456',
role_id=ADMIN,
status_id=ACTIVE,
user_detail=UserDetail(
age=10,
url=u'http://admin.example.com',
deposit=100.00,
location=u'Hangzhou',
bio=u'admin Guy is ... hmm ... just a admin guy.'),
)
db.session.add(demo)
db.session.add(admin)
db.session.commit()
manager.add_option('-c', '--config',
dest="config",
required=False,
help="config file")
if __name__ == "__main__":
manager.run()