def delete_lightbox(lightbox_id): logger.debug('delete lightbox id: %d' % lightbox_id) lightbox = Lightbox.get_by_id(lightbox_id) logger.debug('delete lightbox name: %s' % lightbox.name) db.delete(lightbox) response = make_response('OK', 200) return response
def get_lightbox(lightbox_id): logger.debug('get lightbox id: %d' % lightbox_id) lightbox = Lightbox.get_by_id(lightbox_id) photo_keys = [] for photo in lightbox.photos: photo_keys.append(photo.key().id()) result = {"lightbox_id": lightbox.key().id(), "name": lightbox.name, "photos": photo_keys} logger.debug(result) return jsonify(lightbox=result)
def copy_image_to_lightbox(): lightboxId = int(request.json['lightboxId']) photoId = int(request.json['photoId']) logger.debug('copy image id %s lightbox id %s' % (photoId, lightboxId)) #user = users.get_current_user() lightbox = Lightbox.get_by_id(lightboxId) original = Photo.get_by_id(photoId) copied = clone_entity(original, lightbox=lightbox) copied.put() return jsonify(lightbox={"id": lightbox.key().id(), "photos": [copied.key().id()]})
def upload(): lightbox_id = int(request.form['lightboxId']) lightbox = Lightbox.get_by_id(lightbox_id) photos = [] for file in request.files.getlist('file'): logger.debug('processing file name %s for lightbox id: %d' % (file.filename, lightbox_id)) photo = Photo() photo.lightbox = lightbox image_data = file.read() photo.full_image = db.Blob(image_data) photo.thumbnail = db.Blob(images.resize(image_data, 180, 180)) photo.owner = users.get_current_user() photo.name = file.filename photo.put() photos.append(photo.key().id()) return jsonify(lightbox={"id": lightbox.key().id(), "photos": photos})