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})
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})
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})
def evaluation(request, *args, **kwargs): if not request.session.get('is_login', False) or request.session['user_type'] != 'finance': return redirect("/index") error_msg, page, page_list, projects_dict, project_id = initialize(args, request) eva_info = utils.get_eva_info(project_id) if request.method == 'GET': return render(request, 'financeoff_evaluation.html', {"projects_dict": projects_dict, "project_id":project_id, "eva_info": eva_info, 'page_list':page_list, 'page':page, 'error_msg':error_msg})
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 })
def evaluation(request, *args, **kwargs): if not request.session.get( 'is_login', False) or request.session['user_type'] != 'information': return redirect("/index") error_msg, page, page_list, projects_dict, project_id = initialize( args, request) eva_info = utils.get_eva_info(project_id) if request.method == 'GET': return render( request, 'Administrators_evaluation.html', { "projects_dict": projects_dict, "project_id": project_id, "eva_info": eva_info, 'page_list': page_list, 'page': page, 'error_msg': error_msg }) if request.method == 'POST': for num in [1, 2, 3, 4, 5]: if request.POST.get("pass" + str(num)): with open("database/evaluation.pk", 'rb') as f: eva = pickle.load(f) eva[project_id][num - 1] = 2 with open("database/evaluation.pk", 'wb') as f: f.write(pickle.dumps(eva)) return redirect("/info/evaluation&id=%d&page=%d" % (project_id, page)) if request.POST.get("complete"): with open("database/projects.pk", 'rb') as f: _projects_dict = pickle.load(f) if request.POST.get("complete") == "结束项目": status, maintain = "已结题", 0 else: status, maintain = "使用中", int( _projects_dict[project_id]["budget"] * 0.1) _projects_dict[project_id]['status'] = status _projects_dict[project_id]['maintain'] = maintain _projects_dict[project_id]["end"] = time.strftime( '%Y-%m-%d', time.localtime(time.time())) with open("database/projects.pk", 'wb') as f: f.write(pickle.dumps(_projects_dict)) return redirect("/info/evaluation&id=%d&page=%d" % (project_id, page)) return render( request, 'Administrators_evaluation.html', { "projects_dict": projects_dict, "project_id": project_id, "eva_info": eva_info, 'page_list': page_list, 'page': page, 'error_msg': error_msg })
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})
def evaluation(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) eva_info = utils.get_eva_info(project_id) if request.method == 'GET': return render( request, 'admin_evaluation.html', { "projects_dict": projects_dict, "project_id": project_id, "eva_info": eva_info, 'page_list': page_list, 'page': page, 'error_msg': error_msg }) if request.method == 'POST': for num in [1, 2, 3, 4, 5]: if request.POST.get("pass" + str(num)): print num with open("database/evaluation.pk", 'rb') as f: eva = pickle.load(f) eva[project_id][num - 1] = 2 with open("database/evaluation.pk", 'wb') as f: f.write(pickle.dumps(eva)) if eva[project_id][4] == 2: with open("database/projects.pk", 'rb') as f: _projects_dict = pickle.load(f) _projects_dict[project_id]['status'] = "已结题" with open("database/projects.pk", 'wb') as f: f.write(pickle.dumps(_projects_dict)) return redirect("/admin/evaluation&id=%d&page=%d" % (project_id, page)) return render( request, 'admin_evaluation.html', { "projects_dict": projects_dict, "project_id": project_id, "eva_info": eva_info, 'page_list': page_list, 'page': page, 'error_msg': error_msg })