Пример #1
0
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
Пример #2
0
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")
Пример #3
0
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')
Пример #4
0
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")
Пример #5
0
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
Пример #6
0
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')
Пример #7
0
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"))
Пример #8
0
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"))
Пример #9
0
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")
Пример #10
0
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")
Пример #11
0
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)))
Пример #12
0
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
Пример #13
0
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
Пример #14
0
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")
Пример #15
0
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")
Пример #16
0
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")
Пример #17
0
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")
Пример #18
0
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)))
Пример #19
0
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)
Пример #20
0
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)
Пример #21
0
def item(request, shop, key):
    stories = getCategoriesInfo()
    item = Item.get_by_id(int(key), parent=getSupplier(shop))
    return record.getItemResponse(request, item, stories)
Пример #22
0
def item(request,shop,key):
  stories = getCategoriesInfo()
  item = Item.get_by_id(int(key),parent = getSupplier(shop))
  return record.getItemResponse(request,item,stories)