Exemple #1
0
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_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 edit_case(request, id):
    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 == 'GET':
        test_info = TestCaseInfo.objects.get_case_by_id(int(id))
        request = eval(test_info[0].request)
        return render_to_response('edit_case.html', {
            'info': test_info[0],
            'request': request['test']
        })
def add_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)
            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_case.html', manage_info)
    else:
        return HttpResponse('session invalid')