def AddChuZi(request, type): if request.method == "POST": form = CaseForm(request.POST) if form.is_valid(): osc = form.save(commit=False) osc.creater = request.user index = int(type) - 1 osc.documentunit = CONFIG['left_panel'][index]['index'] glvar = GlobalVar.objects.filter(id=1)[0] osc.informnumber = (CONFIG['documentnum'][type] % (time.strftime('%Y'), glvar.casecount3)) osc.documenttype = '3' osc.save() glvar.casecount3 += 1 glvar.save() return HttpResponseRedirect(reverse('ListChuZi', args=(type,))) else: form = CaseForm() kwvars = { 'form':form, 'request':request, 'type':type, 'config':CONFIG, } return render_to_response('autonumber/chuzi_add.html',kwvars,RequestContext(request))
def EditGaoZi(request, type, ID): iGaozi = Case.objects.get(id=ID) if request.method == "POST": form = CaseForm(request.POST,instance=iGaozi) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('ListGaoZi', args=(type,))) else: form = CaseForm(instance=iGaozi) kwvars = { 'ID':ID, 'form':form, 'request':request, 'type':type, 'config':CONFIG, } return render_to_response('autonumber/gaozi_edit.html',kwvars,RequestContext(request))