Esempio n. 1
0
def add_item(response, username):
	user_lists = User.find(username).get_wishlists()
	current_wishlist = user_lists[0]

	details = {
		"name": response.get_field('wish'),
		"image": response.get_field('image') or '/static/images/gift_box.png',
		"link": response.get_field('website'),
		"description": response.get_field('description'),
		"price": response.get_field('price')
	}

	encoded_string = ""
	if details['name'] != "":
		product = Product.create(**details)
		current_wishlist.add_item(product)
	else:
		encoded_string = urlencode({'error': "0"})

	response.redirect('/users/' + username + "?" + encoded_string)