def getItemHistoryResponse(request): itemrefs = getItemHistory(request) items = [] if (itemrefs != None): for ref in itemrefs: items.append(getItem(ref)) stories = getCategoriesInfo() lvl1 = "Viewing History" dict = {'SHOP':'Items you recently viewed','STORIES':stories,'PATH':lvl1,'CATEGORY':""} dict['sellitems'] = items context = Context(dict) temp_path = currentSite().gettemplate("products.html"); return (render_to_response(temp_path,context,context_instance=RequestContext(request))) else: return userError(request,"Your have not signed in")
def item(request,itemid): stories = getCategoriesInfo() item = getItem(itemid) if item: iteminfo = {} iteminfo['galleryurl'] = item.galleryurl iteminfo['description'] = item.description iteminfo['specification'] = item.specification iteminfo['infourl'] = "/admin/item/"+item.parent().name+"/"+str(item.key().id()) +"/" response = HttpResponse(json.dumps(iteminfo)) response['Access-Control-Allow-Origin'] = "*" return response else: response = HttpResponse("{}") response['Access-Control-Allow-Origin'] = "*" return response
def getItemHistory(request): user = zuser.getCurrentUser(request) rslt = [] if user: history = user.history if not history: history = "{}" history = json.loads(history) if 'items' in history: items = history['items'] else: items = [] for rid in items: item = getItem(rid) if item: rslt.append(item) return rslt
def item(request, itemid): stories = getCategoriesInfo() item = getItem(itemid) if item: iteminfo = {} iteminfo['galleryurl'] = item.galleryurl iteminfo['description'] = item.description iteminfo['specification'] = item.specification iteminfo['infourl'] = "/admin/item/" + item.parent().name + "/" + str( item.key().id()) + "/" response = HttpResponse(json.dumps(iteminfo)) response['Access-Control-Allow-Origin'] = "*" return response else: response = HttpResponse("{}") response['Access-Control-Allow-Origin'] = "*" return response
def getItemHistoryResponse(request): itemrefs = getItemHistory(request) items = [] if (itemrefs != None): for ref in itemrefs: items.append(getItem(ref)) stories = getCategoriesInfo() lvl1 = "Viewing History" dict = { 'SHOP': 'Items you recently viewed', 'STORIES': stories, 'PATH': lvl1, 'CATEGORY': "" } dict['sellitems'] = items context = Context(dict) temp_path = currentSite().gettemplate("products.html") return (render_to_response(temp_path, context, context_instance=RequestContext(request))) else: return userError(request, "Your have not signed in")
def format(ebayinfo,itemid): token = ebayinfo['token'] id = ebayinfo['id'] config = {'SELLER_ID':id} item = GetItem(itemid,token) xml_doc = etree.parse(StringIO(item)) ack = xml_doc.xpath("//xs:Ack", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0] if('Success' in ack.text): description = xml_doc.xpath("//xs:Description", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0] refid = xml_doc.xpath("//xs:SKU", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"}) if (not refid): return returnError('SKU Not Provided') else: refid = refid[0].text # refid = xml_doc.xpath("//xs:ItemID", # namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text name = xml_doc.xpath("//xs:Title", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text price = xml_doc.xpath("//xs:ConvertedCurrentPrice", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text galleryurl = xml_doc.xpath("//xs:GalleryURL", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text infourl = xml_doc.xpath("//xs:ViewItemURL", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text ebaycategory = xml_doc.xpath("//xs:PrimaryCategory/xs:CategoryID", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text category = xml_doc.xpath("//xs:StoreCategoryID", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text sndcategory = xml_doc.xpath("//xs:StoreCategory2ID", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text sellingstatus = xml_doc.xpath("//xs:SellingStatus/xs:ListingStatus", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text topd = description.text.split("<!-- below is embeded code -->") config['INITIAL'] = topd[0] config['EXTRA'] = ShopInfo.all().filter("type =","ebay").order("name") # save the item iteminfo = {'refid':refid,'name':name ,'price':float(price),'cost':float(price),'galleryurl':galleryurl ,'infourl':infourl,'category':category,'sndcategory':sndcategory ,'description':topd[0],'ebayid':itemid,'ebaycategory':ebaycategory ,'specification':"{}"} item = retailtype.getItem(refid) supplier = getSupplierFromEbayInfo(ebayinfo) if item: iteminfo['specification'] = item.specification # FIXME: We do not update galleryurl back to ebay gallery url at the moment. # iteminfo['galleryurl'] = item.galleryurl item.ebayid = itemid supplier = item.parent() zitem = supplier.saveItem(iteminfo) config['ITEM'] = zitem format = loader.get_template("ebay/format.html") content = format.render(Context(config)) if (sellingstatus != "Completed"): revise = ReviseItemSimple(item,token,content) xml_doc = etree.parse(StringIO(revise)) ack = xml_doc.xpath("//xs:Ack", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0] if('Success' in ack.text): return (HttpResponse(revise,mimetype = "text/xml"),item) else: return (HttpResponse(revise,mimetype = "text/xml"),None) else: revise = RelistItemSimple(item,token,content) xml_doc = etree.parse(StringIO(revise)) ack = xml_doc.xpath("//xs:Ack", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0] if('Success' in ack.text): ebayid = xml_doc.xpath("//xs:ItemID", namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text zitem.ebayid = refid zitem.put() return (HttpResponse(revise,mimetype = "text/xml"),item) else: return (HttpResponse(revise,mimetype = "text/xml"),None) else: return (HttpResponse(item,mimetype = "text/xml"),None)
def format(ebayinfo, itemid): token = ebayinfo['token'] id = ebayinfo['id'] config = {'SELLER_ID': id} item = GetItem(itemid, token) xml_doc = etree.parse(StringIO(item)) ack = xml_doc.xpath("//xs:Ack", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0] if ('Success' in ack.text): description = xml_doc.xpath( "//xs:Description", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0] refid = xml_doc.xpath( "//xs:SKU", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"}) if (not refid): return returnError('SKU Not Provided') else: refid = refid[0].text # refid = xml_doc.xpath("//xs:ItemID", # namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text name = xml_doc.xpath("//xs:Title", namespaces={ 'xs': "urn:ebay:apis:eBLBaseComponents" })[0].text price = xml_doc.xpath( "//xs:ConvertedCurrentPrice", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text galleryurl = xml_doc.xpath( "//xs:GalleryURL", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text infourl = xml_doc.xpath( "//xs:ViewItemURL", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text ebaycategory = xml_doc.xpath( "//xs:PrimaryCategory/xs:CategoryID", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text category = xml_doc.xpath( "//xs:StoreCategoryID", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text sndcategory = xml_doc.xpath( "//xs:StoreCategory2ID", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text sellingstatus = xml_doc.xpath( "//xs:SellingStatus/xs:ListingStatus", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text topd = description.text.split("<!-- below is embeded code -->") config['INITIAL'] = topd[0] config['EXTRA'] = ShopInfo.all().filter("type =", "ebay").order("name") # save the item iteminfo = { 'refid': refid, 'name': name, 'price': float(price), 'cost': float(price), 'galleryurl': galleryurl, 'infourl': infourl, 'category': category, 'sndcategory': sndcategory, 'description': topd[0], 'ebayid': itemid, 'ebaycategory': ebaycategory, 'specification': "{}" } item = retailtype.getItem(refid) supplier = getSupplierFromEbayInfo(ebayinfo) if item: iteminfo['specification'] = item.specification # FIXME: We do not update galleryurl back to ebay gallery url at the moment. # iteminfo['galleryurl'] = item.galleryurl item.ebayid = itemid supplier = item.parent() zitem = supplier.saveItem(iteminfo) config['ITEM'] = zitem format = loader.get_template("ebay/format.html") content = format.render(Context(config)) if (sellingstatus != "Completed"): revise = ReviseItemSimple(item, token, content) xml_doc = etree.parse(StringIO(revise)) ack = xml_doc.xpath( "//xs:Ack", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0] if ('Success' in ack.text): return (HttpResponse(revise, mimetype="text/xml"), item) else: return (HttpResponse(revise, mimetype="text/xml"), None) else: revise = RelistItemSimple(item, token, content) xml_doc = etree.parse(StringIO(revise)) ack = xml_doc.xpath( "//xs:Ack", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0] if ('Success' in ack.text): ebayid = xml_doc.xpath( "//xs:ItemID", namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text zitem.ebayid = refid zitem.put() return (HttpResponse(revise, mimetype="text/xml"), item) else: return (HttpResponse(revise, mimetype="text/xml"), None) else: return (HttpResponse(item, mimetype="text/xml"), None)