Esempio n. 1
0
def stop(request, *args, **kwargs):
    if not request.session.get('is_login', False) or request.session['user_type'] != 'accounts':
        return redirect("/index")
    error_msg = ''
    project_id = utils.get_id(args)
    page = utils.get_page(args)
    if request.method == "GET":
        for id, item in utils.get_projects(request.session['account']):
            if id == project_id:
                project_info = item
        return render(request, "user_projectstop.html", {"project_info":project_info, "project_id":project_id, "page":page , "error_msg": error_msg})
    if request.method == "POST":
        data = {
            "name": request.POST.get("name"),
            "leader": request.POST.get("leader"),
            "teammates": request.POST.get("teammates"),
            "start": request.POST.get("start"),
            "cost": request.POST.get("cost"),
        }
        if int(data['cost']) < 0:
            data['cost'] = '0'
        if not error_msg:
            error_msg = "项目申停成功"
            _projects_dict = utils.get_projects(request.session['account'])
            page_list = utils.get_pages(page, _projects_dict)
            projects_dict, page, project_id = utils.adjust_info(_projects_dict, page, project_id)
            steps = utils.get_steps(project_id)
            step_path = utils.steps_path(utils.get_eva_info(project_id, top=True))
            return render(request, "user_projectprocess.html",
                          {"projects_dict": projects_dict, "project_id": project_id,
                           "steps": steps, "step_path": step_path, "page_list": page_list, "page": page,
                           'error_msg': error_msg})
Esempio n. 2
0
def evaluation(request, *args, **kwargs):
    if not request.session.get('is_login', False) or request.session['user_type'] != 'accounts':
        return redirect("/index")
    error_msg, page, page_list, projects_dict, project_id = initialize(args, request, True)
    if not project_id:
        return redirect('/account/summary')
    eva_info = utils.get_eva_info(project_id)
    steps = utils.get_steps(project_id)
    step_path = utils.steps_path(utils.get_eva_info(project_id, top=True))
    if request.method == 'GET':
        return render(request, 'user_evaluation.html',
                {"projects_dict": projects_dict, "project_id":project_id,
                 "eva_info": eva_info,
                 "steps": steps, "step_path": step_path,
                "page_list":page_list, "page":page, "error_msg":error_msg})
    if request.method == 'POST':
        for num in [1,2,3,4,5]:
            if request.FILES.get("file"+str(num)):
                with open("database/evaluation.pk", 'rb') as f:
                    eva = pickle.load(f)
                eva[project_id][num-1] = 1
                with open("database/evaluation.pk", 'wb') as f:
                    f.write(pickle.dumps(eva))
                utils.save_file(project_id, request, "file"+str(num), "evaluation%d"%num)
                return redirect("/account/evaluation&id=%d&page=%d"%(project_id, page))
        error_msg = '未选择文件'
        return render(request, 'user_evaluation.html',
                      {"projects_dict": projects_dict, "project_id": project_id, "eva_info": eva_info,
                       'page_list': page_list, 'page': page, 'error_msg': error_msg})
Esempio n. 3
0
def process(request, *args, **kwargs):
    if not request.session.get('is_login', False) or request.session['user_type'] != 'accounts':
        return redirect("/index")
    error_msg, page, page_list, projects_dict, project_id = initialize(args, request, True)
    if not project_id:
        return redirect('/account/summary')
    steps = utils.get_steps(project_id)
    step_path = utils.steps_path(utils.get_eva_info(project_id, top=True))
    if request.method == 'GET':
        return render(request, 'user_projectprocess.html',{"projects_dict": projects_dict, "project_id":project_id,
                    "steps":steps, "step_path":step_path, "page_list":page_list, "page":page, 'error_msg':error_msg})
    if request.method == "POST":
        data = {
            "mission" : request.POST.get("mission"),
            "flow": request.POST.get("flow"),
            "start" : request.POST.get("start"),
            "process" : request.POST.get("process"),
            "teammates": request.POST.get("teammates").strip().split(',') if request.POST.get("teammates") else None,
            "end" : request.POST.get("end"),
        }
        data, error_msg = utils.check_error(data, pro_name=False, budget=False)
        if not data.get("mission", None):
            error_msg = '请输入正确的任务名称'
        elif data.get("flow", None) not in ['1','2','3','4','5']:
            error_msg = '请输入正确的任务所属流程'
        # utils.add_steps(project_id, data)
        # return redirect("/account/process&id=%d&page=%d"%(project_id, page))
        if not error_msg:
            utils.add_steps(project_id, data)
            return redirect("/account/process&id=%d&page=%d" % (project_id, page))
        else:
            return render(request, 'user_projectprocess.html',
                          {"projects_dict": projects_dict, "project_id": project_id,
                           "steps": steps, "step_path": step_path, "page_list": page_list, "page": page,
                           'error_msg': error_msg})
Esempio n. 4
0
def process(request, *args, **kwargs):
    if not request.session.get(
            'is_login', False) or request.session['user_type'] != 'admin':
        return redirect("/index")
    error_msg, page, page_list, projects_dict, project_id = initialize(
        args, request)
    steps = utils.get_steps(project_id)
    step_list = []
    for obj in steps:
        step_list.append(obj[1]['flow'])
    step_path = utils.steps_path(utils.get_eva_info(project_id, top=True))
    if request.method == 'GET':
        return render(
            request, 'admin_projectprocess.html', {
                "projects_dict": projects_dict,
                "project_id": project_id,
                "steps": steps,
                "step_path": step_path,
                "page_list": page_list,
                "page": page,
                'error_msg': error_msg
            })
    if request.method == "POST":
        data = {
            "mission": request.POST.get("mission"),
            "flow": request.POST.get("flow"),
            "leader": request.POST.get("leader"),
            "start": request.POST.get("start"),
            "process": request.POST.get("process"),
            "teammates": request.POST.get("teammates"),
            "end": request.POST.get("end"),
        }
        if not data.get("mission", None):
            error_msg = '请输入正确的任务名称'
        elif data.get("flow", None) not in ['1', '2', '3', '4', '5']:
            error_msg = '请输入正确的任务所属流程'
        # utils.add_steps(project_id, data)
        # return redirect("/account/process&id=%d&page=%d"%(project_id, page))
        if not error_msg:
            utils.add_steps(project_id, data)
            return redirect("/admin/process&id=%d&page=%d" %
                            (project_id, page))
        else:
            return render(
                request, 'admin_projcetprocess.html', {
                    "projects_dict": projects_dict,
                    "project_id": project_id,
                    "steps": steps,
                    "step_path": step_path,
                    "page_list": page_list,
                    "page": page,
                    'error_msg': error_msg
                })
Esempio n. 5
0
def finance(request, *args, **kwargs):
    if not request.session.get('is_login', False) or request.session['user_type'] != 'accounts':
        return redirect("/index")
    error_msg, page, page_list, projects_dict, project_id = initialize(args, request, True)
    if not project_id:
        return redirect('/account/summary')
    steps = utils.get_steps(project_id)
    step_path = utils.steps_path(utils.get_eva_info(project_id, top=True))
    if request.method == 'GET':
        with open("database/finance.pk", 'rb') as f:
            finance = pickle.load(f)
        records = enumerate(finance.get(project_id, []))
        return render(request, 'user_finance.html', {"records":records,"projects_dict": projects_dict, "project_id":project_id,
                     "steps": steps, "step_path": step_path,"page_list":page_list, "page":page, "error_msg":error_msg})