Created
August 12, 2015 10:24
-
-
Save prrraveen/04bbe39a479385ce69b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@csrf_exempt | |
def save(request): | |
''' | |
save the images 1234 | |
get the item | |
image_key =create image with this item key | |
update item color and flyrobe size and image forien key | |
save this item | |
return the response | |
''' | |
print '@ save' | |
item = pc.inventory.objects.all().get(pk=request.POST['item_id']) | |
result1 = cloudinary.uploader.upload(request.FILES['img1']) | |
print 'result1' | |
print result1 | |
image={'image_public_id':result1['public_id'],'image_feature_type':'FRONT','inventory': item} | |
obj = pc.item_image(**image) | |
obj.save() | |
result2 = cloudinary.uploader.upload(request.FILES['img2']) | |
print 'result2' | |
print result2 | |
image={'image_public_id':result2['public_id'],'image_feature_type':'BACK','inventory': item} | |
obj = pc.item_image(**image) | |
obj.save() | |
result3 = cloudinary.uploader.upload(request.FILES['img3']) | |
print 'result3' | |
print result3 | |
image={'image_public_id':result3['public_id'],'image_feature_type':'MULTI1','inventory': item} | |
obj = pc.item_image(**image) | |
obj.save() | |
result4 = cloudinary.uploader.upload(request.FILES['img4']) | |
print 'result4' | |
print result4 | |
image={'image_public_id':result4['public_id'],'image_feature_type':'MULTI2','inventory': item} | |
obj = pc.item_image(**image) | |
obj.save() | |
color_list = json.loads(request.POST['color']) | |
for i in color_list: | |
cobj = pc.color.objects.all().get(pk=int(i) ) | |
item.color.add(cobj) | |
item.flyrobe_size = request.POST['flyrobe_size'] | |
item.save() | |
return HttpResponse(json.dumps(''), content_type='application/json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment