Exemplo n.º 1
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")
Exemplo n.º 2
0
def addimages(request,supplier):
  file = request.FILES['files[]'].read()
  name = request.FILES['files[]'].name.split(".")
  name.pop()
  rid = ".".join(name)
  item = createDefaultItem(rid,supplier)
  picture = quickrescale(file, 600)
  idx = 0
  img = item.getImage(idx)
  if img:
    img.image = picture
    img.small = createsc(img.image)
    img.put()
  else:
    img = ImageData(image=picture,name=item.name,parent=item,idx=idx) 
    img.url = "http://" + request.META['HTTP_HOST'] + "/admin/fetchimage/" + item.parent().name + "/" + str(item.key().id()) + "/" + str(idx)
    img.small = createsc(img.image)
    img.put()
    del picture
    item.galleryurl = img.url
    item.put()
  return HttpResponse("ok")
Exemplo n.º 3
0
def addimages(request, supplier):
    file = request.FILES['files[]'].read()
    name = request.FILES['files[]'].name.split(".")
    name.pop()
    rid = ".".join(name)
    item = createDefaultItem(rid, supplier)
    picture = quickrescale(file, 600)
    idx = 0
    img = item.getImage(idx)
    if img:
        img.image = picture
        img.small = createsc(img.image)
        img.put()
    else:
        img = ImageData(image=picture, name=item.name, parent=item, idx=idx)
        img.url = "http://" + request.META[
            'HTTP_HOST'] + "/admin/fetchimage/" + item.parent(
            ).name + "/" + str(item.key().id()) + "/" + str(idx)
        img.small = createsc(img.image)
        img.put()
        del picture
        item.galleryurl = img.url
        item.put()
    return HttpResponse("ok")
Exemplo n.º 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")