```
def productionplans_create(request):
if request.user.is_anonymous():
return render(request,"home_view.html",{"message":"未登录!"})
elif not request.user.is_superuser:
if not (request.user.employee.department == DepartmentStatus.TECHNICAL_DEPARMENT
or request.user.employee.department == DepartmentStatus.MANAGER_DEPARMENT
or request.user.employee.department == DepartmentStatus.PRODUCTION_VICEPRESIDENT):
return render(request,"home_view.html",{"message":"没有权限查看该模块内容!"})
form = ProductionPlanForm(request.POST or None)
if request.method == 'POST':
if form.is_valid():
time = str(datetime.datetime.now())
title = "JTL_I_" + str(time[0:4]) + str(time[5:7]) + str(time[8:10]) + str(time[11:13]) + str(time[14:16]) + str(time[17:19])
request.session['title'] = title
request.session['department'] = form.cleaned_data.get("department").department_name
#print(request.session['department'])
request.session['ingredient_plan_id'] = form.cleaned_data.get("ingredient_plan").id
request.session['input_weight_plan'] = form.cleaned_data.get("input_weight_plan")
request.session['ingredient_weight_plan'] = form.cleaned_data.get("ingredient_weight_plan")
request.session['start_date'] = str(form.cleaned_data.get("start_date"))
request.session['complete_date'] = str(form.cleaned_data.get("complete_date"))
request.session['is_publish'] = form.cleaned_data.get("is_publish")
return redirect(reverse("productionplans:createplan"))
context = {
"productionplan_form":form,
}
return render(request, "productionplan_create.html", context)
```