Example #1
0
File: ebay.py Project: zoyoe/ectool
def relist(ebayinfo,item):
  token = ebayinfo['token']
  config = {'SELLER_ID':ebayinfo['id']}
  config['INITIAL'] = item.description
  config['ITEM'] = item
  config['EXTRA'] = ShopInfo.all().filter("type =","ebay").order("name")
  format = loader.get_template("ebay/format.html")
  content = format.render(Context(config))
  ebayitem = GetItem(item.ebayid,token)
  xml_doc = etree.parse(StringIO(ebayitem))
  ack = xml_doc.xpath("//xs:Ack",
    namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0]
  if('Success' in ack.text):
    sellingstatus = xml_doc.xpath("//xs:SellingStatus/xs:ListingStatus",
      namespaces={'xs':"urn:ebay:apis:eBLBaseComponents"})[0].text
    if (sellingstatus == "Completed"):
      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
        item.ebayid = refid
        item.put()
      return (HttpResponse(revise,mimetype = "text/xml"),item)
    else:
      return (returnError("Related ebay item is still active"),item)
  else:
    return (HttpResponse(ebayitem,mimetype = "text/xml"),item)
Example #2
0
def relist(ebayinfo, item):
    token = ebayinfo['token']
    config = {'SELLER_ID': ebayinfo['id']}
    config['INITIAL'] = item.description
    config['ITEM'] = item
    config['EXTRA'] = ShopInfo.all().filter("type =", "ebay").order("name")
    format = loader.get_template("ebay/format.html")
    content = format.render(Context(config))
    ebayitem = GetItem(item.ebayid, token)
    xml_doc = etree.parse(StringIO(ebayitem))
    ack = xml_doc.xpath("//xs:Ack",
                        namespaces={'xs':
                                    "urn:ebay:apis:eBLBaseComponents"})[0]
    if ('Success' in ack.text):
        sellingstatus = xml_doc.xpath(
            "//xs:SellingStatus/xs:ListingStatus",
            namespaces={'xs': "urn:ebay:apis:eBLBaseComponents"})[0].text
        if (sellingstatus == "Completed"):
            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
                item.ebayid = refid
                item.put()
            return (HttpResponse(revise, mimetype="text/xml"), item)
        else:
            return (returnError("Related ebay item is still active"), item)
    else:
        return (HttpResponse(ebayitem, mimetype="text/xml"), item)
Example #3
0
def ebayconfig(request):
    #  some config template
    context = {}
    context['EBAY'] = ShopInfo.all().filter("type =", "ebay").order("name")
    return (render_to_response("config/config.html",
                               context,
                               context_instance=RequestContext(request)))
Example #4
0
def preference(request):
    context = {}
    context['CATEGORIES'] = ShopInfo.all().filter("type =",
                                                  "category").order("name")
    context['SITEINFO'] = retailtype.getSiteInfo()
    return (render_to_response("config/preferences.html",
                               context,
                               context_instance=RequestContext(request)))
Example #5
0
def feedinfo(k, content, type):
    if (type == "private"):
        configsite(k, content)
    else:
        line = ShopInfo.all().filter("name =", k).get()
        if not line:
            line = ShopInfo(name=k, content=content, type=type)
            line.put()
        else:
            line.content = content
            line.put()
Example #6
0
def addconfig(request):
  if ("title" in request.POST):
    if ("content" in request.POST and request.POST['content']):
      feedinfo(request.POST['title'],request.POST['content'],request.POST['type'])
    else:
      line = ShopInfo.all().filter("name =",request.POST['title']).get()
      if line:
        line.delete()
  response =  HttpResponseRedirect('/admin/config/'+ request.POST['setting'])
  return response
Example #7
0
def addconfig(request):
    if ("title" in request.POST):
        if ("content" in request.POST and request.POST['content']):
            feedinfo(request.POST['title'], request.POST['content'],
                     request.POST['type'])
        else:
            line = ShopInfo.all().filter("name =", request.POST['title']).get()
            if line:
                line.delete()
    response = HttpResponseRedirect('/admin/config/' + request.POST['setting'])
    return response
Example #8
0
def feedinfo(k,content,type):
  if(type == "private"):
    configsite(k,content)
  else:
    line = ShopInfo.all().filter("name =",k).get()
    if not line:
      line = ShopInfo(name=k,content=content,type=type)
      line.put()
    else:
      line.content = content
      line.put()
Example #9
0
File: ebay.py Project: zoyoe/ectool
def sync(ebayinfo,item):
  token = ebayinfo['token']
  id = ebayinfo['id']
  config = {'SELLER_ID':id}
  description = item.description
  name = item.name 
  config['INITIAL'] = description
  config['ITEM'] = item
  config['EXTRA'] = ShopInfo.all().filter("type =","ebay").order("name")
  format = loader.get_template("ebay/format.html")
  content = format.render(Context(config))
  if (not item.ebayid):
    revise = ReviseItemBySKU(item.refid,name,token,content)
  else:
    revise = ReviseItem(item,token,content)
  return HttpResponse(revise,mimetype = "text/xml")
Example #10
0
def sync(ebayinfo, item):
    token = ebayinfo['token']
    id = ebayinfo['id']
    config = {'SELLER_ID': id}
    description = item.description
    name = item.name
    config['INITIAL'] = description
    config['ITEM'] = item
    config['EXTRA'] = ShopInfo.all().filter("type =", "ebay").order("name")
    format = loader.get_template("ebay/format.html")
    content = format.render(Context(config))
    if (not item.ebayid):
        revise = ReviseItemBySKU(item.refid, name, token, content)
    else:
        revise = ReviseItem(item, token, content)
    return HttpResponse(revise, mimetype="text/xml")
Example #11
0
File: ebay.py Project: zoyoe/ectool
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)
Example #12
0
def removeconfig(request):
    if ("title" in request.POST):
        line = ShopInfo.all().filter("name =", request.POST['title']).get()
        if line:
            line.delete()
    return HttpResponse("ok")
Example #13
0
def removeconfig(request):
  if ("title" in request.POST):
    line = ShopInfo.all().filter("name =",request.POST['title']).get()
    if line:
      line.delete()
  return HttpResponse("ok")
Example #14
0
def ebayconfig(request):
#  some config template
  context = {}
  context['EBAY'] = ShopInfo.all().filter("type =","ebay").order("name")
  return (render_to_response("config/config.html",context,context_instance=RequestContext(request)))
Example #15
0
def preference(request):
  context = {}
  context['CATEGORIES'] = ShopInfo.all().filter("type =","category").order("name")
  context['SITEINFO'] = retailtype.getSiteInfo()
  return (render_to_response("config/preferences.html",context,context_instance=RequestContext(request)))
Example #16
0
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)