Пример #1
0
    def get_current_user(self):
	# The user_id returned from here will be set in self.current_user
	user_id = self.get_cookie(configuration.user_id_cookie_name)
	if not user_id:
	    log.error('Auth Fail: No user_id found in cookie')
	    return
	self.username = user_service.get_user_nav_name(id = user_id)
	return user_id
Пример #2
0
    def post(self):
	resp = {}
	try:
	    name = self.get_argument('name').strip() if self.get_argument('name', None) \
		    else None
	    user = user_service.get_user(id = self.current_user)
	    if not name or not user:
		resp['error'] = ERROR_MISSING_PARAMS
	    else:
		kwargs = {
			'name' : name,
			'user_id' : self.current_user,
			'seller_name' : user_service.get_user_nav_name(id = self.current_user),
			'seller_email' : user.to_dict().get('email', None),
			'livemode' : True
			 }
		resp['id'] = form_service.save_new_form(**kwargs)
		resp['success'] = True
	except Exception as e:
	    resp['error'] = '%s' %(e)
	self.set_body(resp)
	return self.render()