def register(request): if request.is_ajax(): user_info = json.loads(request.body.decode('utf-8')) msg = register_info_logic(**user_info) return HttpResponse(get_ajax_msg(msg, '恭喜您,账号已成功注册')) elif request.method == 'GET': return render_to_response("register.html")
def edit_case(request): if request.session.get('login_status'): if request.is_ajax(): testcase_lists = json.loads(request.body.decode('utf-8')) msg = case_info_logic(**testcase_lists, type=False) return HttpResponse(get_ajax_msg(msg, '用例更新成功')) elif request.method == 'POST': id = request.POST.get('id') account = request.POST.get('account') test_info = TestCaseInfo.objects.get_case_by_id(id) request = eval(test_info[0].request) manage_info = { 'account': account, 'info': test_info[0], 'request': request['test'], 'project': ProjectInfo.objects.all().values('pro_name').order_by( '-create_time') } return render_to_response('edit_case.html', manage_info) else: return HttpResponseRedirect("/api/login/")
def add_project(request): if request.is_ajax(): project_info = json.loads(request.body.decode('utf-8')) msg = project_info_logic(**project_info) return HttpResponse(get_ajax_msg(msg, '项目添加成功')) elif request.method == 'GET': return render_to_response('add_project.html')
def project_list(request, id): if request.is_ajax(): project_info = json.loads(request.body.decode('utf-8')) if 'status' in project_info.keys(): msg = change_status(ProjectInfo, **project_info) return HttpResponse(get_ajax_msg(msg, '项目状态已更改!')) else: msg = project_info_logic(type=False, **project_info) return HttpResponse(get_ajax_msg(msg, '项目信息更新成功')) else: filter_query = set_filter_session(request) pro_list = get_pager_info(ProjectInfo, filter_query, '/api/project_list/', id) return render_to_response('project_list.html', { 'project': pro_list[1], 'page_list': pro_list[0], 'info': filter_query })
def add_case(request): project = ProjectInfo.objects.all().values('pro_name').order_by( '-create_time') if request.is_ajax(): testcase_lists = json.loads(request.body.decode('utf-8')) msg = case_info_logic(**testcase_lists) return HttpResponse(get_ajax_msg(msg, '用例添加成功')) elif request.method == 'GET': return render_to_response('add_case.html', {'project': project})
def module_list(request, id): if request.is_ajax(): module_info = json.loads(request.body.decode('utf-8')) if 'status' in module_info.keys(): msg = change_status(ModuleInfo, **module_info) return HttpResponse(get_ajax_msg(msg, '模块状态已更改!')) else: msg = module_info_logic(type=False, **module_info) return HttpResponse(get_ajax_msg(msg, '模块信息更新成功')) else: filter_query = set_filter_session(request) module_list = get_pager_info(ModuleInfo, filter_query, '/api/module_list/', id) return render_to_response( 'module_list.html', { 'module': module_list[1], 'page_list': module_list[0], 'info': filter_query })
def add_module(request): if request.is_ajax(): module_info = json.loads(request.body.decode('utf-8')) msg = module_info_logic(**module_info) return HttpResponse(get_ajax_msg(msg, '模块添加成功')) elif request.method == 'GET': return render_to_response( 'add_module.html', {'data': ProjectInfo.objects.all().values('pro_name')})
def add_project(request): if request.session.get('login_status'): if request.is_ajax(): project_info = json.loads(request.body.decode('utf-8')) msg = project_info_logic(**project_info) return HttpResponse(get_ajax_msg(msg, '项目添加成功')) elif request.method == 'GET': manage_info = {'account': request.session["now_account"]} return render_to_response('add_project.html', manage_info) else: return HttpResponseRedirect("/api/login/")
def edit_config(request, id): if request.is_ajax(): testconfig_lists = json.loads(request.body.decode('utf-8')) msg = config_info_logic(type=False, **testconfig_lists) return HttpResponse(get_ajax_msg(msg, '配置更新成功')) elif request.method == 'GET': test_info = TestCaseInfo.objects.get_case_by_id(int(id)) request = eval(test_info[0].request) return render_to_response('edit_config.html', { 'info': test_info[0], 'request': request['config'] })
def add_module(request): if request.session.get('login_status'): if request.is_ajax(): module_info = json.loads(request.body.decode('utf-8')) msg = module_info_logic(**module_info) return HttpResponse(get_ajax_msg(msg, '模块添加成功')) elif request.method == 'GET': manage_info = { 'account': request.session["now_account"], 'data': ProjectInfo.objects.all().values('pro_name') } return render_to_response('add_module.html', manage_info) else: return HttpResponseRedirect("/api/login/")
def add_config(request): if request.session.get('login_status'): if request.is_ajax(): testconfig_lists = json.loads(request.body.decode('utf-8')) msg = config_info_logic(**testconfig_lists) return HttpResponse(get_ajax_msg(msg, '配置添加成功')) elif request.method == 'GET': manage_info = { 'account': request.session["now_account"], 'project': ProjectInfo.objects.all().values('pro_name').order_by('-create_time') } return render_to_response('add_config.html', manage_info) else: return HttpResponse('session invalid')
def test_list(request, id): if request.is_ajax(): test_info = json.loads(request.body.decode('utf-8')) if 'status' in test_info.keys(): msg = change_status(TestCaseInfo, **test_info) return HttpResponse(get_ajax_msg(msg, '用例或配置状态已更改!')) else: filter_query = set_filter_session(request) test_list = get_pager_info(TestCaseInfo, filter_query, '/api/test_list/', id) return render_to_response('test_list.html', { 'test': test_list[1], 'page_list': test_list[0], 'info': filter_query })
def edit_config(request, id): if request.session.get('login_status'): if request.is_ajax(): testconfig_lists = json.loads(request.body.decode('utf-8')) msg = config_info_logic(type=False, **testconfig_lists) return HttpResponse(get_ajax_msg(msg, '配置更新成功')) elif request.method == 'POST': id = request.POST.get('id') account = request.POST.get('account') test_info = TestCaseInfo.objects.get_case_by_id(id) request = eval(test_info[0].request) manage_info = { 'account': account, 'info': test_info[0], 'request': request['config'] } return render_to_response('edit_config.html', manage_info) else: return HttpResponseRedirect("/api/login/")
def test_list(request, id): if request.session.get('login_status'): if request.is_ajax(): test_info = json.loads(request.body.decode('utf-8')) if 'status' in test_info.keys(): msg = change_status(TestCaseInfo, **test_info) return HttpResponse(get_ajax_msg(msg, '用例或配置状态已更改!')) else: filter_query = set_filter_session(request) test_list = get_pager_info(TestCaseInfo, filter_query, '/api/test_list/', id) manage_info = { 'account': request.session["now_account"], 'test': test_list[1], 'page_list': test_list[0], 'info': filter_query } return render_to_response('test_list.html', manage_info) else: return HttpResponseRedirect("/api/login/")