Skip to content

Commit 0d6d39b

Browse files
author
PedroGao
committed
feat: 增加新建管理员脚本
1 parent bab6400 commit 0d6d39b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

add_super.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
:copyright: © 2019 by the Lin team.
3+
:license: MIT, see LICENSE for more details.
4+
"""
5+
6+
from app.app import create_app
7+
from lin.db import db
8+
from lin.core import User
9+
10+
app = create_app()
11+
with app.app_context():
12+
with db.auto_commit():
13+
# 创建一个超级管理员
14+
user = User()
15+
user.nickname = 'super'
16+
user.password = '123456'
17+
user.email = '1234995678@qq.com'
18+
# super为 2 的时候为超级管理员,普通用户为 1
19+
user.super = 2
20+
db.session.add(user)

fake.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,10 @@
66
from app.app import create_app
77
from app.models.book import Book
88
from lin.db import db
9-
from lin.core import User
109

1110
app = create_app()
1211
with app.app_context():
1312
with db.auto_commit():
14-
# 创建一个超级管理员
15-
user = User()
16-
user.nickname = 'super'
17-
user.password = '123456'
18-
user.email = '12345678@qq.com'
19-
user.super = 2
20-
db.session.add(user)
2113
# 添加书籍
2214
book1 = Book()
2315
book1.title = '深入理解计算机系统'

0 commit comments

Comments
 (0)