def api_upload(request): if request.method == 'POST': picture = Picture() user = User.objects.get(email=request.POST['email']) picture.user = user form = UploadFileForm(request.POST, request.FILES, instance=picture) if form.is_valid(): picture.picture = request.FILES['picture'] if request.POST.has_key('gallery_id'): gallery = Gallery.objects.get(id=request.POST['gallery_id'], user=user) picture.gallery = gallery picture.picture.name = unidecode(picture.picture.name) picture.save() rotate_picture(picture) picture.update_thumb() if request.POST.has_key('description'): picture_description = PictureDescription(picture=picture) picture_description.text = request.POST['description'] picture_description.save() response = {'status':'OK'} response['data'] = serialize_picture(picture) return HttpResponse(json.dumps(response)) return HttpResponse(content_200)
def api_upload(request): if request.method == 'POST': picture = Picture() user = User.objects.get(email=request.POST['email']) picture.user = user form = UploadFileForm(request.POST, request.FILES, instance=picture) if form.is_valid(): picture.picture = request.FILES['picture'] if request.POST.has_key('gallery_id'): gallery = Gallery.objects.get(id=request.POST['gallery_id'], user=user) picture.gallery = gallery picture.picture.name = unidecode(picture.picture.name) picture.save() rotate_picture(picture) picture.update_thumb() if request.POST.has_key('description'): picture_description = PictureDescription(picture=picture) picture_description.text = request.POST['description'] picture_description.save() response = {'status': 'OK'} response['data'] = serialize_picture(picture) return HttpResponse(json.dumps(response)) return HttpResponse(content_200)
def api_picture(request, picture_id): picture = Picture.objects.get(id=picture_id) picture_json = serialize_picture(picture) return HttpResponse(json.dumps(picture_json), content_type="application/json")