def add_config(request):
    project = ProjectInfo.objects.all().values('pro_name').order_by(
        '-create_time')

    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':
        return render_to_response('add_config.html', {'project': project})
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_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')
Exemple #4
0
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/")