Exemplo n.º 1
0
	def is_available(self, request_id, offer_id):
		try:
			assert self.current_user, 'Not login'
			uid = self.current_user.key().id()
			rid = force_int(request_id)
			oid = force_int(offer_id)
			request = OneToOnesService.get_request(rid)
			assert request, 'No reqeust found'
			offer = OneToOnesService.get_offer(oid)
			assert offer, 'No offer found'
			
			assert request.author_id == uid or offer.author_id == uid, 'No permission'
		except AssertionError, e:
			logging.error(e)
			return False
Exemplo n.º 2
0
	def decorated_func(arg, *args, **kargs):
		if not arg.is_logged_in:
			arg.add_flash(get_text('LOGIN_REQUIRED'), 'error')
			arg.redirect('/about')
			return
		try:
			assert 'request_id' in kargs and 'offer_id' in kargs, 'Invalid request'
			uid = arg.current_user.key().id()
			rid = force_int(kargs['request_id'])
			oid = force_int(kargs['offer_id'])
			request = OneToOnesService.get_request(rid)
			assert request, 'No reqeust found'
			offer = OneToOnesService.get_offer(oid)
			assert offer, 'No offer found'
		except AssertionError, e:
			logging.error("# %s" % e)
			arg.render_error(404)
			return