def index(): params = request.args page = int(params.get('page')) if params.get('page') else 1 user = User().get_by_sub(session['sub']) userList = User().get_list({}, page) count = User().get_list_num({}) return render_template('admin/user.html', title='用户管理', user=user, userList=userList, count=count, page=page)
def index(): params = request.args page = int(params.get('page')) if params.get('page') else 1 user = User().get_by_sub(session['sub']) logList = Log().query_list({}, page) count = Log().query_list_num({}) return render_template('admin/log.html', title='请求日志', user=user, logList=logList, count=count, page=page)
def test_create(self): sub = 'uinttest' # uinttest/lilijie res = User().create(sub) if not res: print('create user ' + sub + ' error') self.assertEqual(res, True) return print('create user ' + sub + ' success') self.assertEqual(res, res)
def test_del(self): sub = 'unit' # uinttest/unit res = User().load({'sub': sub}).delete() if not res: print('delete user ' + sub + ' error') self.assertEqual(res, True) return print('delete user ' + sub + ' success') self.assertEqual(res, res)
def test_login(self): sub = 'lilijie' pwd = '123456' # 123456/12345 res = User().load({'sub': sub, 'pwd': pwd}).login() if not res: print('login user ' + sub + ' error') self.assertEqual(res, True) return print('login user ' + sub + ' success') self.assertEqual(res, res)
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')
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/user/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']) userList = User().get_list(data, page) count = User().get_list_num(data) return render_template('admin/user.html', title='用户管理', user=user, userList=userList, count=count, page=page, type=params.get('type'), content=params.get('content'))
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')
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')
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')
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')
def auth_cb(): code = request.args.get('code') or '' if code == '': msg = request.args.get('error') or 'no code' return render_template('error.html', msg=msg) res, content = auth_req(code) if res.getcode() != CODE.SUCCESS: return content.get('error') data = auth_decode(content) user = User() if not user.get_by_sub(data.get('sub')): user.create(session['sub']) session['sub'] = user.sub session['pid'] = user.pid return redirect(url_for('home.index'))
def index(): userModel = User().get_by_sub(session['sub']) return render_template('user/home.html', title='个人主页', user=userModel)
def check_power(): user = User().get_by_sub(session['sub']) if user.pid is not power.ADMIN: return render_template('user/no-power.html', title='权限不足', user=user)
def index(): user = User().load({'sub': session['sub']}) if user.get_ws_sid(): return render_template('user/file-refresh.html', title="文件传输", user=user) return render_template('user/file.html', title="文件传输", user=user)
def index(): user = User().get_by_sub(session['sub']) return render_template('admin/monitor.html', title='传输监控', user=user)