def new_arbitrate(request):
if request.user.is_anonymous():
return HttpResponseForbidden()
if request.user.department is not None:
if request.method == 'POST':
pdn_h = PdnForm(request.POST, prefix='pdn')
cert_h = CertForm(request.POST, prefix='cert')
arb_h = ArbitrateForm(request.POST, prefix='arbitrate')
if cert_h.is_valid() and arb_h.is_valid() and pdn_h.is_valid():
user = User.objects.create_user(pdn_h.cleaned_data.get('login'), None,
pdn_h.cleaned_data.get('password'))
user.first_name = pdn_h.cleaned_data.get('first_name')
user.last_name = pdn_h.cleaned_data.get('last_name') # ??????? ?????????????? ???? ???????? ???? ???.
c = cert_h.save()
request.user.department.arbitration_set.create(certificate=c, user=user,
activity_info=arb_h.cleaned_data.get('activity_info'),
dismissal_date=arb_h.cleaned_data.get('dismissal_date'),
office_location=arb_h.cleaned_data.get('office_location'),
organization_field=arb_h.cleaned_data.get('organization_field'),
name_register=arb_h.cleaned_data.get('name_register'),
)
# ? ????????? ?????? ?????? ?????? ??? ???????, ???? ??? ? ????? ???????.
# ???? ???-?? ???????? ??????? -- u r welcome
user.save()
return redirect(arbitrates)
else:
pdn_h = PdnForm(prefix='pdn')
cert_h = CertForm(prefix='cert')
arb_h = ArbitrateForm(prefix='arbitrate')
return render_to_response("createarbitrate.html", {"pdn": pdn_h,
"cert": cert_h, "arbitrate": arb_h, }, context_instance=RequestContext(request))
else:
return HttpResponseForbidden()
评论列表
文章目录