def wrapper(*args, **kw): if not args: raise IndicoError(_('Wrong usage of location decorator')) location_name = getattr(request, request_attribute).get(parameter_name, None) location = Location.find_first(name=location_name) if not location: raise NotFoundError(_('There is no location named: {0}').format(location_name)) setattr(args[0], attribute_name, location) return f(*args, **kw)
def wrapper(*args, **kw): try: location = getattr(args[0], location_attribute_name) except (AttributeError, IndexError): raise IndicoError(_('Wrong usage of room decorator')) room_id = getattr(request, request_attribute).get(parameter_name, None) try: room = Room.query.with_parent(location).filter_by(id=room_id).one() except NoResultFound: raise NotFoundError(_("There is no room at '{1}' with id: {0}").format(room_id, location.name)) setattr(args[0], attribute_name, room) return f(*args, **kw)
def _checkParams(self): RHRoomBookingBookingMixin._checkParams(self) # use 'room' if passed through GET room_id = request.args.get('room', None) if room_id is None: # otherwise default to reservation's self._room = self._reservation.room else: self._room = Room.get(int(room_id)) if self._room is None: raise NotFoundError('This room does not exist')
def _checkParams(self): self._room = Room.get(int(request.view_args['roomID'])) if self._room is None: raise NotFoundError('This room does not exist')