修复用户管理bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from flask import Blueprint, render_template, request, jsonify
|
from flask import Blueprint, render_template, request, jsonify
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from applications.common.curd import model_to_dicts, enable_status, disable_status, get_one_by_id
|
from applications.common.curd import model_to_dicts, enable_status, disable_status, get_one_by_id
|
||||||
from applications.common.utils.http import table_api, success_api, fail_api
|
from applications.common.utils.http import table_api, success_api, fail_api
|
||||||
from applications.common.utils.rights import authorize
|
from applications.common.utils.rights import authorize
|
||||||
@@ -7,7 +8,6 @@ from applications.common.utils.validate import str_escape
|
|||||||
from applications.extensions import db
|
from applications.extensions import db
|
||||||
from applications.models import Role, Power, User
|
from applications.models import Role, Power, User
|
||||||
from applications.schemas import RoleOutSchema, PowerOutSchema2
|
from applications.schemas import RoleOutSchema, PowerOutSchema2
|
||||||
|
|
||||||
admin_role = Blueprint('adminRole', __name__, url_prefix='/admin/role')
|
admin_role = Blueprint('adminRole', __name__, url_prefix='/admin/role')
|
||||||
|
|
||||||
|
|
||||||
@@ -183,7 +183,6 @@ def remove(id):
|
|||||||
# 批量删除
|
# 批量删除
|
||||||
@admin_role.delete('/batchRemove')
|
@admin_role.delete('/batchRemove')
|
||||||
@authorize("admin:role:remove", log=True)
|
@authorize("admin:role:remove", log=True)
|
||||||
@login_required
|
|
||||||
def batch_remove():
|
def batch_remove():
|
||||||
ids = request.form.getlist('ids[]')
|
ids = request.form.getlist('ids[]')
|
||||||
for id in ids:
|
for id in ids:
|
||||||
|
|||||||
@@ -40,19 +40,26 @@ def data():
|
|||||||
filters.append(User.realname == dept_id)
|
filters.append(User.realname == dept_id)
|
||||||
|
|
||||||
# print(*filters)
|
# print(*filters)
|
||||||
data, count = db.session.query(
|
query = db.session.query(
|
||||||
User.id,
|
User,
|
||||||
User.username,
|
Dept
|
||||||
User.realname,
|
).filter(*filters).filter(User.dept_id == Dept.id).layui_paginate()
|
||||||
User.enable,
|
|
||||||
User.create_at,
|
return table_api(
|
||||||
User.update_at,
|
data=[{
|
||||||
Dept.dept_name
|
'id': user.id,
|
||||||
).filter(*filters).filter(User.dept_id == Dept.id).layui_paginate_db_json()
|
'username': user.username,
|
||||||
return table_api(data=data, count=count)
|
'realname': user.realname,
|
||||||
|
'enable': user.enable,
|
||||||
|
'create_at': user.create_at,
|
||||||
|
'update_at': user.update_at,
|
||||||
|
'dept_name': dept.dept_name
|
||||||
|
} for user, dept in query],
|
||||||
|
count=query.total)
|
||||||
|
|
||||||
|
# 用户增加
|
||||||
|
|
||||||
|
|
||||||
# 用户增加
|
|
||||||
@admin_user.get('/add')
|
@admin_user.get('/add')
|
||||||
@authorize("admin:user:add", log=True)
|
@authorize("admin:user:add", log=True)
|
||||||
def add():
|
def add():
|
||||||
|
|||||||
Reference in New Issue
Block a user