Skip to content

Commit 26c630e

Browse files
committed
feat: 增加 add_super 脚本的成功提示
1 parent 7a60654 commit 26c630e

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

add_super.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,30 @@
22
:copyright: © 2019 by the Lin team.
33
:license: MIT, see LICENSE for more details.
44
"""
5+
from sqlalchemy.exc import IntegrityError
56

67
from app.app import create_app
78
from lin.db import db
89
from lin.core import User
910

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-
# admin 2 的时候为超级管理员,普通用户为 1
19-
user.admin = 2
20-
db.session.add(user)
11+
12+
def main():
13+
app = create_app()
14+
with app.app_context():
15+
with db.auto_commit():
16+
# 创建一个超级管理员
17+
user = User()
18+
user.nickname = 'super'
19+
user.password = '123456'
20+
user.email = '1234995678@qq.com'
21+
# admin 2 的时候为超级管理员,普通用户为 1
22+
user.admin = 2
23+
db.session.add(user)
24+
25+
26+
if __name__ == '__main__':
27+
try:
28+
main()
29+
print("新增超级管理员成功")
30+
except Exception as e:
31+
raise e

app/config/setting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
# 插件模块暂时没有开启,以下配置可忽略
1919
# plugin config写在字典里面
2020
PLUGIN_PATH = {
21-
'oss': {'path': 'app.plugins.oss', 'enable': True, 'version': '0.0.1', 'access_key_id': 'not complete', 'access_key_secret': 'not complete', 'endpoint': 'http://oss-cn-shenzhen.aliyuncs.com', 'bucket_name': 'not complete', 'upload_folder': 'app', 'allowed_extensions': ['jpg', 'gif', 'png', 'bmp']},
22-
'poem': {'path': 'app.plugins.poem', 'enable': True, 'version': '0.0.1', 'limit': 20}
21+
'poem': {'path': 'app.plugins.poem', 'enable': True, 'version': '0.0.1', 'limit': 20},
22+
'oss': {'path': 'app.plugins.oss', 'enable': True, 'version': '0.0.1', 'access_key_id': 'not complete', 'access_key_secret': 'not complete', 'endpoint': 'http://oss-cn-shenzhen.aliyuncs.com', 'bucket_name': 'not complete', 'upload_folder': 'app', 'allowed_extensions': ['jpg', 'gif', 'png', 'bmp']}
2323
}

0 commit comments

Comments
 (0)