Beispiel #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)
Beispiel #2
0
 def _process(self):
     if self._room.has_live_reservations():
         flash(_(u'Cannot delete room with live bookings'), 'error')
         return redirect(
             url_for('rooms.roomBooking-roomDetails', self._room))
     else:
         db.session.delete(self._room)
         build_rooms_spritesheet()
         flash(_(u'Room deleted'), 'success')
         return redirect(
             url_for('rooms_admin.roomBooking-adminLocation',
                     self._room.location))
Beispiel #3
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)
Beispiel #4
0
    def _save(self):
        room = self._room
        form = self._form
        # Simple fields
        form.populate_obj(room,
                          skip=('bookable_hours', 'nonbookable_periods'),
                          existing_only=True)
        room.update_name()
        # Photos
        if form.large_photo.data:
            _cache.delete('photo-{}'.format(room.id))
            room.photo = Photo(data=form.large_photo.data.read())
            build_rooms_spritesheet()
        elif form.delete_photos.data:
            _cache.delete('photo-{}'.format(room.id))
            room.photo = None
            build_rooms_spritesheet()
        # Custom attributes
        room.attributes = [
            RoomAttributeAssociation(value=form['attribute_{}'.format(
                attr.id)].data,
                                     attribute_id=attr.id)
            for attr in self._location.attributes.all()
            if form['attribute_{}'.format(attr.id)].data
        ]
        # Bookable times
        room.bookable_hours = [
            BookableHours(start_time=bt['start'], end_time=bt['end'])
            for bt in form.bookable_hours.data
            if all(x is not None for x in bt.viewvalues())
        ]

        # Nonbookable dates
        room.nonbookable_periods = [
            NonBookablePeriod(start_dt=nbd.start_dt, end_dt=nbd.end_dt)
            for nbd in form.nonbookable_periods
            if (nbd.start_dt and nbd.end_dt)
        ]
Beispiel #5
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))