def FChange_Item(request): context = {"url":blobstore.create_upload_url('/admin/item_change')} goodID = None data = None done = False img1 = None img2 = None if request.method == 'POST': id_form = Goods_ID_Form(request.POST) form=Goods_Form(request.POST) if id_form.is_valid() and form.is_valid(): data= form.cleaned_data goodID = id_form.cleaned_data['goods_id'] if "image1" in request.FILES: img1=get_uploads2(request,"image1") if "image2" in request.FILES: img2=get_uploads2(request,"image2") done = Product_Change(goodID, data['type_id'], data['goods_name'], data['goods_cost'], data['introduction1'], data['Ingredient'], data['Manual'], data['enable'], data['sp'], data['new'], img1, img2) context['name'] = data['goods_name'] context['type'] = data['type_id'] context['goodID'] = goodID context['success'] = done return HttpResponse(json.dumps(context), content_type="application/json")
def addNewItem(request): intro=[] img1=None img2=None user_id = None done=None type_id=None option=None goods_name=None goods_cost=None if request.method == 'POST': context = {} context['url'] = blobstore.create_upload_url('/admin/add-new-item') form = Goods_Form(request.POST) if "user_data" in request.COOKIES: data=request.COOKIES['user_data'].split(";") if not (data[1]==str(True)): return HttpResponseNotFound('<h1>Page not found</h1>') if form.is_valid(): type_id = form.cleaned_data['type_id'] goods_name = form.cleaned_data['goods_name'] goods_cost = form.cleaned_data['goods_cost'] intro.append(form.cleaned_data['introduction1']) ingredient = form.cleaned_data['Ingredient'] manual = form.cleaned_data['Manual'] enable = not form.cleaned_data['enable'] sp=form.cleaned_data['sp'] new=form.cleaned_data['new'] if "image1" in request.FILES: img1=get_uploads2(request,"image1") if "image2" in request.FILES: img2=get_uploads2(request,"image2") done=Product_Put(goods_name, goods_cost, intro, type_id, enable, sp, new, manual, ingredient, img1, img2) context['success'] = done context['name'] = goods_name context['cost'] = goods_cost return HttpResponse(json.dumps(context), mimetype='application/javascript') return HttpResponseNotFound('<h1>Page not found</h1>')