forked from maciejmalycha/code_review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_create.py
37 lines (29 loc) · 1.52 KB
/
db_create.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
import logging
# noinspection PyUnresolvedReferences
from flask.ext.security.utils import encrypt_password
from app import app
from app import logs
from app import db, user_datastore
def db_create():
with app.app_context():
db.create_all()
db.session.commit()
admin_role = user_datastore.find_or_create_role(name="admin", description="Administrator")
user_role = user_datastore.find_or_create_role(name="user", description="User")
admin = user_datastore.create_user(email="[email protected]", password=encrypt_password("password"),
cc_login="roman.szalla")
user_datastore.add_role_to_user(admin, admin_role)
user_datastore.add_role_to_user(admin, user_role)
admin = user_datastore.create_user(email="[email protected]", password=encrypt_password("password"),
cc_login="maciej")
user_datastore.add_role_to_user(admin, admin_role)
user_datastore.add_role_to_user(admin, user_role)
admin = user_datastore.create_user(email="[email protected]", password=encrypt_password("password"),
cc_login="piotr")
user_datastore.add_role_to_user(admin, admin_role)
user_datastore.add_role_to_user(admin, user_role)
db.session.commit()
if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
logging.getLogger().addHandler(logs.get_console_handler())
db_create()