Exemple #1
0
def result_page(request, slug):
	event_host_id = int(slug.split('-')[2])
	shards_to_query = bucket_users_into_shards([event_host_id])
	shardid = 0 
	event = None

	# This is shady, but basically theres only going to be 1
	# match for the event we're looking for
	for shard, id in shards_to_query.items():
		event = Event.objects.filter(slug__in=[slug])
		set_user_for_sharding(event, shard)
		shardid = shard
		event = event.first()
		
	set_user_for_sharding(EventSubmission.objects, shardid)
	submissions = EventSubmission.objects.filter(event_id=event.id)

	event_preferences=[]
	for submission in submissions:
		set_user_for_sharding(Restriction.objects, shardid)
		restrictions = Restriction.objects.filter(submission=submission)
		for restriction in restrictions:
			print(restriction.name)
			event_preferences.append(restriction.name)
	event_preferences=set(event_preferences)

	set_user_for_sharding(Restaurant.objects, shardid)
	result = yelp_call(event.radius,event.location,event_preferences)
	restaurant = Restaurant(user_id=shardid, event=event,restaurant_name=result[0],image_url=result[1],yelp_url=result[2],address=result[3])
	restaurant.save()

	return render(request,'../templates/successpage.html',{'restaurant':restaurant,'event':event})
Exemple #2
0
def restaurants():
    #""" Get All Restaurants. """
    if request.method == 'GET':
        restaurants = Restaurant.query.all()
        response = jsonify({
            'restaurants':
            [restaurant.to_dict() for restaurant in restaurants],
            '_link':
            url_for('api.restaurants')
        })
        response.headers['Location'] = url_for('api.restaurants')
        return response

    #""" Create a restaurant. """
    elif request.method == 'POST':
        data = request.get_json() or {}

        if 'name' not in data and 'email' not in data and 'contact' not in data:
            return bad_request(
                'Restaurant name, email and contact was missing from the request.'
            )
        if 'name' not in data:
            return bad_request('Restaurant name was missing from the request.')
        if 'email' not in data:
            return bad_request('Email was missing from the request.')
        if 'contact' not in data:
            return bad_request('Contact was missing from the request.')
        if Restaurant.query.filter_by(name=data['name']).first():
            return bad_request('This Restaurant name is already registered.')
        if Restaurant.query.filter_by(email=data['email']).first():
            return bad_request(
                'This email is already in use by another restuarant. Please use a different email.'
            )

        restaurant = Restaurant()
        restaurant.from_dict(data)

        db.session.add(restaurant)
        db.session.commit()
        response = jsonify(restaurant.to_dict())
        response.status_code = 201
        response.headers['Location'] = url_for('api.restaurant',
                                               id=restaurant.id)
        return response

    #""" PUT method not allowed on this endpoint. """
    elif request.method == 'PUT':
        return bad_request(
            "You cannot update a restaurant on this end point. Use this for a PUT request with an id: "
            + url_for('api.restaurant') + "/<id>")

    #""" DELETE method not allowed on this endpoint. """
    elif request.method == 'DELETE':
        return bad_request(
            "You cannot delete a restaurant on this end point. Use this for a DELETE request with an id: "
            + url_for('api.restaurant') + "/<id>")

    else:
        return bad_request("That's a bad request.")
def adding_restaurant():
    try:
        data = request.json
        res = Restaurant(name=data['name'], logo=data['logo'])
        db.session.add(res)
        db.session.commit()
        return jsonify(res.to_dict())
    except:
        return {'errors': ['An error occurred while posting the data']}
Exemple #4
0
def seed_restaurants():

    res = [
        Restaurant(name='Dunkin', logo='//logo.clearbit.com/dunkindonuts.com'),
        Restaurant(name='Southern Catch Seafood Restaruant', logo='')
    ]

    db.session.add_all(res)
    db.session.commit()
Exemple #5
0
    def restaurant(current_user):
        if current_user.role != 'admin':
            response = jsonify({
                'message': 'Unauthorized command',
                'status': False
            })
            response.status_code = 401

            return response

        restaurant_name = str(request.data.get('restaurant_name'))
        restaurant_email = str(request.data.get('restaurant_email'))
        restaurant_county = str(request.data.get('restaurant_county'))
        restaurant_location = str(request.data.get('restaurant_location'))
        restaurant_minorder = str(request.data.get('restaurant_minorder'))
        restaurant_phone = str(request.data.get('restaurant_phone'))
        restaurant_mobile = str(request.data.get('restaurant_mobile'))
        restaurant_about = str(request.data.get('restaurant_about'))
        restaurant_delivery = str(request.data.get('restaurant_delivery'))

        if restaurant_name.isspace() or restaurant_email.isspace() or restaurant_county.isspace() or restaurant_location.isspace():
            response = jsonify({
                'message': 'All fields are required',
                'status': False
            })

            return response
        elif restaurant_minorder.isspace() or restaurant_phone.isspace() or restaurant_mobile.isspace():
            reponse = jsonify({
                'message': 'All fields are required',
                'status': False
            })

            return response
        elif restaurant_about.isspace() or restaurant_delivery.isspace():
            response = jsonify({
                'message': 'All fields are required',
                'status': False
            })

            return response
        else: 
            new_restaurant = Restaurant(restaurant_name, restaurant_email, restaurant_county, restaurant_location, restaurant_minorder, restaurant_phone, restaurant_mobile, restaurant_about, restaurant_delivery)
            new_restaurant.save()

            response = jsonify({
                'Message': 'Successfully added new Restaurant',
                'Status': True
            })

            response.status_code = 201
            return response
Exemple #6
0
    def test_happy_hour_model(self):
        """
        Test number of records in Happy Hour table
        """

        # create test restaurant
        restaurant = Restaurant(name="The Med",
                                deal="Beerz fo dayz",
                                menu="www.pornhub.com")

        # save restaurant to database
        db.session.add(restaurant)
        db.session.commit()

        # create test happy hour
        happy_hour = HappyHour(day='mon',
                               restaurant_id=Restaurant.query.filter_by(name='The Med').first().id,
                               start_time=datetime.time(1, 0),
                               end_time=datetime.time(1, 30))

        # save happy hour to database
        db.session.add(happy_hour)
        db.session.commit()

        self.assertEqual(Restaurant.query.count(), 1)
Exemple #7
0
    def get(self, restaurant_id):
        restaurant = Restaurant.get_restaurant(restaurant_id)
        if restaurant:
            Votes.increment(restaurant, self.today)
            self.voter.broadcast_votes(self.today)

        return self.ok()
Exemple #8
0
def all_restaurants():

    if request.method == 'GET':
        restaurants = session.query(Restaurant).all()
        return jsonify([item.serialize for item in restaurants])

    if request.method == 'POST':
        location = request.args.get('l')
        meal = request.args.get('m')
        restaurant_data = find_restaurant(meal, location)

        if restaurant_data['name'] == 'No restaurants found.':
            return jsonify({
                "error":
                "No Restaurants Found for {} in {}".format(meal, location)
            })
        else:
            rest_query = session.query(Restaurant).filter_by(
                name=restaurant_data['name'])
            if rest_query.first():
                restaurant = rest_query.first()
                return jsonify({
                    "error":
                    "Restaurant {} already exists in the database.".format(
                        restaurant.name)
                })
            else:
                restaurant = Restaurant(
                    name=restaurant_data['name'],
                    address=restaurant_data['address'].decode('utf-8'),
                    image=restaurant_data['image'])
                session.add(restaurant)
                session.commit()
                return jsonify(restaurant=restaurant.serialize)
Exemple #9
0
def seed_restuarants(filepath="../csv_data/lko_final_01.csv"):
    if os.path.exists(filepath):
        df = pd.read_csv(filepath)
        for index, r in df.iterrows():
            # rest_id,zomato_url,name,city,area,rating,rating_count,telephone,
            # cuisine,cost_for_two,address,online_order,table_reservation,delivery_only,
            # famous_food,longitude,latitude

            record = Restaurant(id=r['rest_id'],
                                zomato_url=r['zomato_url'],
                                name=r['name'],
                                city=r['city'],
                                area=r['area'],
                                rating=r['rating'],
                                rating_count=r['rating_count'],
                                telephone=r['telephone'],
                                cuisine=r['cusine'],
                                cost_for_two=r['cost_for_two'],
                                address=r['address'],
                                online_order=r['online_order'],
                                table_reservation=r['table_reservation'],
                                delivery_only=r['delivery_only'],
                                famous_food=r['famous_food'],
                                longitude=r['longitude'],
                                latitude=r['latitude'], )
            db.session.add(record)
        db.session.commit()
Exemple #10
0
def client():
    db_file_directory, db_file = tempfile.mkstemp()

    os.environ["SQLALCHEMY_URL"] = "sqlite:///" + db_file

    from app import create_app
    from app import db

    app = create_app()

    with app.test_client() as testing_client:
        with app.app_context():
            app.config["SQLALCHEMY_DATABASE_URI"] = os.environ[
                "SQLALCHEMY_URL"]
            app.config["TESTING"] = True

            db.create_all()

            from app.models import Restaurant

            for restaurant in restaurants:
                db.session.add(Restaurant(**restaurant))

            db.session.commit()

            yield testing_client

    os.close(db_file_directory)
Exemple #11
0
 def post(self):
     form = UpdateOrDeleteRestaurantReviewForm(request.form)
     # todo: assert not 2 fields are posted
     if form.archive.data is True:
         repo.archive_restaurant(g.restaurant)
         flash(
             f'Successfully Archived: <a href="{url_for("admin.restaurant_review", id=g.restaurant.id)}">{g.restaurant.name}</a>',
             category="success",
         )
         return redirect(url_for("admin.restaurant_reviews"))
     elif form.unarchive.data is True:
         repo.unarchive_restaurant(g.restaurant)
         flash(
             f'Successfully Unarchived: <a href="{url_for("admin.restaurant_review", id=g.restaurant.id)}">{g.restaurant.name}</a>',
             category="success",
         )
         return redirect(url_for("admin.restaurant_reviews"))
     elif form.delete.data is True:
         repo.delete_restaurant(g.restaurant)
         flash(
             f"Successfully Deleted: {g.restaurant.name}",
             category="success",
         )
         return redirect(url_for("admin.restaurant_reviews"))
     elif form.update.data is True and form.validate_on_submit():
         restaurant = Restaurant.from_form(form)
         repo.update_restaurant(restaurant)
         flash(
             f'Successfully Updated: <a href="{url_for("admin.restaurant_review", id=restaurant.id)}">{restaurant.name}</a>',
             category="success",
         )
         return redirect(url_for("admin.restaurant_reviews"))
     else:
         return self.render_template(form=form)
Exemple #12
0
def new_restaurant():
    if request.method == "POST":
        new_res = Restaurant(name=request.form['name'])
        db.session.add(new_res)
        db.session.commit()
        return redirect(url_for('show_restaurants'))
    else:
        return render_template('newRestaurant.html')
Exemple #13
0
 def _format_restaurant(self, restaurant):
     resto_dict = {'resto_id': restaurant['id'], 
                   'owner': self._user, 
                   'name': restaurant['name'], 
                   'latitude': restaurant['location']['lat'], 
                   'longitude': restaurant['location']['lng'],
                   'provider': PROVIDER_NAME}
     
     return Restaurant(**resto_dict)
Exemple #14
0
def add_restaurant():
    req_data = request.get_json()
    err = restaurant_schema.validate(req_data)
    if err:
        return jsonify(err), 400
    else:
        restaurant_dat, err = restaurant_schema.load(req_data)
        restaurant = Restaurant(**restaurant_dat)
        return db_add(restaurant, restaurant_schema)
Exemple #15
0
 def post(self):
     form = CreateRestaurantReviewForm(request.form)
     if form.validate_on_submit():
         restaurant = Restaurant.from_form(form)
         # slack.chat.post_message('created-restaurants', text=restaurant.query_string())
         repo.save_restaurant(restaurant)
         return redirect(url_for("blog.home"))
     else:
         return self.render_template("create_restaurant_review.html",
                                     form=form)
Exemple #16
0
def add_restaurant():
    user = current_user
    form = forms.NewRestaurant(request.form)
    if request.method == 'POST':
        new_restaurant = Restaurant(name=form.name.data, user_id=user.id)
        session.add(new_restaurant)
        session.commit()
        return redirect(url_for('list_restaurants'))

    return render_template('add_restaurant.html', form=form)
Exemple #17
0
def newRestaurant():
    if 'user' not in session:
        flash('Please login to create a new restaurant', 'error')
        return False
    if request.method == 'POST':
        newRestaurant = Restaurant(name=request.form['name'],
                                   user_id=session['user']['user_id'])
        db.session.add(newRestaurant)
        flash('New Restaurant %s Successfully Created' % newRestaurant.name)
        db.session.commit()
        return redirect(url_for('showRestaurants'))
    else:
        return flask.render_template('newRestaurant.html')
Exemple #18
0
def restaurantDetails(request):
    data = {'title': 'My Restaurant Details'}
    print("one")
    if request.method == "POST":
        name = request.POST.get('name')
        address1 = request.POST.get('address1', '')
        address2 = request.POST.get('address2', '')
        zip = request.POST.get('zip', '')
        tag = request.POST.get('tag', '')
        if not name:
            messages.error(request, 'cant save restaurant details')
            return redirect('restaurant_details')
        rest = Restaurant()
        try:
            rest = Restaurant.objects.create(user=request.user,
                                             name=name,
                                             address1=address1,
                                             address2=address2,
                                             zip=zip,
                                             tag=tag)
            messages.info(request, 'saved restaurant details')

        except IntegrityError:  #this error is generated on the loss of uniqueness of the assumed unique variable user
            rest = Restaurant.objects.get(user=request.user)
            rest.name = name
            rest.address1 = address1
            rest.address2 = address2
            rest.zip = zip
            rest.tag = tag
            rest.save()
            messages.info(request, 'updated restaurant details.')
        except:
            messages.info(
                request,
                'Loss of uniquness. Cant save restaurant details. Try again')

        return redirect('restaurant_details')

    data['rest'] = Restaurant.objects.filter(
        user=request.user).order_by('id').first()
    print(data['rest'])
    return render(request, 'partner/owner/restaurant_details.html',
                  processData(request, data))
Exemple #19
0
    def get(self):
        args = self.parser.parse_args()
        query = args.get('q')
        results = self.searcher.search(query)
        resp = []
        for r in results.get('businesses', {}):
            if not Restaurant.find_restaurant(r.get('name'), r.get('address')):
                resp.append({
                    'name': r.get('name'),
                    'url': r.get('url'),
                    'address': "|".join(r.get('location').get('display_address')),
                })

        return self.ok(resp)
Exemple #20
0
    def test_restaurant_model(self):
        """
        Test number of records in Restaurant table
        """

        # create test restaurant
        restaurant = Restaurant(name="The Med",
                                deal="Beerz fo dayz",
                                menu="www.pornhub.com")

        # save restaurant to database
        db.session.add(restaurant)
        db.session.commit()

        self.assertEqual(Restaurant.query.count(), 1)
Exemple #21
0
def addMarcos():
    u = User(username='******', email='*****@*****.**', password_hash='nba')
    db.session.add(u)
    restaurant = Restaurant(name='jajaja')
    review = Review(body='Awesome burritos', user_id=1, restaurant_id=1)
    playlist = List(name='Best plant based', header='yum', creator_id=1)
    ranked = Ranked_Member(ranking=5,
                           hook='best east broadway',
                           list_id=1,
                           restaurant_id=1)

    db.session.add(restaurant)
    db.session.add(review)
    db.session.add(playlist)
    db.session.add(ranked)

    db.session.commit()
Exemple #22
0
def add_want_to_go():
    if request.method == "POST":
        # validate form
        req = request.form
        missing = list()

        for k, v in req.items():
            if v == "":
                missing.append(k)

        if missing:
            feedback = f"Please fill fields: {', '.join(missing)}"

            return render_template(
                "add_want_to_go.html",
                title="Add Want To Go",
                feedback=feedback,
            )

        restaurant_in_database = [
            restaurant.name for restaurant in db.session.query(Restaurant)
        ]

        if request.form.get("name") in restaurant_in_database:
            feedback = f"You already have been in: {', '.join(missing)}"

            return render_template(
                "form.html",
                title="Add Visit",
                feedback=feedback,
            )

        restaurant = Restaurant(name=request.form.get("name"),
                                url=request.form.get("website"),
                                want_to_go=True)
        db.session.add(restaurant)
        db.session.commit()

        flash("Restaurant {} was added as want to go".format(
            request.form.get("name")))
        return redirect("/want_to_go")

    return render_template("add_want_to_go.html", title="Add Want To Go")
def add_restaurant():
    user = get_jwt_identity()
    if (re.search(regex, user)):
        data = request.get_json()
        name = data['restaurant']['name']
        description = data['restaurant']['description']
        createdAt = datetime.now()
        updatedAt = datetime.now()
        db.session.add(Restaurant(name, description, createdAt, updatedAt))
        db.session.commit()
        data = Restaurant.query.filter(Restaurant.name == name).first()
        restaurant = {
            "restaurant": {
                "id": data.id,
                "name": data.name,
                "description": data.description,
                "createdAt": data.createdAt,
                "updatedAt": data.updatedAt
            }
        }
        return jsonify(restaurant), 200
    else:
        return ('Only Admin can Add the Restaurant'), 403
Exemple #24
0
def seed_restaurants():

    joann = Restaurant(
        name='Joann\'s Fine Foods',
        description=
        'Joann’s Fine Foods is a South Congress neighborhood spot, a new take on the American diner, and a vacation for locals and tourists alike. Open early and late at the Austin Motel, Joann’s is a welcome respite for early birds and night owls, outlaws and in-laws, all ways always.',
        photo=
        'https://joannsaustin.com/wp-content/uploads/2018/10/MH_MMG_JOANNS_1568_FINAL-e1540241567159.jpg',
        address='1224 S Congress Ave',
        city='Austin',
        state='TX',
        zip_code='78704',
        lat="30.251772505429667",
        lng="-97.7491314024451",
        phone="5123586054",
        menu="https://joannsaustin.com/menus-hours/")

    db.session.add(joann)

    db.session.commit()

    lucky = Restaurant(
        name='Lucky Robot',
        description=
        'Hip option for Tokyo-inspired street fare including Asian tacos, sushi & dumplings, plus sake punch.',
        photo=
        'https://www.luckyrobotatx.com/spillover/proto/luckyrobotatx/images/design/promo6.jpg',
        address='1303 S Congress Ave',
        city='Austin',
        state='TX',
        zip_code='78704',
        lat="30.25093840149734",
        lng="-97.74901338525792",
        phone="5124448081",
        menu="https://www.luckyrobotatx.com/images/LuckyRobotMenu.pdf")

    db.session.add(lucky)

    db.session.commit()

    marker10 = Restaurant(
        name='Marker 10 Spirits and Cuisine',
        description=
        'Cocktails, sushi & bar bites served in a posh lounge featuring a patio with lake views at the Hyatt.',
        photo='https://resizer.otstatic.com/v2/photos/wide-huge/1/26369987.jpg',
        address='208 Barton Springs Rd',
        city='Austin',
        state='TX',
        zip_code='78704',
        lat="30.261064352407683",
        lng="-97.74743137360971",
        phone="5124771234",
        menu="http://places.singleplatform.com/marker-10/menu#menu_1763293")

    db.session.add(marker10)

    db.session.commit()

    cityO = Restaurant(
        name='City O\' City',
        description=
        'Bohemian hangout dishing up high-concept vegetarian fare to meat & plant eaters alike.',
        photo=
        'https://custombyrushton.com/w/wp-content/uploads/2015/04/city-o-city-vegetarian-restaurant-denver_1.jpg',
        address='206 E 13th Ave',
        city='Denver',
        state='CO',
        zip_code='80203',
        lat="39.73686403703116",
        lng="-104.98463530223482",
        phone="3038316443",
        menu="http://cityocitydenver.com/menu")

    db.session.add(cityO)

    db.session.commit()

    osaka = Restaurant(
        name='Osaka Ramen',
        description=
        'Busy restaurant & bar specializing in ramen bowls plus other Japanese food in a playful setting.',
        photo=
        'https://assets.simpleviewinc.com/simpleview/image/fetch/q_75/https://assets.simpleviewinc.com/simpleview/image/upload/crm/denver/osaka-ramen-cb7d030dede0c78_cb7d03ef-0096-9fed-3e04b4469eae13a8.jpg',
        address='2611 Walnut St',
        city='Denver',
        state='CO',
        zip_code='80205',
        lat="39.75968772727945",
        lng="-104.98608384456384",
        phone="3039557938",
        menu="http://osakaramendenver.com/menu")

    db.session.add(osaka)

    db.session.commit()

    barcelona = Restaurant(
        name='Barcelona Wine Bar',
        description=
        'Tapas, paella & an extensive list of Spanish wines on offer amid quaint-meets-industrial decor.',
        photo=
        'https://barcelonawinebar.com/media/Screen-Shot-2018-04-02-at-4.24.37-PM.png',
        address='2900 Larimer St',
        city='Denver',
        state='CO',
        zip_code='80205',
        lat="39.761490980261954",
        lng="-104.98131768689338",
        phone="3038163300",
        menu=
        "https://barcelonawinebar.com/media/Rino-Dinner-Menu-2.14.2021-VALENTINES-WEEKEND.pdf"
    )

    db.session.add(barcelona)

    db.session.commit()

    kamonegi = Restaurant(
        name='kamonegi',
        description=
        'Pocket-sized space specializing in handmade soba noodles, tempura & other Japanese specialties.',
        photo=
        'https://cdn.vox-cdn.com/thumbor/KPFCra3K9ZyTwKLBaOJRN2cc4G8=/0x0:2000x1334/1200x800/filters:focal(840x507:1160x827)/cdn.vox-cdn.com/uploads/chorus_image/image/57142447/Pratt_Kamonegi_017.0.jpg',
        address='1054 N 39th St',
        city='Seattle',
        state='WA',
        zip_code='98103',
        lat="47.654173311085216",
        lng="-122.34428170201583",
        phone="2066320185",
        menu="https://www.kamonegiseattle.com/menus/")

    db.session.add(kamonegi)

    db.session.commit()

    junebaby = Restaurant(
        name='Junebaby',
        description=
        'Classic Southern fare made with heirloom ingredients is served in a stylish locale with cocktails.',
        photo=
        'https://cdn.vox-cdn.com/thumbor/2QuzoRBdEK8jcGAECGV2LLKvlP8=/0x0:2000x1333/1200x675/filters:focal(840x507:1160x827)/cdn.vox-cdn.com/uploads/chorus_image/image/54460701/Pratt_Junebaby_56.0.jpg',
        address='2122 NE 65th St',
        city='Seattle',
        state='WA',
        zip_code='98115',
        lat="47.67608156256543",
        lng="-122.30418100201531",
        phone="2062574470",
        menu="http://places.singleplatform.com/junebaby/menu#menu_2827558")

    db.session.add(junebaby)

    db.session.commit()

    fats = Restaurant(
        name='Fat\'s Chicken and Waffles',
        description=
        'Small, stylish cafe offers Southern favorites such as chicken & waffles and catfish & greens.',
        photo=
        'http://fatschickenandwaffles.com/wp-content/themes/1140FluidStarkers/images/about-bk.jpg',
        address='2726 E Cherry St',
        city='Seattle',
        state='WA',
        zip_code='98122',
        lat="47.60836081263612",
        lng="-122.29640408667647",
        phone="2066026863",
        menu="http://fatschickenandwaffles.com/menu/")

    db.session.add(fats)

    db.session.commit()
Exemple #25
0
from app import db
from app.models import Restaurant, MenuItem, User

# Create dummy user
User1 = User(
    name="Robo Barista",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)
db.session.add(User1)
db.session.commit()

# Menu for UrbanBurger
restaurant1 = Restaurant(user_id=1, name="Urban Burger")

db.session.add(restaurant1)
db.session.commit()

menu_items1 = [
    MenuItem(
        user_id=1,
        name="Veggie Burger",
        description="Juicy grilled veggie patty with tomato mayo and lettuce",
        price="$7.50",
        course="Entree",
        restaurant=restaurant1),
    MenuItem(user_id=1,
             name="French Fries",
             description="with garlic and parmesan",
             price="$2.99",
Exemple #26
0
def populate_db():
    zomato_json = load_json('rest_api_info_v2.json')
    restaurant_info = zomato_json['restaurant']
    city_info = zomato_json['city']
    cuisine_info = zomato_json['cuisine']
    #populate the restaurant table
    c_row = 0  #Cuisine junct row
    h_row = 0  #Highlight junct row
    for r in restaurant_info:
        #Assumed non-nullable info
        rest_id = r['rest_id']
        name = r['name']
        price_per_two = r['price_per_two']
        rating = r['rating']
        #Iterate through cuisines and add to junction table
        rest_cuisines = r['cuisine']
        for c in rest_cuisines:
            e_c_row = Establishment_Cuisine_Junct(row_id=c_row,
                                                  rest_id=rest_id,
                                                  cuisine=c)
            db.session.add(e_c_row)
            db.session.commit()
            c_row = c_row + 1
        locality = r['locality']
        city = r['city']

        #Potentially nullable information
        state = r['state']
        address = r['address']
        if r['menu'] != "":
            menu = r['menu']
        else:
            menu = None
        if r['hours'] != "":
            hours = r['hours']
        else:
            hours = None
        if r['coordinates'] != "":
            coordinates = r['coordinates']
        else:
            coordinates = None
        price_rating = r['price']
        if r['thumbnail_url'] != "":
            thumbnail_url = r['thumbnail_url']
        else:
            thumbnail_url = None
        if r['featured_image'] != "":
            featured_image = r['featured_image']
        else:
            featured_image = None
        if r['phone'] != "":
            phone = r['phone']
        else:
            phone = None
        if r['cuisine']:
            cuisine = r['cuisine'][0]
        else:
            cuisine = None
        #Iterate through highlights and add to junction table
        #for h in r['highlights']:
        #	e_h_row = Establishment_Highlights(row_id = h_row, rest_id = rest_id, highlight = h)
        #	db.session.add(e_h_row)
        #	db.session.commit()
        #	h_row = h_row + 1

        new_establishment = Restaurant(name=name,
                                       price_per_two=price_per_two,
                                       rating=rating,
                                       city=city,
                                       locality=locality,
                                       rest_id=rest_id,
                                       state=state,
                                       address=address,
                                       menu=menu,
                                       hours=hours,
                                       coordinates=coordinates,
                                       price_rating=price_rating,
                                       thumbnail_url=thumbnail_url,
                                       featured_image=featured_image,
                                       phone=phone,
                                       cuisine=cuisine)

        db.session.add(new_establishment)
        db.session.commit()

    c_row = 0  #City_Cuisine row
    pc_row = 0  #Popular cuisinces row
    pr_row = 0  #Popular restaurant row
    loc_row = 0  #Locality row
    city_table_row = 0
    for c in city_info:
        #Assumed non-nullable info
        city_id = c['city_id']
        name = c['name']
        #Fill out locality table
        for n in c['neighborhood']:
            loc_row += 1
            nbhd = Locality(id=loc_row, name=n, city=name)
            db.session.add(nbhd)
            db.session.commit()
        score = c['score']
        #Fill out city_cuisines table
        for cuisine in c['cuisine']:
            cuisine_row = City_Cuisine(row_id=c_row,
                                       city_name=name,
                                       cuisine_name=cuisine)
            db.session.add(cuisine_row)
            db.session.commit()
            c_row = c_row + 1

        #Potentially nullable information
        nightlife_index = c['nightlife_index'] if c[
            'nightlife_index'] else 'N/A'
        num_restaurants = c['num_restaurants'] if c[
            'num_restaurants'] else 'N/A'
        country = c['country'] if c['cuisine'] else 'N/A'
        c_cuisine = c['cuisine'][0] if c['cuisine'] else 'N/A'
        #Fill our popular cuisine junct table
        for cuisine in c['popular_cuisines']:
            pc = City_Popular_Cuisine_Junct(row_id=pc_row,
                                            city_name=name,
                                            cuisine=cuisine)
            db.session.add(pc)
            db.session.commit()
            pc_row = pc_row + 1
        #Fill out our popular restaurants junct table
        for r in c['popular_restaurants']:
            pr = City_Popular_Restaurant_Junct(row_id=pr_row,
                                               rest_id=r,
                                               city_name=name)
            db.session.add(pr)
            db.session.commit()
            pr_row = pr_row + 1

        new_city = City(name=name,
                        score=score,
                        nightlife_index=nightlife_index,
                        city_id=city_id,
                        num_restaurants=num_restaurants,
                        country=country,
                        cuisine=c_cuisine)
        db.session.add(new_city)
        db.session.commit()

        #Construct the city table info
        est_list = c['establishment'].copy()
        counter = 0
        while len(est_list) != 0 and counter != len(restaurant_info):
            r = restaurant_info[counter]
            if r['rest_id'] in est_list:
                nbhd = r['locality']
                if len(r['cuisine']) != 0:
                    cuis = r['cuisine'][0]
                else:
                    cuis = ""
                new_row = City_Table(row_id=city_table_row,
                                     city_name=name,
                                     nbhd=nbhd,
                                     establishment=r['name'],
                                     cuisine=cuis,
                                     score=score)
                city_table_row = city_table_row + 1
                est_list.remove(r['rest_id'])
                db.session.add(new_row)
                db.session.commit()
            counter = counter + 1

    cuisine_table_row = 0
    for c in cuisine_info:
        #Assumed non-nullable info
        name = c['name']
        #Average the price
        l = len(c['price'])
        s = 0
        for p in c['price']:
            s = s + float(p)
        if l == 0:
            avg_price_rating = "N/A"
        else:
            avg_price_rating = str(s / l)
        #Average the rating
        l = len(c['rating'])
        s = 0
        for r in c['rating']:
            s = s + float(r)
        if l == 0:
            avg_rating = "N/A"
        else:
            avg_rating = str(s / l)
        # get id of restaurant
        c_rest_id = c['establishment'][0] if c['establishment'] else "N/A"
        # get name of restaurant
        c_rest = ''
        if c_rest_id == 'N/A':
            c_rest = 'N/A'
        else:
            for r in restaurant_info:
                if r['rest_id'] == c_rest_id:
                    c_rest = r['name']
                    break
        c_city = ''
        for c in city_info:
            if name in c['cuisine']:
                c_city = c['name']
                break
        new_cuisine = Cuisine(name=name,
                              avg_price_rating=avg_price_rating,
                              avg_rating=avg_rating,
                              rest_id=c_rest_id,
                              rest_name=c_rest,
                              city=c_city)
        db.session.add(new_cuisine)
        db.session.commit()
        """shouldn't need anymore
Exemple #27
0
def add_rating():
    if request.method == "POST":
        # validate form
        req = request.form
        missing = list()

        for k, v in req.items():
            if v == "":
                missing.append(k)

        if missing:
            feedback = f"Please fill fields: {', '.join(missing)}"
            restaurant_in_database = [
                restaurant.name for restaurant in db.session.query(Restaurant)
            ]
            if len(restaurant_in_database) == 0:
                restaurant_in_database = ["No restaurant added yet."]
            return render_template(
                "form.html",
                title="Add Visit",
                feedback=feedback,
                restaurants=restaurant_in_database,
            )

        # add data to database
        restaurant_in_database = (db.session.query(Restaurant).filter_by(
            name=request.form.get("name")).first())

        if not restaurant_in_database:
            restaurant = Restaurant(name=request.form.get("name"),
                                    url=request.form.get("url"),
                                    want_to_go=False)
            db.session.add(restaurant)
            db.session.commit()
            restaurant_in_database = (db.session.query(Restaurant).filter_by(
                name=request.form.get("name")).first())
        elif restaurant_in_database.want_to_go:
            restaurant_in_database.want_to_go = False
            db.session.commit()

        restaurant_id = restaurant_in_database.id

        rating = Rating(
            taste=request.form.get("taste_rating"),
            delivery=request.form.get("delivery_rating"),
            spiciness=request.form.get("spiciness_rating"),
            restaurant_id=restaurant_id,
        )
        db.session.add(rating)
        db.session.commit()

        flash("Visit in restaurant {} has been added 🕉".format(
            request.form.get("name")))
        return redirect("/")

    restaurant_in_database = [
        restaurant.name for restaurant in db.session.query(Restaurant)
    ]
    if len(restaurant_in_database) == 0:
        restaurant_in_database = ["No restaurant added yet."]

    return render_template("form.html",
                           title="Add Visit",
                           restaurants=restaurant_in_database)
Exemple #28
0
# Make a request to the API
response = requests.get(url=BUSINESS_ENDPOINT,
                        params=PARAMETERS,
                        headers=HEADERS)

# Converts the json string to a dictionary
category_data = response.json()

# add restaurants to database
for restaurant in category_data['businesses']:
    # print(restaurant['name'], restaurant['location']['display_address'], restaurant['id'])

    existing_restaurant = Restaurant.query.get(restaurant['id'])
    if not existing_restaurant:
        r = Restaurant(id=restaurant['id'],
                       name=restaurant['name'],
                       address=restaurant['location']['address1'],
                       price=restaurant['price'])
        db.session.add(r)
        db.session.commit()
        print('I have added the restaurants to the database')

#check the database to see if the restuarant was added


@api.route('/')
def displayWelcomePage():
    return render_template('base.html')


@login_required
@api.route('/feed')
Exemple #29
0
def test():
	restaurant = Restaurant()
	query = restaurant.order()
	return query
Exemple #30
0
def restaurantsJSON():
    restaurants = Restaurant.all()
    return jsonify(restaurants=[r.serialize for r in restaurants])
Exemple #31
0
def seed_restaurants():

    fast = Cuisine.query.get(1)
    asian = Cuisine.query.get(2)
    burgers = Cuisine.query.get(3)
    chinese = Cuisine.query.get(4)
    healthy = Cuisine.query.get(5)
    breakfast = Cuisine.query.get(6)
    thai = Cuisine.query.get(7)
    chicken = Cuisine.query.get(8)
    mexican = Cuisine.query.get(9)
    japanese = Cuisine.query.get(10)
    italian = Cuisine.query.get(11)
    pizza = Cuisine.query.get(12)

    popular = Tag.query.get(1)
    national_favorites = Tag.query.get(2)
    lunch = Tag.query.get(3)
    culture = Tag.query.get(4)

    # 1
    panda = Restaurant(name='Panda Express', address='5150 Cherry Ave, San Jose, CA 95118', 
        description="Fast-food chain for Chinese standards, including some health-conscious options.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/42492.jpg")
    panda.cuisines.append(chinese)
    panda.cuisines.append(asian)
    panda.tags.append(culture)
    panda.tags.append(national_favorites)
    panda.tags.append(popular)
    panda.tags.append(lunch)
    db.session.add(panda)

    #2
    mcd = Restaurant(name='McDonald\'s', address='1365 Blossom Hill Rd, San Jose, CA 95118', 
        description="Classic, long-running fast-food chain known for its burgers, fries & shakes.", 
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/5579.png")
    mcd.cuisines.append(fast)
    mcd.cuisines.append(burgers)
    mcd.tags.append(national_favorites)
    mcd.tags.append(lunch)
    mcd.tags.append(popular)
    db.session.add(mcd)

    #3
    poki = Restaurant(name='Poki Time', address='2101 Lombard St, San Francisco, CA 94123', 
        description="Hawaiian poke bowls are made-to-order at this local chain link also serving a range of desserts.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/349186.jpg")
    poki.cuisines.append(healthy)
    poki.cuisines.append(asian)
    poki.cuisines.append(japanese)
    poki.tags.append(culture)
    poki.tags.append(popular)
    db.session.add(poki)

    #4
    tony = Restaurant(name='Tony\'s Pizza Napoletana', address='1570 Stockton St, San Francisco, CA 94133', 
        description="Bustling Italian eatery with varied pizza options from coal-fired to Roman-style, plus beer on tap.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/193224.jpg")
    tony.cuisines.append(pizza)
    tony.cuisines.append(italian)
    tony.tags.append(culture)
    db.session.add(tony)

    #5
    kfc = Restaurant(name='Kentucky Fried Chicken', address='691 Eddy St, San Francisco, CA 94109', 
        description="Fast-food chain known for its buckets of fried chicken, plus wings & sides.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/1e869531-be3a-4c1a-a4c1-271e81113b1e.jpg")
    kfc.cuisines.append(chicken)
    kfc.cuisines.append(fast)
    kfc.tags.append(national_favorites)
    db.session.add(kfc)

    #6
    honey = Restaurant(name='Honey Honey Cafe & Crepery', address='599 Post St, San Francisco, CA 94102', 
        description="Diners order at the counter at this casual, cheery spot that cooks up a mix of crêpes & cafe fare.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/fa17869e-208a-4604-94e8-81b2bf70fd4f.466")
    honey.cuisines.append(breakfast)
    db.session.add(honey)

    #7
    smash = Restaurant(name='Smashburger', address='2300 16th St Suite 293, San Francisco, CA 94103', 
        description="Counter-serve chain featuring signature smashed burgers, plus sides & shakes.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/43726.jpg")
    smash.cuisines.append(burgers)
    smash.cuisines.append(fast)
    smash.tags.append(national_favorites)
    smash.tags.append(lunch)
    db.session.add(smash)

    #8
    subway = Restaurant(name='Subway', address='550B C St, San Francisco, CA 94158', 
        description="Casual counter-serve chain for build-your-own sandwiches & salads, with health-conscious options.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/3720.jpg")
    subway.cuisines.append(fast)
    subway.cuisines.append(healthy)
    subway.tags.append(popular)
    subway.tags.append(lunch)
    subway.tags.append(national_favorites)
    db.session.add(subway)

    #9
    hinodeya = Restaurant(name='Hinodeya Ramen Downtown', address='680 Clay St, San Francisco, CA 94111', 
        description="",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/9d75fc4f-44b7-485e-82df-4204916745af.JPG")
    hinodeya.cuisines.append(asian)
    hinodeya.cuisines.append(japanese)
    hinodeya.tags.append(culture)
    db.session.add(hinodeya)

    #10
    lers = Restaurant(name='Lers Ros Thai', address='730 Larkin St, San Francisco, CA 94109', 
        description="Popular late-night Thai spot with long menu of exotic game specials & more traditional Thai dishes.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/21157.jpg")
    lers.cuisines.append(thai)
    lers.cuisines.append(asian)
    lers.tags.append(culture)
    db.session.add(lers)

    #11
    chipotle = Restaurant(name='Chipotle', address='211 Sutter St, San Francisco, CA 94104', 
        description="Fast-food chain offering Mexican fare, including design-your-own burritos, tacos & bowls.",
        image_url="https://img.cdn4dd.com/cdn-cgi/image/fit=contain,width=1920,format=auto,quality=50/https://cdn.doordash.com/media/store/header/8b48c653-0eca-40bb-8e47-6fd4ac0f75b5.jpg")
    chipotle.cuisines.append(mexican)
    chipotle.cuisines.append(healthy)
    chipotle.tags.append(lunch)
    chipotle.tags.append(national_favorites)
    chipotle.tags.append(popular)
    db.session.add(chipotle)

    db.session.commit()
Exemple #32
0
def seed_restaurants():
    genre1 = Genre(
        name="Cakes",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/flat+version+svg+slice+of+cake-1319964486387545161.png"
    )
    genre2 = Genre(name="Cupcakes",
                   img_src="https://img.icons8.com/plasticine/2x/cupcake.png")
    genre3 = Genre(
        name="Pies",
        img_src="https://iconarchive.com/download/i99743/sonya/swarm/Pie.ico")
    genre4 = Genre(
        name="Chocolate",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/Chocolate-1320568040315110190.png"
    )
    genre5 = Genre(
        name="Candy",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/flat+version+svg+candy-1319964483174784523.png"
    )
    genre6 = Genre(
        name="Ice Cream",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/flat+version+svg+ice+cream-1319964483943937255.png"
    )
    genre7 = Genre(
        name="Donuts",
        img_src=
        "https://freepngimg.com/download/grocery/55063-3-pink-donut-photos-download-hd-png.png"
    )
    genre8 = Genre(
        name="Pastries",
        img_src=
        "https://iconarchive.com/download/i107463/google/noto-emoji-food-drink/32372-croissant.ico"
    )
    genre9 = Genre(
        name="Gelato",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/linecolor+version+svg+ice+cream-1319964494028526965.png"
    )
    genre10 = Genre(
        name="Vegan",
        img_src="https://img.icons8.com/plasticine/2x/vegan-symbol.png")
    genre11 = Genre(
        name="Cookies",
        img_src=
        "https://icons-for-free.com/iconfiles/png/512/cookie-1319971784454690183.png"
    )

    restaurant1 = Restaurant(
        name="Nothing Bundt Cakes",
        description=
        "Bakery chain with bundt cakes ranging from bite-sized to tiered, plus platters, candles & cards.",
        address=" 2785 Bee Cave Rd",
        city="Austin",
        state="TX",
        zip_code="78746",
        lat=30.274082967865112,
        lng=-97.78770001461015,
        hours="9:00AM - 6:00PM",
        price="$$",
        rating=4.8,
    )
    restaurant2 = Restaurant(
        name="Paper Route Bakery",
        description=
        "Small batch artisanal bakery homegrown here in Austin! Homemade delicacies, organic & local ingredients.",
        address="1835 W Alambama St",
        city="Austin",
        state="TX",
        zip_code="78702",
        lat=30.261396556115916,
        lng=-97.73375683068825,
        hours="8:00AM - 4:00PM",
        price="$",
        rating=4.9,
    )
    restaurant3 = Restaurant(
        name="Sugar Mama's Bakeshop",
        description=
        "Well-known bakery offering cupcakes, cookies, bars & mini-pies in a vintage space with a few seats.",
        address="1905 S 1st St",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.24722791833769,
        lng=-97.75662594603243,
        hours="10:00AM - 7:00PM",
        price="$",
        rating=4.3,
    )
    restaurant4 = Restaurant(
        name="Capital City Bakery",
        description=
        "Local bakery preparing all-vegan treats including cupcakes, brownies & special-occasion cakes.",
        address="2211 E Cesar Chavez St",
        city="Austin",
        state="TX",
        zip_code="78702",
        lat=30.25627587968311,
        lng=-97.72009946137655,
        hours="10:00AM - 6:00PM",
        price="$",
        rating=4.7,
    )
    restaurant5 = Restaurant(
        name="Word of Mouth Bakery",
        description=
        "Word of Mouth Bakery is an Austin Bakery with a cafe menu that features breakfast sandwiches, pastries, muffins, cookies, cake by the slice, cupcakes, salads, sandwiches, and a catering to go menu. Let us do the cooking!",
        address="917 W 12th St",
        city="Austin",
        state="TX",
        zip_code="78703",
        lat=30.27756356269626,
        lng=-97.7507719,
        hours="10:00AM - 4:00PM",
        price="$$",
        rating=4.7,
    )
    restaurant6 = Restaurant(
        name="Hayleycakes and Cookies",
        description=
        "Petite stop-in for sweet treats, from inventive cupcakes to cookies, plus special-occasion cakes.",
        address="1700 S Lamar Blvd",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.251858996097788,
        lng=-97.76640427672069,
        hours="7:00AM - 7:00PM",
        price="$$",
        rating=4.3,
    )
    restaurant7 = Restaurant(
        name="Manolis Ice Cream Pastries & Cakes",
        description=
        "Housemade ice cream, popsicles & pastries are doled out at this busy food truck with outdoor tables",
        address="603 W Live Oak St",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.245213622657094,
        lng=-97.75797916931172,
        hours="2:00PM - 11:00PM",
        price="$",
        rating=4.9,
    )
    restaurant8 = Restaurant(
        name="Whole Foods",
        description=
        "We believe in the best, from our kitchens to your table. From our cult-favorite Berry Chantilly Cake to wholesome Seeduction Bread, our baked goods are made with unbleached, unbromated flour and cage-free or better eggs — and we don’t use hydrogenated fats or high-fructose corn syrup.",
        address="525 N Lamar Blvd",
        city="Austin",
        state="TX",
        zip_code="78703",
        lat=30.270744292416065,
        lng=-97.75320356423829,
        hours="7:00AM - 9:00PM",
        price="$$$",
        rating=4.5,
    )
    restaurant9 = Restaurant(
        name="Polkadots Cupcake Factory",
        description=
        "Cheery bakery crafting cupcakes in creative flavors, plus made-to-order cakes & hand-iced cookies.",
        address="2826 Rio Grande St",
        city="Austin",
        state="TX",
        zip_code="78705",
        lat=30.296683931389214,
        lng=-97.74425971534413,
        hours="7:00AM - 9:00PM",
        price="$",
        rating=4.3,
    )
    restaurant10 = Restaurant(
        name="Hey Cupcake!",
        description=
        "Cupcakes are the draw at this whimsical shop operating out of a parked trailer with outdoor seating.",
        address="1511 S Congress Ave",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.24935067782933,
        lng=-97.74942885396759,
        hours="11:00AM - 9:00PM",
        price="$",
        rating=4.1,
    )
    restaurant11 = Restaurant(
        name="Zucchini Kill Bakery",
        description=
        "Punk rock, female-led bakery serving vegan sweet & savory goods that are also soy & gluten-free.",
        address="701 E 53rd S",
        city="Austin",
        state="TX",
        zip_code="78751",
        lat=30.316314014490814,
        lng=-97.71660398465573,
        hours="3:00PM - 8:00PM",
        price="$$",
        rating=4.8,
    )
    restaurant12 = Restaurant(
        name="Tiny Pies",
        description=
        "Handmade by Scratch Daily Using Traditional Baking Methods and Natural Ingredients. Made fresh Daily!",
        address="2032 S Lamar Blvd",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.250212425241358,
        lng=-97.7687649,
        hours="8:00AM - 8:00PM",
        price="$$",
        rating=4.5,
    )
    # restaurant13 = Restaurant(name="Quack's 43rd Street Bakery",
    #                     description="Quack’s line of bakery products grew out of a need to provide freshly baked goods for our customers. All the baked items sold here are made here from scratch. We use high quality, natural ingredients. We do not use frozen dough or mixes. Our bakery products contain no preservatives, high fructose corn syrups or additives. We provide service to many wholesale accounts that elect to serve their customers better quality baked goods in lieu of more commonly available, less expensive commercial products",
    #                     address="411 E 43rd St",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78751",
    #                     lat=30.30534896953304,
    #                     lng=-97.72654048465586,
    #                     hours="7:00AM - 9:00PM",
    #                     price="$",
    #                     rating=4.6,
    #                     )
    restaurant13 = Restaurant(
        name="The Cake and Spoon",
        description=
        "The Cake and Spoon is a wholesale and special order bakery concentrating on English, American, and European desserts and pastries.",
        address="3008 Gonzales St",
        city="Austin",
        state="TX",
        zip_code="78702",
        lat=30.250212425241358,
        lng=-97.7687649,
        hours="8:00AM - 1:00PM",
        price="$",
        rating=4.6,
    )
    restaurant14 = Restaurant(
        name="Upper Crust Bakery",
        description=
        "Well-known bakery with a cozy ambiance selling made-from-scratch pastries, bread & lunch fare.",
        address="4508 Burnet Rd",
        city="Austin",
        state="TX",
        zip_code="78756",
        lat=30.31652058929442,
        lng=-97.7415639,
        hours="7:00AM - 3:00PM",
        price="$",
        rating=4.6,
    )
    # restaurant16 = Restaurant(name="Big Top",
    #                     description="Colorful, circus-themed sweets store featuring old-school confections & a soda fountain.",
    #                     address="1706 S Congress Ave",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78704",
    #                     lat=30.247915810809495,
    #                     lng=-97.7508139232793,
    #                     hours="11:00AM - 6:00PM",
    #                     price="$$",
    #                     rating=4.6,
    #                     )
    restaurant15 = Restaurant(
        name="Edis Chocolates",
        description=
        "Locally owned shop creating specialty chocolates, cakes, cookies, pastries & other confections.",
        address="3808 Spicewood Springs Rd",
        city="Austin",
        state="TX",
        zip_code="78759",
        lat=30.365796276705574,
        lng=-97.74900098465586,
        hours="10:00AM - 5:00PM",
        price="$$",
        rating=4.8,
    )
    # restaurant18 = Restaurant(name="Delysia Chocolatier",
    #                     description="Our chocolates are handcrafted in Austin, Texas at our Culinary Center & Chocolate Boutique. Many include unique, local ingredients that are not available anywhere else. Relish in our passion for creating the finest quality and most unique chocolates available.",
    #                     address="2000 Windy Terrace",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78726",
    #                     lat=30.461966325891236,
    #                     lng=-97.83330320740897,
    #                     hours="12:00PM - 4:00PM",
    #                     price="$",
    #                     rating=4.7,
    #                     )
    # restaurant19 = Restaurant(name="Yummi Joy",
    #                     description="Craft sodas, mix-and-match candy, & coffee, plus vegan ice cream in playful, cartoon-ish surrounds.",
    #                     address="409 W 2nd St",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78701",
    #                     lat=30.265914420466785,
    #                     lng=-97.74820453068827,
    #                     hours="11:00AM - 7:00PM",
    #                     price="$",
    #                     rating=4.6,
    #                     )
    restaurant16 = Restaurant(
        name="Madhu Chocolate",
        description=
        "Austin made small batch chocolate bars with an emphasis on unique Indian flavors.",
        address="6814 Northeast Dr",
        city="Austin",
        state="TX",
        zip_code="78723",
        lat=30.31936931469751,
        lng=-97.6804175,
        hours="10:00AM - 2:00PM",
        price="$",
        rating=5.0,
    )
    restaurant17 = Restaurant(
        name="Lammes Candies",
        description=
        "Austin's hometown candy store and home of the world-famous Texas Chewie® Pecan Praline. ",
        address="2927 W Anderson Ln",
        city="Austin",
        state="TX",
        zip_code="78757",
        lat=30.359302551025714,
        lng=-97.73851866983784,
        hours="11:00AM - 5:30PM",
        price="$",
        rating=4.6,
    )
    restaurant18 = Restaurant(
        name="IT'SUGAR",
        description=
        "IT'SUGAR is a trendy candy store specializing in innovative sweets, fun novelty gifts, and giant candy.",
        address="11621 Rock Rose Ave",
        city="Austin",
        state="TX",
        zip_code="78758",
        lat=30.40295485903219,
        lng=-97.72194801177815,
        hours="12:00PM - 8:00PM",
        price="$",
        rating=4.2,
    )
    restaurant19 = Restaurant(
        name="See's Candies",
        description=
        "Candies & chocolates are sold by the piece or box at this old-school chain, in business since 1921.",
        address="10710 Research Blvd",
        city="Austin",
        state="TX",
        zip_code="78759",
        lat=30.399847844610722,
        lng=-97.74799219259104,
        hours="9:00AM - 7:30PM",
        price="$",
        rating=4.9,
    )
    # restaurant24 = Restaurant(name="Amy's Ice Creams",
    #                     description="Local chain serving inventive ice creams, milkshakes, ices & frozen yogurts with clever fixings.",
    #                     address="1301 S Congress Ave",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78704",
    #                     lat=30.25218564971291,
    #                     lng=-97.74876643862343,
    #                     hours="11:00AM - 11:00PM",
    #                     price="$",
    #                     rating=4.5,
    #                     )
    restaurant20 = Restaurant(
        name="Jeni's Splendid Ice Creams",
        description=
        "Chain scooping creative flavors of ice cream & frozen yogurt made from local ingredients.",
        address="1208 S Congress Ave",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.252835459387956,
        lng=-97.74918206137656,
        hours="12:00PM - 10:00PM",
        price="$$",
        rating=4.6,
    )
    restaurant21 = Restaurant(
        name="Dolce Neve Gelato",
        description=
        "Busy gelato shop whipping up various inventive flavors of ice cream in a pint-sized setting.",
        address="1713 S 1st St",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.248419896043455,
        lng=-97.75562374603243,
        hours="12:00PM - 9:00PM",
        price="$",
        rating=4.7,
    )
    restaurant22 = Restaurant(
        name="Lick Honest Ice Creams",
        description=
        "This hip ice creamery churns out offbeat flavors made from local, natural & sustainable ingredients.",
        address="1100 S Lamar Blvd",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.256305291156544,
        lng=-97.76265934603252,
        hours="12:00PM - 10:00PM",
        price="$$",
        rating=4.6,
    )
    restaurant23 = Restaurant(
        name="NadaMoo! Scoop Shop",
        description=
        "Festive counter-serve featuring homemade, dairy-free ice cream in traditional & seasonal flavors.",
        address="1701 S Lamar Blvd",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.25144088571262,
        lng=-97.76563339206633,
        hours="2:00PM - 10:00PM",
        price="$",
        rating=4.6,
    )
    restaurant24 = Restaurant(
        name="Sweet Ritual",
        description=
        "Colorful ice cream parlor serving gluten-free & vegan scoops in cups, cones, shakes & sundaes.",
        address="4631 Airport Blvd",
        city="Austin",
        state="TX",
        zip_code="78751",
        lat=30.30738290616657,
        lng=-97.71527361534415,
        hours="12:00PM - 10:00PM",
        price="$",
        rating=4.7,
    )
    restaurant25 = Restaurant(
        name="Voodoo Doughnut",
        description=
        "This counter-serve bakeshop serves creative donuts in colorful, quirky environs.",
        address="212 E 6th St",
        city="Austin",
        state="TX",
        zip_code="78701",
        lat=30.268674458003204,
        lng=-97.74110379206493,
        hours="8:00AM - 12:00AM",
        price="$",
        rating=4.4,
    )
    # restaurant31 = Restaurant(name="Little Lucy's",
    #                     description="Colorful, late-night food truck making mini-donuts with creative flavors, toppings & dipping sauces.",
    #                     address="75 1/2 Rainey St",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78701",
    #                     lat=30.25933696827229,
    #                     lng=-97.73863651534413,
    #                     hours="5:00PM - 2:00AM",
    #                     price="$",
    #                     rating=4.4,
    #                     )
    restaurant26 = Restaurant(
        name="Gourdough's Big. Fat. Donuts.",
        description=
        "Gourdough's Big. Fat. Donuts. is housed in a vintage Airstream Trailer located on South Lamar and doles out the most delectable and crazy donut concoctions your mind and taste buds will allow.",
        address="1503 S 1st St",
        city="Austin",
        state="TX",
        zip_code="78704",
        lat=30.25056331384392,
        lng=-97.75472767114883,
        hours="10:00AM - 12:00AM",
        price="$",
        rating=4.7,
    )
    restaurant27 = Restaurant(
        name="Julie Myrtille Bakery",
        description=
        "Authentic French bakery and fine pastry in Austin founded by French pastry chef Julie Myrtille. Bake the world a better place.",
        address="1023 Springdale Rd",
        city="Austin",
        state="TX",
        zip_code="78721",
        lat=30.26853112905222,
        lng=-97.69396151534413,
        hours="8:30AM - 2:00PM",
        price="$$",
        rating=4.7,
    )
    restaurant28 = Restaurant(
        name="Milky Way Shakes",
        description=
        "Milky Way Shakes, a vegan milkshake trailer located in Austin, TX.",
        address="2324 E Cesar Chavez St",
        city="Austin",
        state="TX",
        zip_code="78702",
        lat=30.255831594732026,
        lng=-97.71826961534413,
        hours="5:00PM - 10:00PM",
        price="$",
        rating=4.9,
    )
    restaurant29 = Restaurant(
        name="Tiff's Treats",
        description=
        "Fresh-baked cookies for pre-order & pickup, or delivery, with a limited selection for walk-ins.",
        address="1700 E Oltorf St",
        city="Austin",
        state="TX",
        zip_code="78741",
        lat=30.234797164809567,
        lng=-97.73945371534413,
        hours="9:00AM - 10:00PM",
        price="$",
        rating=4.0,
    )
    # restaurant36 = Restaurant(name="Tinys Milk & Cookies",
    #                     description="Milk & Cookies is a walk up coffee shop serving homemade ice cream, pastries, and of course, our cookie.",
    #                     address="1515 W 35th St",
    #                     city="Austin",
    #                     state="TX",
    #                     zip_code="78703",
    #                     lat=30.307501456412382,
    #                     lng=-97.7503918,
    #                     hours="7:00AM - 9:00PM",
    #                     price="$",
    #                     rating=4.7,
    #                     )
    restaurant30 = Restaurant(
        name="Insomnia Cookies",
        description=
        "Bakery chain known for late-night deliveries, with some locations selling ice cream.",
        address="2323 San Antonio St",
        city="Austin",
        state="TX",
        zip_code="78705",
        lat=30.288449263565315,
        lng=-97.7425249,
        hours="11:00AM - 12:00AM",
        price="$$",
        rating=3.7,
    )
    restaurant31 = Restaurant(
        name="Crumbl Cookies",
        description=
        "Each week, our menu rotates to give you 4 different specialty flavors to taste and enjoy. Don’t worry, our famous milk chocolate chip and chilled sugar cookie are always available.",
        address="5207 Brodie Ln",
        city="Austin",
        state="TX",
        zip_code="78745",
        lat=30.230633408810952,
        lng=-97.81658836137646,
        hours="8:00AM - 10:00PM",
        price="$$",
        rating=4.8,
    )
    restaurant32 = Restaurant(
        name="The Baked Bear",
        description=
        "Decadent build-your-own custom ice cream sandwiches with artisanal ice cream & house-made cookies.",
        address="211 Walter Seaholm Dr",
        city="Austin",
        state="TX",
        zip_code="78701",
        lat=30.268031906876974,
        lng=-97.75267155396759,
        hours="12:00PM - 11:00PM",
        price="$",
        rating=4.7,
    )
    ## add restaurants
    db.session.add(restaurant1)
    db.session.add(restaurant2)
    db.session.add(restaurant3)
    db.session.add(restaurant4)
    db.session.add(restaurant5)
    db.session.add(restaurant6)
    db.session.add(restaurant7)
    db.session.add(restaurant8)
    db.session.add(restaurant9)
    db.session.add(restaurant10)
    db.session.add(restaurant11)
    db.session.add(restaurant12)
    db.session.add(restaurant13)
    db.session.add(restaurant14)
    db.session.add(restaurant15)
    db.session.add(restaurant16)
    db.session.add(restaurant17)
    db.session.add(restaurant18)
    db.session.add(restaurant19)
    db.session.add(restaurant20)
    db.session.add(restaurant21)
    db.session.add(restaurant22)
    db.session.add(restaurant23)
    db.session.add(restaurant24)
    db.session.add(restaurant25)
    db.session.add(restaurant26)
    db.session.add(restaurant27)
    db.session.add(restaurant28)
    db.session.add(restaurant29)
    db.session.add(restaurant30)
    db.session.add(restaurant31)
    db.session.add(restaurant32)

    ## append cake
    genre1.restaurants.append(restaurant1)
    genre1.restaurants.append(restaurant3)
    genre1.restaurants.append(restaurant5)
    genre1.restaurants.append(restaurant6)
    genre1.restaurants.append(restaurant7)
    genre1.restaurants.append(restaurant8)
    genre1.restaurants.append(restaurant11)
    genre1.restaurants.append(restaurant13)
    genre1.restaurants.append(restaurant27)
    ##append cupcake
    genre2.restaurants.append(restaurant3)
    genre2.restaurants.append(restaurant6)
    genre2.restaurants.append(restaurant8)
    genre2.restaurants.append(restaurant11)
    genre2.restaurants.append(restaurant2)
    genre2.restaurants.append(restaurant4)
    genre2.restaurants.append(restaurant9)
    genre2.restaurants.append(restaurant10)
    # append pie
    genre3.restaurants.append(restaurant3)
    genre3.restaurants.append(restaurant13)
    genre3.restaurants.append(restaurant12)
    genre3.restaurants.append(restaurant14)
    #append chocolate
    genre4.restaurants.append(restaurant15)
    genre4.restaurants.append(restaurant17)
    genre4.restaurants.append(restaurant18)
    genre4.restaurants.append(restaurant19)
    genre4.restaurants.append(restaurant16)
    #append candy
    genre5.restaurants.append(restaurant17)
    genre5.restaurants.append(restaurant18)
    genre5.restaurants.append(restaurant19)
    # append ice cream
    genre6.restaurants.append(restaurant20)
    genre6.restaurants.append(restaurant21)
    genre6.restaurants.append(restaurant22)
    genre6.restaurants.append(restaurant23)
    genre6.restaurants.append(restaurant24)
    genre6.restaurants.append(restaurant28)
    genre6.restaurants.append(restaurant29)
    genre6.restaurants.append(restaurant30)
    genre6.restaurants.append(restaurant31)
    genre6.restaurants.append(restaurant32)
    # append Doughnuts
    genre7.restaurants.append(restaurant25)
    genre7.restaurants.append(restaurant26)
    genre7.restaurants.append(restaurant11)
    #append Pastries
    genre8.restaurants.append(restaurant5)
    genre8.restaurants.append(restaurant6)
    genre8.restaurants.append(restaurant8)
    genre8.restaurants.append(restaurant13)
    genre8.restaurants.append(restaurant27)
    genre8.restaurants.append(restaurant2)
    genre8.restaurants.append(restaurant4)
    genre8.restaurants.append(restaurant14)
    genre8.restaurants.append(restaurant15)

    #append gelato
    genre9.restaurants.append(restaurant21)

    # append vegan
    genre10.restaurants.append(restaurant8)
    genre10.restaurants.append(restaurant11)
    genre10.restaurants.append(restaurant4)
    genre10.restaurants.append(restaurant23)
    genre10.restaurants.append(restaurant24)
    genre10.restaurants.append(restaurant28)
    genre10.restaurants.append(restaurant25)
    #append cookies
    genre11.restaurants.append(restaurant3)
    genre11.restaurants.append(restaurant5)
    genre11.restaurants.append(restaurant8)
    genre11.restaurants.append(restaurant11)
    genre11.restaurants.append(restaurant13)
    genre11.restaurants.append(restaurant2)
    genre11.restaurants.append(restaurant4)
    genre11.restaurants.append(restaurant14)
    genre11.restaurants.append(restaurant29)
    genre11.restaurants.append(restaurant30)
    genre11.restaurants.append(restaurant31)
    genre11.restaurants.append(restaurant32)

    ## add genres
    db.session.add(genre1)
    db.session.add(genre2)
    db.session.add(genre3)
    db.session.add(genre4)
    db.session.add(genre5)
    db.session.add(genre6)
    db.session.add(genre7)
    db.session.add(genre8)
    db.session.add(genre9)
    db.session.add(genre10)

    db.session.add(genre11)

    db.session.commit()