Esempio n. 1
0
 def _process(self):
     sprite_mapping = _cache.get('rooms-sprite-mapping')
     if sprite_mapping is None:
         build_rooms_spritesheet()
     if 'version' not in request.view_args:
         return redirect(url_for('.sprite', version=_cache.get('rooms-sprite-token')))
     photo_data = _cache.get('rooms-sprite')
     return send_file('rooms-sprite.jpg', BytesIO(photo_data), 'image/jpeg', no_cache=False, cache_timeout=365*86400)
Esempio n. 2
0
 def _process_POST(self):
     f = request.files['photo']
     try:
         photo = Image.open(f)
     except OSError:
         raise UserValueError(_('You cannot upload this file as a room picture.'))
     if photo.format.lower() not in {'jpeg', 'png', 'gif'}:
         raise UserValueError(_('The file has an invalid format ({format}).').format(format=photo.format))
     if photo.mode != 'RGB':
         photo = photo.convert('RGB')
     image_bytes = BytesIO()
     photo.save(image_bytes, 'JPEG')
     image_bytes.seek(0)
     self.room.photo = Photo(data=image_bytes.read())
     token = build_rooms_spritesheet()
     return jsonify(rooms_sprite_token=str(token))
Esempio n. 3
0
 def _process_POST(self):
     photo = request.files['photo'].read()
     self.room.photo = Photo(data=photo)
     token = build_rooms_spritesheet()
     return jsonify(rooms_sprite_token=unicode(token))
Esempio n. 4
0
 def _process_POST(self):
     photo = request.files['photo'].read()
     self.room.photo = Photo(data=photo)
     token = build_rooms_spritesheet()
     return jsonify(rooms_sprite_token=unicode(token))