def role_edit(): def edit_model(form, model): setattr(model, "permissions", [ Permission.query.filter(Permission.id == permission).first() for permission in form['permissions'] ]) query = common_edit(Role, edit_model=edit_model) if query: return jsonify(common.trueReturn('', 'success to alert data')) else: return jsonify(common.falseReturn('', 'fail to alert data'))
def role_list(): query = common_list(Role) return jsonify(common.trueReturn(query, 'success to list data'))
def role_delete(): query = common_delete(Role) if query: return jsonify(common.trueReturn('', 'success to delete data')) else: return jsonify(common.falseReturn('', 'fail to delete data'))
def current_user(): query = User.query.filter(User.id == current_identity['id']).all() return jsonify( common.trueReturn( quert2dict(query)[0], 'success to get current user info'))
def current_user_permission(): return jsonify( common.trueReturn(dict(current_identity), 'success to get current user info'))
def user_list(): query = common_list( User, filter_select=User.id != current_identity['id']) # 不显示自己的信息 return jsonify(common.trueReturn(query, 'success to list data'))
def group_delete(): query = common_delete(Group) if query: return jsonify(common.trueReturn('', 'success to delete data')) else: return jsonify(common.falseReturn('', 'fail to delete data'))
def group_list(): query = common_list(Group) return jsonify(common.trueReturn(query, 'success to list data'))