Skip to content

Commit 35eedc3

Browse files
colorful3pedro
authored andcommitted
fix: 增加配置项,屏蔽sql alchemy的FSADeprecationWarning (#37)
* fix: 修复软删除带来的用户查询个数与结果不一致 * fix: 修复软删除带来的查询问题 * refactor: 添加DAO层,分离视图函数中数据库相关的业务逻辑 * fix: 修改模块注释为团队信息 * feat:支持插件模板自动生成 * refactor: 为了方便学习源码,移除掉DAO层 * fix: 修改模型层的实例方法为类方法 * doc: 更新README.md * feat: 添加插件初始化脚本 * refactor: 将plugin_init脚本移至根目录下 * feat: 插件初始化支持自动检测依赖冲突问题 * fix: 修改oss插件的依赖版本 * refactor: 将项目中的所有super字段改为admin字段 * feat: refresh接口增加refresh_token的刷新 * fix: 修改requirements.txt 中lin-cms 的版本号为最新 * fix: 增加配置项目,屏蔽sql alchemy的FSADeprecationWarning * feat: 增加 add_super 脚本的成功提示
1 parent 61a29f6 commit 35eedc3

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

add_super.py

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

app/config/setting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# 令牌配置
1313
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
1414

15+
# 屏蔽 sql alchemy 的 FSADeprecationWarning
16+
SQLALCHEMY_TRACK_MODIFICATIONS = False
17+
1518
# 插件模块暂时没有开启,以下配置可忽略
1619
# plugin config写在字典里面
1720
PLUGIN_PATH = {

0 commit comments

Comments
 (0)