Exemple #1
0
def query():
    file_desc_list = File().get_desc_list()
    if not file_desc_list:
        return Response(my_json_res(CODE.ERROR, {}, ''),
                        content_type='application/json')
    return Response(my_json_res(CODE.SUCCESS, file_desc_list, ''),
                    content_type='application/json')
Exemple #2
0
def change_pid():
    data = {
        'sub': request.form.get('sub'),
        'pid': request.form.get('pid'),
    }
    user = User().load(data)
    res = my_json_res(CODE.SUCCESS, {}, '更改权限成功')
    if not user.change_power():
        res = my_json_res(CODE.ERROR, {}, '更改权限失败')
    return Response(res, content_type='application/json')
Exemple #3
0
def index():
    if request.method == 'GET':
        return render_template('login.html')
    user = User().load({
        'sub': request.form.get('sub'),
        'pwd': request.form.get('pwd')
    })
    if not user.login():
        res = my_json_res(CODE.ERROR, {}, '用户名或密码错误!')
    else:
        session['sub'] = user.sub
        res = my_json_res(CODE.SUCCESS, {}, '登录成功!')
    return Response(res, content_type='application/json')
Exemple #4
0
def profile():
    data = {
        'sub': session['sub'],
        'phone': request.form.get('phone'),
        'email': request.form.get('email'),
        'intro': request.form.get('intro'),
    }
    userModel = User().load(data)
    res, msg = userModel.check_arrt()
    if not res:
        res = my_json_res(CODE.ERROR, {}, msg)
    else:
        userModel.update_profile()
        res = my_json_res(CODE.SUCCESS, {}, '更改个人信息成功')
    return Response(res, content_type='application/json')
Exemple #5
0
def update_profile():
    data = {
        'sub': request.form.get('sub'),
        'phone': request.form.get('phone'),
        'email': request.form.get('email'),
    }
    user = User().load(data)
    res, msg = user.check_arrt()
    if not res:
        return Response(my_json_res(CODE.ERROR, {}, msg),
                        content_type='application/json')
    if not user.update_profile():
        return Response(my_json_res(CODE.ERROR, {}, '更改信息失败'),
                        content_type='application/json')
    return Response(my_json_res(CODE.SUCCESS, {}, '更改信息成功'),
                    content_type='application/json')
Exemple #6
0
def pwd():
    data = {
        'sub': session['sub'],
        'pwd': request.form.get('old_pwd'),
    }
    userModel = User().load(data)
    new_pwd = request.form.get('new_pwd')
    re_pwd = request.form.get('re_pwd')
    if re_pwd != new_pwd:
        res = my_json_res(CODE.ERROR, {}, '两次密码输入不一致')
        return Response(res, content_type='application/json')
    if not userModel.reset_pwd(new_pwd):
        res = my_json_res(CODE.ERROR, {}, '输入的原密码不正确')
    else:
        del session['sub']
        res = my_json_res(CODE.SUCCESS, {}, '更新密码成功,请重新登录')
    return Response(res, content_type='application/json')
Exemple #7
0
def query():
    params = request.args
    page = int(params.get('page')) if params.get('page') else 1
    if request.method == 'POST':
        params = request.form
        url = ('/admin/log/query?type=' + params.get('type') +
               '&content=' + params.get('content') +
               '&page=' + str(page))
        return Response(my_json_res(CODE.SUCCESS, {'url': url}, ''), content_type='application/json')
    data = {
        params.get('type'): params.get('content')
    }
    user = User().get_by_sub(session['sub'])
    logList = Log().query_list(data, page)
    count = Log().query_list_num(data)
    return render_template('admin/log.html', title='请求日志', user=user,
                           logList=logList, count=count, page=page,
                           type=params.get('type'), content=params.get('content'))