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')
Exemple #2
0
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 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
        })