def return_restaurants():
"""Gives response to browser of restaurants in db for given list"""
list_id = request.form.get('list_id')
item_id = request.form.get('id')
restaurants_lists = RestaurantList.query.filter_by(list_id=list_id, visited=False).all()
restaurants = []
for item in restaurants_lists:
restaurant = Restaurant.query.filter_by(restaurant_id=item.restaurant_id).first()
restaurants.append({'restaurant_name': restaurant.restaurant_name,
'yelp_rating': restaurant.yelp_rating,
'latitude': restaurant.latitude,
'longitude': restaurant.longitude,
'restaurant_id': restaurant.restaurant_id})
print restaurants
return jsonify(status="success", results=restaurants, id=item_id)
评论列表
文章目录