forked from imwilsonxu/fbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
77 lines (60 loc) · 1.86 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
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
import os
from flask.ext.script import Manager, prompt, prompt_pass, prompt_bool
from fbone import create_app
from fbone.extensions import db
from fbone.models import User, UserDetail, Role
manager = Manager(create_app())
from fbone import create_app
app = create_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.
role_user = Role(name=u'user')
role_admin = Role(name=u'admin')
db.session.add(role_user)
db.session.add(role_admin)
db.session.commit()
demo = User(
name = u'demo',
email = u'demo@example.com',
password = u'123456',
role = role_user,
user_detail = UserDetail(
real_name = u'Demo Guy',
age = 10,
url = u'http://demo.example.com',
location = u'Hangzhou',
bio = u'Demo Guy is ... hmm ... just a demo guy.',
),
)
admin = User(
name = u'admin',
email = u'admin@example.com',
password = u'123456',
role = role_admin,
user_detail = UserDetail(
real_name = u'admin Guy',
age = 10,
url = u'http://admin.example.com',
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()