Example #1
0
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'))
Example #2
0
def role_list():
    query = common_list(Role)
    return jsonify(common.trueReturn(query, 'success to list data'))
Example #3
0
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'))
Example #4
0
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'))
Example #5
0
def current_user_permission():
    return jsonify(
        common.trueReturn(dict(current_identity),
                          'success to get current user info'))
Example #6
0
def user_list():
    query = common_list(
        User, filter_select=User.id != current_identity['id'])  # 不显示自己的信息
    return jsonify(common.trueReturn(query, 'success to list data'))
Example #7
0
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'))
Example #8
0
def group_list():
    query = common_list(Group)
    return jsonify(common.trueReturn(query, 'success to list data'))