def syncwithebay(request,shop,key): registerAdminAction(request,"ebayexport",shop+"/"+key) info = ebay.getEbayInfo(request) item = Item.get_by_id(int(key),parent = getSupplier(shop)) if item: rslt = sync(info,item) return rslt
def item(request, shop, key): stories = getCategoriesInfo() item = Item.get_by_id(int(key), parent=getSupplier(shop)) if item: upload_url = '/admin/blobimage/' + shop + "/" + key + "/0/" upload_url1 = '/admin/blobimage/' + shop + "/" + key + "/1/" upload_url2 = '/admin/blobimage/' + shop + "/" + key + "/2/" upload_url3 = '/admin/blobimage/' + shop + "/" + key + "/3/" dict = { 'ITEM': item, 'STORIES': stories, 'BLOBURL': upload_url, 'BLOBURL1': upload_url1, 'BLOBURL2': upload_url2, 'BLOBURL3': upload_url3 } dict['STORIES'] = stories context = Context(dict) response = render_to_response("admin/itemfull.html", context, context_instance=RequestContext(request)) response['Cache-Control'] = 'no-cache, no-store, must-revalidate' return response else: return retailError(request, "item not found")
def fetchimage(request, shop, key, index="0"): item = Item.get_by_id(int(key), parent=getSupplier(shop)) picture = None idx = int(index) if item: image = item.getImage(idx) if image: if ("sc" in request.GET): if image.small: picture = image.small elif image.image: image.small = createsc(image.image) try: image.put() except RequestTooLargeError: pic = rescale(image.image, 600, 600) image.image = pic image.put() del pic picture = image.small else: picture = None else: picture = image.image else: picture = None else: picture = None if picture: return HttpResponse(picture, mimetype="image/jpeg") else: return HttpResponseRedirect('/static/res/picnotfound.jpg')
def blobimage(request, shop, key, index='0'): registerAdminAction(request, "blobimage", shop + "/" + key) #file = request.FILES['image'].read() #type = request.FILES['image'].content_type #image = request.FILES['image'].content_type_extra file = request.FILES['image'].read() picture = rescale(file, 600, 600) item = Item.get_by_id(int(key), parent=getSupplier(shop)) idx = int(index) if item: img = item.getImage(idx) if img: img.image = picture else: img = ImageData(image=picture, name=item.name, parent=item, idx=idx) img.url = "http://" + request.META[ 'HTTP_HOST'] + "/admin/fetchimage/" + shop + "/" + key + "/" + str( idx) img.small = createsc(picture) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok") else: return HttpResponse("fail")
def syncwithebay(request, shop, key): registerAdminAction(request, "ebayexport", shop + "/" + key) info = ebay.getEbayInfo(request) item = Item.get_by_id(int(key), parent=getSupplier(shop)) if item: rslt = sync(info, item) return rslt
def fetchimage(request,shop,key,index="0"): item = Item.get_by_id(int(key),parent = getSupplier(shop)) picture = None idx = int(index) if item: image = item.getImage(idx) if image: if ("sc" in request.GET): if image.small: picture = image.small elif image.image: image.small = createsc(image.image) try: image.put() except RequestTooLargeError: pic = rescale(image.image,600,600) image.image = pic image.put() del pic picture = image.small else: picture = None else: picture = image.image else: picture = None else: picture = None if picture: return HttpResponse(picture, mimetype="image/jpeg") else: return HttpResponseRedirect('/static/res/picnotfound.jpg')
def relisttoebay(request,shop,key): registerAdminAction(request,"ebayrelist",shop+"/"+key) info = ebay.getEbayInfo(request) item = Item.get_by_id(int(key),parent = getSupplier(shop)) if item: if (item.ebayid and (item.ebayid != '0')): rslt,item = relist(info,item) return rslt return (returnError("item not find or not exists in ebay"))
def relisttoebay(request, shop, key): registerAdminAction(request, "ebayrelist", shop + "/" + key) info = ebay.getEbayInfo(request) item = Item.get_by_id(int(key), parent=getSupplier(shop)) if item: if (item.ebayid and (item.ebayid != '0')): rslt, item = relist(info, item) return rslt return (returnError("item not find or not exists in ebay"))
def rotateimage(request, shop, key, index="0"): item = Item.get_by_id(int(key), parent=getSupplier(shop)) idx = int(index) if item: image = item.getImage(int(idx)) if image: gimg = images.Image(image.image) gimg.rotate(90) image.image = gimg.execute_transforms() image.put() return HttpResponse("ok")
def rotateimage(request,shop,key,index="0"): item = Item.get_by_id(int(key),parent = getSupplier(shop)) idx = int(index) if item: image = item.getImage(int(idx)) if image: gimg = images.Image(image.image) gimg.rotate(90) image.image = gimg.execute_transforms() image.put() return HttpResponse("ok")
def itemimage(request,shop,key): suppliers = Supplier.all() stories = {} items = [] for supply in suppliers: stories[supply.name] = json.loads(supply.data) item = Item.get_by_id(int(key),parent = getSupplier(shop)) if(item): upload_url = '/admin/blobimage/'+ shop + "/" + key +"/0/" upload_url1 = '/admin/blobimage/'+ shop + "/" + key +"/1/" upload_url2 = '/admin/blobimage/'+ shop + "/" + key +"/2/" upload_url3 = '/admin/blobimage/'+ shop + "/" + key +"/3/" dict = {'ITEM':item,'STORIES':stories,'BLOBURL':upload_url ,'BLOBURL1':upload_url1 ,'BLOBURL2':upload_url2 ,'BLOBURL3':upload_url3} context = Context(dict) return (render_to_response("admin/image.html",context,context_instance=RequestContext(request)))
def saveitem(request,shop,key): registerAdminAction(request,"saveitem",shop+"/"+key) item = Item.get_by_id(int(key),parent = getSupplier(shop)) if(item): item.name = request.POST['name'] item.refid = request.POST['refid'] item.price = float(request.POST['price']) item.cost = float(request.POST['cost']) item.description = request.POST['description'] item.specification = request.POST['spec'] item.category = request.POST['category'] item.category2 = request.POST['sndcategory'] item.ebaycategory = request.POST['ebaycategory'] item.disable = (True,False)[request.POST['disabled'] == "False"] item.put() indexItem(item) response = HttpResponseRedirect('/admin/item/'+ shop + '/' + key +"/") return response
def saveitem(request, shop, key): registerAdminAction(request, "saveitem", shop + "/" + key) item = Item.get_by_id(int(key), parent=getSupplier(shop)) if (item): item.name = request.POST['name'] item.refid = request.POST['refid'] item.price = float(request.POST['price']) item.cost = float(request.POST['cost']) item.description = request.POST['description'] item.specification = request.POST['spec'] item.category = request.POST['category'] item.category2 = request.POST['sndcategory'] item.ebaycategory = request.POST['ebaycategory'] item.disable = (True, False)[request.POST['disabled'] == "False"] item.put() indexItem(item) response = HttpResponseRedirect('/admin/item/' + shop + '/' + key + "/") return response
def exporttoebay(request,shop,key): registerAdminAction(request,"ebayexport",shop+"/"+key) token = ebay.getToken(request) item = Item.get_by_id(int(key),parent = getSupplier(shop)) if item: if (item.ebayid and (item.ebayid != '0')): info = ebay.getEbayInfo(request) rslt = sync(info,item) return HttpResponse(rslt,mimetype="text/xml") rslt = ebayapi.api.AddItem(token,item) xml_doc = etree.parse(StringIO(rslt)) ack = xml_doc.xpath("//xs:Ack", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0] if(not 'Failure' in ack.text): itemid = xml_doc.xpath("//xs:ItemID", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text item.ebayid = itemid item.put() return HttpResponse(rslt,mimetype="text/xml")
def item(request,shop,key): stories = getCategoriesInfo() item = Item.get_by_id(int(key),parent = getSupplier(shop)) if item: upload_url = '/admin/blobimage/'+ shop + "/" + key +"/0/" upload_url1 = '/admin/blobimage/'+ shop + "/" + key +"/1/" upload_url2 = '/admin/blobimage/'+ shop + "/" + key +"/2/" upload_url3 = '/admin/blobimage/'+ shop + "/" + key +"/3/" dict = {'ITEM':item,'STORIES':stories,'BLOBURL':upload_url ,'BLOBURL1':upload_url1 ,'BLOBURL2':upload_url2 ,'BLOBURL3':upload_url3} dict['STORIES'] = stories context = Context(dict) response = render_to_response("admin/itemfull.html",context,context_instance=RequestContext(request)) response['Cache-Control'] = 'no-cache, no-store, must-revalidate' return response else: return retailError(request,"item not found")
def exporttoebay(request, shop, key): registerAdminAction(request, "ebayexport", shop + "/" + key) token = ebay.getToken(request) item = Item.get_by_id(int(key), parent=getSupplier(shop)) if item: if (item.ebayid and (item.ebayid != '0')): info = ebay.getEbayInfo(request) rslt = sync(info, item) return HttpResponse(rslt, mimetype="text/xml") rslt = ebayapi.api.AddItem(token, item) xml_doc = etree.parse(StringIO(rslt)) ack = xml_doc.xpath( "//xs:Ack", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0] if (not 'Failure' in ack.text): itemid = xml_doc.xpath( "//xs:ItemID", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text item.ebayid = itemid item.put() return HttpResponse(rslt, mimetype="text/xml")
def blobimage(request,shop,key,index='0'): registerAdminAction(request,"blobimage",shop+"/"+key) #file = request.FILES['image'].read() #type = request.FILES['image'].content_type #image = request.FILES['image'].content_type_extra file = request.FILES['image'].read() picture = rescale(file,600,600) item = Item.get_by_id(int(key),parent = getSupplier(shop)) idx = int(index) if item: img = item.getImage(idx) if img: img.image = picture else: img = ImageData(image=picture,name=item.name,parent=item,idx=idx) img.url = "http://" + request.META['HTTP_HOST'] + "/admin/fetchimage/" + shop + "/" + key + "/" + str(idx) img.small = createsc(picture) img.put() del picture item.galleryurl = img.url item.put() return HttpResponse("ok") else: return HttpResponse("fail")
def itemimage(request, shop, key): suppliers = Supplier.all() stories = {} items = [] for supply in suppliers: stories[supply.name] = json.loads(supply.data) item = Item.get_by_id(int(key), parent=getSupplier(shop)) if (item): upload_url = '/admin/blobimage/' + shop + "/" + key + "/0/" upload_url1 = '/admin/blobimage/' + shop + "/" + key + "/1/" upload_url2 = '/admin/blobimage/' + shop + "/" + key + "/2/" upload_url3 = '/admin/blobimage/' + shop + "/" + key + "/3/" dict = { 'ITEM': item, 'STORIES': stories, 'BLOBURL': upload_url, 'BLOBURL1': upload_url1, 'BLOBURL2': upload_url2, 'BLOBURL3': upload_url3 } context = Context(dict) return (render_to_response("admin/image.html", context, context_instance=RequestContext(request)))
def deleteitem(request,shop,key): item = Item.get_by_id(int(key),parent = getSupplier(shop)) if item: deleteItemIndex(item) item.delete() return HttpResponseRedirect('/admin/items/'+shop)
def deleteitem(request, shop, key): item = Item.get_by_id(int(key), parent=getSupplier(shop)) if item: deleteItemIndex(item) item.delete() return HttpResponseRedirect('/admin/items/' + shop)
def item(request, shop, key): stories = getCategoriesInfo() item = Item.get_by_id(int(key), parent=getSupplier(shop)) return record.getItemResponse(request, item, stories)
def item(request,shop,key): stories = getCategoriesInfo() item = Item.get_by_id(int(key),parent = getSupplier(shop)) return record.getItemResponse(request,item,stories)