示例#1
0
文件: views.py 项目: suall936/test
def stock_manual_adjust(request):
  # if request.method == 'GET':
  #   form = manualAdjustStockForm()
  #   return render_to_response('stock_manual_adjust_form.html', {'form':form},context_instance=RequestContext(request))
  # elif request.method == 'POST':
  #   # return HttpResponse('process form')
  #   return HttpResponse('<script type="text/javascript">$("#stock_window").jqxWindow("close");</script>')
  #   # return HttpResponse('<div>console.log("posted");</div>')
  # else:
  #   return Http404
  if request.method == 'POST':
    sn = request.POST.get('sn')
    form = manualAdjustStockForm(request.POST)
    s = Stock.objects.get(sn=sn)
    if form.is_valid():
      # sn = request.POST.get('sn')
      # s = Stock.objects.get(sn=sn)
      s.manual_adjust(form.cleaned_data)
      return HttpResponse(JSON_response_data([s,], ''))
      # return render_to_response('stock_manual_adjust_succ.html', {'module':module, 'sn':sn},context_instance=RequestContext(request))
    else:
      print type(form.errors.as_json())
      print form.errors.as_json()
      return HttpResponse(JSON_response_data([s,], form.errors.as_json()))
  else:
    sn = request.GET.get('sn')
    form = manualAdjustStockForm()
  return render_to_response('stock_manual_adjust_form.html', {'form':form, 'sn':sn}, context_instance=RequestContext(request))
示例#2
0
文件: views.py 项目: suall936/ozbuy
def stock_manual_adjust(request):
  if request.method == 'POST':
    sn = request.POST.get('sn')
    form = manualAdjustStockForm(request.POST)
    s = Stock.objects.get(sn=sn)
    if form.is_valid():
      s.manual_adjust(form.cleaned_data)
      return HttpResponse(JSON_response_data([s,], ''))
    else:
      print type(form.errors.as_json())
      print form.errors.as_json()
      return HttpResponse(JSON_response_data([s,], form.errors.as_json()))
  else:
    sn = request.GET.get('sn')
    form = manualAdjustStockForm()
  return render_to_response('stock_manual_adjust_form.html', {'form':form, 'sn':sn}, context_instance=RequestContext(request))