def add_review(id):
    content = request.form.get('content')
    apartment = Apartment.query.filter_by(id=id).first()
    if not content or content == '':
        flash('The content is empty', 'warning')
    elif not apartment:
        flash('The hotel is not exist.', 'warning')
    elif not apartment.checkuser(current_user.id):
        flash("You can't review it before booking.")
    else:
        review = Review(content=content,
                        apartment_id=id,
                        user_id=current_user.id,
                        score=request.form.get('rating'))
        db.session.add(review)
        db.session.commit()
        flash('Review added', 'success')

    return redirect(url_for('apartment', id=id))
Exemple #2
0
def add_review_process():
    """Get information from review form page"""

    campsite_name = request.form["campsite_name"]
    campsite = Campsite.query.filter_by(name=campsite_name).first()
    campsite_id = campsite.campsite_id
    amenities = campsite.amenities
    ratings = campsite.ratings


    # Get form variables 
    review = request.form["review"]
    noise_level = int(request.form["noiselevel"])
    privacy_level = int(request.form["privacylevel"])
    risk_level = int(request.form["risklevel"])

    #User_id pulled from session
    user_id = session.get("user_id")
    user = User.query.filter_by(user_id=user_id).first()

    new_rating = Rating(noise_level=noise_level,
                    risk_level=risk_level,
                    privacy_level=privacy_level,
                    user_id=user_id,
                    campsite_id=campsite_id)

    new_review = Review(user_id=user_id,
                        campsite_id=campsite_id,
                        review_description=review)

    db.session.add(new_rating)
    db.session.add(new_review)

    db.session.commit()

    reviews = campsite.reviews

    return render_template("campsite-details.html", campsite=campsite,
                                                    amenities=amenities,
                                                    ratings=ratings,
                                                    reviews=reviews,
                                                    user=user)
Exemple #3
0
def add_review_db():
    """add a review to db"""

    if "user_id" in session:

        brand_id = request.form.get("brandid")
        review_content = request.form.get("reviewContent")
        user = User.query.get(session["user_id"])

        review = Review(user=user,
                        review_content=review_content,
                        product_id=brand_id)

        db.session.add(review)
        db.session.commit()

        return jsonify({"status": "added review"})

    else:
        return redirect("/login")
Exemple #4
0
    def post(self):
        json_data = request.get_json(force=True)
        if not json_data:
            return {'message': 'No input data provided'}, 400

        data, errors = review_schema.load(json_data)
        if errors:
            return {"status": "error", "data": errors}, 422
        product_id = Review.query.filter_by(id=data['product_id']).first()
        if not product_id:
            return {
                'status': 'error',
                'message': 'review product not found'
            }, 400
        review = Review(product_id=data['product_id'], review=data['review'])
        db.session.add(review)
        db.session.commit()

        result = review_schema.dump(review).data

        return {'status': "success", 'user_reviews': result}, 201
Exemple #5
0
def review_process(biz_name):
    """Processes user review of business."""

    score = request.form.get['rating']
    comment = request.form.get['review']
    rev_type = request.form.get['rev_type']
    today = datetime.today()
    biz = Business.query.filter_by(biz_name=biz_name).first()

    user = User.query.get(session['user_id'])

    if rev_type == 'new':
        review = Review(user_id=session['user_id'],
                        biz_id=biz.biz_id,
                        rating=int(score),
                        review=comment,
                        review_date=today)

        db.session.add(review)
        db.session.commit()

        flash('Your review has been received. {} appreciates your feedback.'.format(biz_name), 'info')

    elif rev_type == 'revise':
        review_id = request.form.get['review-id']

        review = Review.query.get(review_id)

        review.revise_review = True
        review.new_rating = score
        review.new_review = comment

        db.session.commit()

        flash('Your review has been updated. {} appreciates your feedback.'.format(biz_name), 'info')

    return render_template('business_profile.html', biz=biz, user=user,
                            today=today, user_score=int(score))
Exemple #6
0
    def post(self, reviews_id):
        user = users.get_current_user()

        if not user:
            self.render_template(
                "permissiondenied.html",
                params={"login_url": users.create_login_url('/')})
            return

        review = self.request.get("newreview")
        price = int(self.request.get("newprice"))
        rating = int(self.request.get("newrating"))
        visit = self.request.get("newvisit")

        reviews = Review(user=user.email(),
                         note=review,
                         price=price,
                         rating=rating,
                         visit=visit,
                         restaurant=reviews_id)
        reviews.put()
        redetail = Gastro.get_by_id(int(reviews_id))
        q = urllib.urlencode({
            "query":
            (redetail.name + " in " + redetail.place).encode(encoding='ascii',
                                                             errors='ignore'),
            "key":
            "AIzaSyBKdIPR1Q6TzIvjJuJzIyvybo6Mg1JLm64"
        })

        url = "https://maps.googleapis.com/maps/api/place/textsearch/json?" + q
        result = urlfetch.fetch(url)

        restaurant_info = json.loads(result.content)
        params = {"redetail": redetail, "restaurant_info": restaurant_info}
        return self.render_template("rest_details.html", params=params)
Exemple #7
0
def add_review():
    """Add a review order to our database."""

    score = request.form.get("score")
    comment_description = request.form.get("commentText")
    comment_title = request.form.get("title")
    trail_id = int(request.form["trail_id"])

    # getting the user name from the form page, to get the user id and add it to
    # reviews
    user_name = request.form["name"]
    session_user = User.query.filter_by(user_name=user_name).first()
    user_id = session_user.user_id

    # add an order to our database here
    new_review = Review(user_id=user_id, trail_id=trail_id,
                        comment_title=comment_title,
                        comment_description=comment_description,
                        score=score)

    db.session.add(new_review)
    db.session.commit()

    return redirect('/')
def generate_reviews():

    print "Reviews"

    Review.query.delete()

    #query db to get all users
    users = User.query.all()

    #query db to get all studios
    studios = Studio.query.all()

    for user in users:
        for studio in studios:
            review = Review(user_id=user.user_id,
                            studio_id=studio.studio_id,
                            amenities_rating=randint(4, 5),
                            cleanliness_rating=randint(4, 5),
                            class_size_rating=randint(1, 2),
                            schedule_rating=randint(4, 5),
                            pace_rating=randint(2, 3))
            db.session.add(review)

    db.session.commit()
Exemple #9
0
def load_reviews():
	"""Load reviews from seed data into database"""

	with open("seed_data/reviews.txt") as reviews: 
		for row in reviews: 
			review = row.rstrip().split("|")

			hidden = True if review[9] == "True" else False

			kwargs = dict(
			review_id = review[0],
			user_id = review[1], 
			play_id = review[2], 
			photo_id= review[3],
			order=review[4],
			content = review[5],
			publication = review[6],
			writer = review[7],
			link = review[8], 
			hidden = hidden 
			)

			keys_to_remove = []

			for key in kwargs.keys(): 
				if kwargs[key] == "":
					keys_to_remove.append(key)

			for key in keys_to_remove:
				del kwargs[key]

			review = Review(**kwargs)

			db.session.add(review)

	db.session.commit()
Exemple #10
0
def process_rating2():
    """Get ratings from modal form and store them in reviews table"""
    print "At process-rating"

    user_id = session['user']

    # If landlord_id was passed as data, set it equal to landlord_id to be used in review
    landlord_id = request.form.get('landlord-id-field')
    if landlord_id:
        print "Received landlord_id: {}".format(landlord_id)

    if not landlord_id:

        fname = request.form.get('fname')
        lname = request.form.get('lname')

        # See if landlord exists in database as entered (case insensitive)
        landlord_result = db.session.query(Landlord).filter(
            db.func.lower(Landlord.fname) == db.func.lower(fname),
            db.func.lower(Landlord.lname) == db.func.lower(lname)).first()

        # TO DO: change to .all() and return both, giving user option to choose

        if landlord_result:
            print "{} {} exists as a landlord.".format(fname, lname)
            landlord_id = landlord_result.landlord_id
        else:
            print "{} {} does not exist as a landlord as entered.".format(
                fname, lname)
            print "Searching for possible matches."

            # Use more flexible lookup to find possible matches
            landlord_results = find_landlords_by_name(fname, lname)

            # Return json object with landlord results
            if landlord_results:

                landlord_list = []

                for landlord in landlord_results:
                    landlord_list.append(landlord.convert_to_dict())

                landlord_dict = {'landlords': landlord_list}

                return jsonify(landlord_dict)

            else:
                return "found-no-landlords"
            # landlord = Landlord(fname=fname, lname=lname)

            # db.session.add(landlord)
            # db.session.commit()
            # flash("Successfully added {} {} as a landlord.".format(fname, lname))

    street = request.form.get('street-field')
    city = request.form.get('city')
    state = request.form.get('state')
    country = request.form.get('country')
    zipcode = request.form.get('zipcode')

    moved_in_at = request.form.get('move-in')
    moved_out_at = request.form.get('move-out')

    if moved_in_at:
        moved_in_at = datetime.strptime(moved_in_at, "%Y-%m-%d")

    else:
        moved_in_at = None

    if moved_out_at:
        moved_out_at = datetime.strptime(moved_out_at, "%Y-%m-%d")

    else:
        moved_out_at = None

    rating1 = request.form.get('rating1') or None
    rating2 = request.form.get('rating2') or None
    rating3 = request.form.get('rating3') or None
    rating4 = request.form.get('rating4') or None
    rating5 = request.form.get('rating5') or None
    comment = request.form.get('comment', None)

    # Query for the address in the database that matches the street, city and state
    address = db.session.query(Address).filter(
        Address.street.ilike("%" + street + "%"),
        Address.city.ilike("%" + city + "%"), Address.state == state).first()
    if address:
        address_id = address.address_id

    # If the address is not in the database
    elif address is None:

        # Geocode to find lat and lng
        # Use center of San Francisco for proximity lat and lng
        proxim_lng = -122.4194155
        proxim_lat = 37.7749295
        req = 'https://api.mapbox.com/geocoding/v5/mapbox.places/{}.json?proximity={},{}&access_token={}'.format(
            street, proxim_lng, proxim_lat, mapbox_token)
        r = requests.get(req)
        json_response = r.json()
        # pp.pprint(json_response)

        feature_to_add = None

        # Isolate the feature in the city the user searched for
        for feature in json_response['features']:
            # print json_response['features']
            print 'iterating over json response'
            if city == feature['context'][1]["text"]:
                feature_to_add = feature
                break

        # If there are no features that match the city the user searched for
        if feature_to_add is None:
            # flash("Can't find the street address you entered in the city you entered.")
            return "Address-not-valid"

        # Otherwise, continue the process to add the address to the database
        else:
            address = Address(street=street,
                              city=city,
                              state=state,
                              zipcode=zipcode,
                              country=country,
                              lng=feature_to_add['center'][0],
                              lat=feature_to_add['center'][1])

            db.session.add(address)
            db.session.commit()

            address_id = address.address_id

    # Add the review to the database

    review = Review(user_id=user_id,
                    landlord_id=landlord_id,
                    address_id=address_id,
                    moved_in_at=moved_in_at,
                    moved_out_at=moved_out_at,
                    created_at=datetime.utcnow(),
                    rating1=rating1,
                    rating2=rating2,
                    rating3=rating3,
                    rating4=rating4,
                    rating5=rating5,
                    comment=comment)

    db.session.add(review)
    db.session.commit()

    success = {'success': landlord_id}
    print success

    return jsonify(success)
def process_review_form():
    """Add input from review form to db and update overall scores"""

    tip_text = request.form.get("tip_text")
    amenities_rating = request.form.get("amenities_rating")
    cleanliness_rating = request.form.get("cleanliness_rating")
    class_size_rating = request.form.get("class_size_rating")
    schedule_rating = request.form.get("schedule_rating")
    pace_rating = request.form.get("pace_rating")

    name = request.form.get("name")
    rating = request.form.get("instructor_rating")

    favorite_class = request.form.get("fav_class")

    studio_id = request.form.get("studio_id")

    #establish user id and studio id foreign keys
    user_id = session['user']

    #check if user already reviewed this studio
    #if already did, update ratings
    #if not, instansiate new review
    existing_review = Review.query.filter(
        Review.user_id == user_id, Review.studio_id == studio_id).first()

    if not existing_review:
        review = Review(user_id=user_id,
                        studio_id=studio_id,
                        tip_text=tip_text,
                        amenities_rating=amenities_rating,
                        cleanliness_rating=cleanliness_rating,
                        class_size_rating=class_size_rating,
                        schedule_rating=schedule_rating,
                        pace_rating=pace_rating,
                        favorite_class=favorite_class)
        db.session.add(review)
        db.session.commit()
    if existing_review:
        existing_review.tip_text = tip_text
        existing_review.cleanliness_rating = cleanliness_rating
        existing_review.class_size_rating = class_size_rating
        existing_review.schedule_rating = schedule_rating
        existing_review.pace_rating = pace_rating
        existing_review.favorite_class = favorite_class
        db.session.commit()

    #check if this instructor exists in the database
    #if so, use id for review
    #if not, add to database
    instructor = Instructor.query.filter(
        Instructor.name == name, Instructor.studio_id == studio_id).first()

    if not instructor:
        instructor = Instructor(studio_id=studio_id, name=name)
        db.session.add(instructor)
        db.session.commit()

    instructor_id = instructor.instructor_id

    #check if user already reviewed this instructor
    #if so, update rating
    #if not, instantiate instructor review

    existing_instructor_review = InstructorReview.query.filter(
        InstructorReview.user_id == user_id,
        InstructorReview.instructor_id == instructor_id).first()

    if not existing_instructor_review:
        instructorreview = InstructorReview(instructor_id=instructor_id,
                                            user_id=user_id,
                                            rating=rating)
        db.session.add(instructorreview)
        db.session.commit()
    if existing_instructor_review:
        existing_instructor_review.rating = rating
        db.session.commit()

    #update studios overall scores in db with this user's scores

    studio = Studio.query.filter(Studio.studio_id == studio_id).first()

    all_reviews = studio.reviews

    #get number of reviews to use for average
    max_id = len(all_reviews)

    amenities_total = 0
    cleanliness_total = 0
    class_size_total = 0
    class_schedule_total = 0
    class_pace_total = 0

    for review in all_reviews:
        amenities_total += int(review.amenities_rating)
        cleanliness_total += int(review.cleanliness_rating)
        class_size_total += int(review.class_size_rating)
        class_schedule_total += int(review.schedule_rating)
        class_pace_total += int(review.pace_rating)

    #if this studio has already been reviewed, calculate the average
    #if not, add this first review to studio db

    if len(all_reviews) > 1:
        # studio.overall_rating = (overall_total + (int(overall_rating))) / int(max_id)
        studio.amenities_rating = (amenities_total +
                                   (int(amenities_rating))) / int(max_id)
        studio.cleanliness_rating = (cleanliness_total +
                                     (int(cleanliness_rating))) / int(max_id)
        studio.class_size_rating = (class_size_total +
                                    (int(class_size_rating))) / int(max_id)
        studio.schedule_rating = (class_schedule_total +
                                  (int(schedule_rating))) / int(max_id)
        studio.pace_rating = (class_pace_total +
                              (int(pace_rating))) / int(max_id)
        db.session.commit()
    else:
        # studio.overall_rating = overall_rating
        studio.amenities_rating = amenities_rating
        studio.cleanliness_rating = cleanliness_rating
        studio.class_size_rating = class_size_rating
        studio.schedule_rating = schedule_rating
        studio.pace_rating = pace_rating
        db.session.commit()

    return redirect('/studios/' + str(studio_id))
Exemple #12
0
def load_test_user():
	"""Load user for testing."""

	print "Test User"

	user = User(username='******',
				email='*****@*****.**',
				password='******',
				birthday='1989-06-28',
				location='LA',
				bio='Hello, everybody! My name is Markiplier.',
				fave_game="Sid Meier's Civilization V")

	db.session.add(user)
	db.session.commit()

	print "Reviews"

	review1 = Review(user_id=1,
					 game_id=16053,
					 user_score=8,
					 review="""An action-packed romp through a zombie-infested island. Needs more dakka.""")
	review2 = Review(user_id=1,
					 game_id=17979,
					 user_score=9,
					 review="""A disgustingly sad game. A solid platformer, though. Has a lot of replayability value. Looking forward to future add-ons.""")
	review3 = Review(user_id=1,
					 game_id=16360,
					 user_score=10,
					 review="""I'm rendered speechless. A beautiful game. Please play this game.""")
	review4 = Review(user_id=1,
					 game_id=17484,
					 user_score=9,
					 review="""They should probably make this multiplayer. Just a thought. That being said, the single-player campaign is fantastic.""")

	db.session.add_all([review1, 
					   review2, 
					   review3, 
					   review4])
	db.session.commit()

	print "Tags"

	tag1 = Tag(user_id=1,
			   tag='horror')
	tag2 = Tag(user_id=1,
               tag='rec')
	tag3 = Tag(user_id=1,
               tag='zombies')
	tag4 = Tag(user_id=1,
               tag='fave')
	tag5 = Tag(user_id=1,
               tag='streamed')

	db.session.add_all([tag1, 
					   tag2, 
					   tag3, 
					   tag4, 
					   tag5])
	db.session.commit()

	print "Vg Tags"

	vg_tag1 = VgTag(game_id=16053,
                    tag_id=1)
	vg_tag2 = VgTag(game_id=16053,
                    tag_id=3)
	vg_tag3 = VgTag(game_id=16360,
                    tag_id=2)
	vg_tag4 = VgTag(game_id=17484,
                    tag_id=1)
	vg_tag5 = VgTag(game_id=17484,
                    tag_id=2)
	vg_tag6 = VgTag(game_id=17484,
                    tag_id=4)
	vg_tag7 = VgTag(game_id=16053,
                    tag_id=5)
	vg_tag8 = VgTag(game_id=17979,
                    tag_id=2)
	vg_tag9 = VgTag(game_id=8838,
                    tag_id=2)
	vg_tag10 = VgTag(game_id=1,
                    tag_id=4)

	db.session.add_all([vg_tag1, 
					   vg_tag2, 
					   vg_tag3, 
					   vg_tag4, 
					   vg_tag5,
					   vg_tag6,
					   vg_tag7,
					   vg_tag8,
					   vg_tag9,
					   vg_tag10])
	db.session.commit()
    def add_val():
        # add user to database
        admin = User(username='******', phone='12345')
        admin.set_password('12345678')
        user = User(username='******', phone='0000')
        user.set_password('12345678')
        u1 = User(username='******', phone='0001')
        u1.set_password('test01')
        u2 = User(username='******', phone='0002')
        u2.set_password('test02')
        # add the data to session
        db.session.add_all([admin, user, u1, u2])
        db.session.flush()
        # add apartment to database
        a1 = Apartment(a_name='Stroll around Victoria Park from a Stylish Loft',
                       location='Ultimo',
                       address='348 Bulware Rd,Ultimo, New South Wales, Australia',
                       postcode='2007', longtitude='151.1993252', altitude='-33.8808471',
                       price='150', type='loft', bedroom= 1, guest= 2, wifi= True, owner_id=user.id,
                       description= "<p>4 guests  1 bedroom  1 bed  1 bath</p>" + \
                                    "<p> Entire loft</p>" + \
                                    "<p>This split-level modest but cozy studio has been recently renovated, making excellent use of the space with high ceilings and nice modern new flooring. Choice of queen bed (upstairs) or sofa bed (downstairs). Our unit is located in a large twin building complex (apartment, student accommodation, hotel, mall) and is perfectly located next to a bus stop (every 2-3min). 10-15min walk to Central station and Paddy's Market, 20min walk to Darling Harbor.</p>")
        a2 = Apartment(a_name='Designer Apartment close CBD & Airport & Beach',
                       location='Rosebery',
                       address='11 rosebery avenue, rosebery, 2018,Sydney',
                       postcode='2018', longtitude='151.2076137', altitude='-33.9137544',
                       price='130', type='apartment', bedroom=1, guest=3, wifi=True, parking=True, tv=True, bathroom=True, owner_id=admin.id,
                       description="<p>3 guests  1 bedroom  2 beds  1 bathroom</p>" + \
                                   "<p> Entire apartment</p>" + \
                                   "<p>Welcome to Rosebery!This modern town is just 5.5 km from Sydney. This one-bedroom apartment with special designer awards is limited to 1 minute walk to Sydney city centre / CBD, University of New South Wales and Bondi Junction / Bondi Beach / Coogee Beach (no transfer required)- 14 minutes walk to Green Square Station- 10 minutes drive from CBD and Sydney Airport- Walking distance to East Village Shopping Centre, public schools, restaurants, medical clinics and other facilities.</p>")
        a3 = Apartment(a_name='Newtown - Entire house, BEST location & parking',
                       location='Newtown',
                       address='267 king street,newtown,2042, Sydney',
                       postcode='2042', longtitude='151.1802630', altitude='-33.8960238',
                       price='141', type='townhouse', bedroom=2, guest=4, wifi=True, parking=True, tv=True, bathroom=True, owner_id=admin.id,
                       description="<p>4 guests  2 bedrooms   3 beds  1.5 bathrooms</p>" + \
                                   "<p>This cute 2 bedroom Victorian terrace is in the heart of Newtown's. 50 metres to the King St/ Enmore Rd junction - where you will find over 600 cafes, restaurants and bars to choose from as well as Newtown train station and buses. 2 minute walk to Enmore Theatre. 5 minute walk to Royal Prince Alfred (RPA) Hospital and 10 minutes to Sydney University.</p>")
        a4 = Apartment(a_name='The Lucky Dog Bondi Beach 3 Bed+ 2 Bath + garden',
                       location='Bondi',
                       address='3 Jaques avenue, Bondi Beach, 2036, Sydney',
                       postcode='2036', longtitude='151.2725109', altitude='-33.8910443',
                       price='412', type='house', bedroom=3, guest=7, wifi=True, parking=True, tv=True, bathroom=True, owner_id=user.id,
                       description="<p>7 guests   3 bedrooms    4 beds    2 bathrooms</p>" + \
                                   "<p>Cool, sleek and sophisticated, this newly renovated 3 bedroom, 2 bathroom home is enveloped in light and comfort. White interiors are complimented by accents of blue and yellow to radiate beach vibes. Walk to cafes, shops and the beach just minutes away<p/>")
        a5 = Apartment(a_name='Studio in the heart of Sydney CBD',
                       location='the rocks',
                       address='4 bridge street,the rocks,2000',
                       postcode='2000', longtitude='151.2078309', altitude='-33.8634198',
                       price='170', type='apartment', bedroom=1, guest=3, wifi=True, parking=False, tv=True, bathroom=True, owner_id=u1.id,
                       description="<p>3 guests  Studio   1 bedroom   1 bathroom</p>" + \
                                   "<p>My apartment is amazingly located in the heart of Sydney CBD, near Circular Quay, Opera House, Royal Botanic Garden and many restaurants, pubs and the shopping area, all the best Sydney can offer. The unit has everything you need to spend a great time in the city. Access to all public transport, unfortunately no parking on the building. *we may expect some noise coming from the street due to construction work on the new light rail*</p>")
        a6 = Apartment(a_name='Darling Harbour: Entire apartment one bedroom',
                       location='darling harbour',
                       address='243 pyrmont street,darling harbor,2007',
                       postcode='2007',longtitude='151.1971769',altitude='-33.8739808',
                       price='175',type='apartment', bedroom=1, guest=4, wifi=True, parking=False, tv=True, bathroom=True, owner_id=u2.id,
                       description="<p>4 guests  1 bedroom  2 beds   1 bathroom</p>" + \
                                   "<p>1 bedroom apartment sleeps 4. light filled , stylish with an internal courtyard Gym /Pool /Spa amenities/ WIFI in unit. 2nd level via lift access in the historic Goldsborough Mort Hotel Pyrmont 245 Pyrmont st, Superb position at Darling harbour with direct undercover access to The International Conference Centre ,Star City Casino ,shops & restaurants. Easy access Sydney City 10 minute walk. Major Attractions inc Harbour bridge ,Opera House, Galleries 30 mins walk Or 2 minute walk to Transport</p>")
        a7 = Apartment(a_name='1BR Apt close to Allianz Stadium & Centennial Park',
                       location='kensington',
                       address='10 anzac pde,kensington,2033',
                       postcode='2033', longtitude='151.2238032', altitude='-33.9031929',
                       price='130', type='apartment', bedroom=1, guest=4, wifi=True, parking=True, tv=True, bathroom=True, owner_id=admin.id,
                       description="<p>4 guests  1 bedroom  2 beds  1 bathroom</p>" + \
                                   "<p>This apartment is ideal for those on holiday, family visit and work trip. Walk to Centennial Park or Watch the NRL's Sydney Roosters, A-League powerhouse Sydney FC & NSW Super Rugby! It can accommodate 2-4 adults, with a Queen size bed in the bedroom and a sofa bed in the living area. Linen and towels are included. For those who drives, there is a private underground parking lot in the Building.</p>")
        a8 = Apartment(a_name='Savour Minimal, Designer Style in a Heritage-listed Terrace',
                       location='surry hills',
                       address='54 Cooper St, Surry Hills, New South Wales, Australia',
                       postcode='2010', longtitude='151.2101872',altitude='-33.8857102',
                       price='132', type='loft', bedroom=1, guest=2, wifi=True, parking=False, tv=True, bathroom=True,owner_id=user.id,
                       description="<p>2 guests  1 bedroom  1 bed  1 bath</p>" + \
                                   "<p>Entire apartment</p>" + \
                                   "<p>A uniquely spacious 1 bedroom flat — it is 1 of 2 flats in a charming heritage listed terrace nestled on a lovely residential street in Sydney's hippest hood. Your home away from home flows over the entire ground floor and you will have exclusive access to your own stylishly designed apartment with slouchy leather lounges, custom designed lighting and thoughtful design throughout.</p>")
        a9 = Apartment(a_name='Cosy 11th floor apartment in the heart of Sydney',
                       location='surry hills',
                       address='4 Little Riley St, New South Wales, Australia',
                       postcode='2010', longtitude='151.2132994', altitude='-33.8806270',
                       price='82', type='apartment', bedroom=1, guest=2, wifi=True, parking=False, tv=True, bathroom=True, owner_id=user.id,
                       description="<p>2 guests  1 bedroom  1 bed  1 bath</p>" + \
                                   "<p>Entire apartment</p>" + \
                                   "<p>Cosy 11th floor studio apartment close to Oxford Street. Walking distance to Hyde Park, surrounded by cafes, bars and restaurants. 7 minutes walk form Museum train station and 2 minutes walk for many bus stops. Entire private use of the apartment including kitchen and bathroom. Rooftop pool and terrace access on level 14 until midnight. Shared access to communal laundry for the building.</p>")
        a10 = Apartment(a_name='Architect Designed Private Studio',
                        location='Redfern',
                        address='767 Maddison Ln, Redfern New South Wales, Australia',
                        postcode='2016', longtitude='151.2157247',altitude='-33.8949822',
                        price='100', type='apartment', bedroom=1, guest=2, wifi=True, parking=False, tv=True, bathroom=True, owner_id=u1.id,
                        description="<p>2 guests  1 bedroom  1 bed  1 bath</p>" + \
                                    "<p>Latest news, just updated the bed to a queen sized bed. With brand new mattress and linen. Also, if there is more than one guest, please specify the amount of guests when requesting to book. Thank you. The Studio is your escape pad in the heart of Redfern / Surry Hills. Architecturally designed. Where industrial and urban combine to give a true inner city experience. Surrounded by wonderful parks and amenities. Close to transport. Walk everywhere</p>")
        a11 = Apartment(a_name='❤️Character Filled, Cosy Federation Terrace Home❤️',
                        location='Redfern',
                        address='28 Marriott St, Redfern, New South Wales, Australia',
                        postcode='2016', longtitude='151.2112483', altitude='-33.8923530',
                        price='65', type='house', bedroom=2, guest=6, wifi=True, parking=True, tv=True, bathroom=True, owner_id=u2.id,
                        description="<p>6 guests  2 bedrooms  3 beds  1 bath</p>" + \
                                    "<p>STAY LIKE A LOCAL. Discover the essence and secrets of Redfern & Surry Hills like locals do. If you enjoy living in a house where it is filled with characters then you won't disappoint!</p>")
        a12 = Apartment(a_name='Spacious Airy Apartment',
                        location='Redfern',
                        address='85 Redfern St,Redfern, New South Wales, Australia',
                        postcode='2016', longtitude='151.2046664', altitude='-33.8930867',
                        price='31', type='apartment', bedroom=1, guest=1, wifi=True, parking=False, tv=False, bathroom=True, owner_id=admin.id,
                        description="<p>1 guest  1 bedroom  1 bed  1 shared bath</p>" + \
                                    "<p>Private room in apartment</p>" + \
                                    "<p>The place is wonderfully situated in close proximity to Redfern station but just tucked in a quiet corner, allowing for both access to Sydney and comfortable, undisturbed sleep. It is also just a few blocks away from Woolies, so grocery shopping is no issue.</p>")
        a13 = Apartment(
            a_name='Luxury designer 2 bedrooms Apt @syd Olympic Park',
            location='Sydney olympic park',
            address=
            '4 Herb Elliott Ave, Sydney Olympic Park, New South Wales, Australia',
            postcode='2127',
            longtitude='151.0707466',
            altitude='-33.8477265',
            price='185',
            type='apartment',
            bedroom=2,
            guest=6,
            wifi=True,
            parking=False,
            tv=True,
            bathroom=True,
            owner_id=user.id,
            description=
            "<p>Complimentary tea and coffee for our guests. *5star two bedrooms high level luxury apartment *modern designer home for everyone *iconic Australia tower with amazing city views *two queen size beds and two additional single beds available *can accommodate up to 6 people *easy access to every event, transport and major facilities in Sydney Olympic Park</p>"
        )
        a14 = Apartment(
            a_name='l21 ”Amazing Sky view”Sydney Olympic Park”2bedroom',
            location='Sydney olympic park',
            address=
            '1 Bennelong Pkwy, Sydney Olympic Park, New South Wales, Australia',
            postcode='2127',
            longtitude='151.0741738',
            altitude='-33.8488338',
            price='70',
            type='apartment',
            bedroom=2,
            guest=5,
            wifi=True,
            parking=True,
            tv=True,
            bathroom=True,
            owner_id=u1.id,
            description=
            "<p>*Sydney olympic park / 2 bedroom / free parking Come and experience the relaxing Australian lifestyle and urban oasis that is Sydney Olympic Park. We are centrally located right in the geographic heart of the Greater Sydney Metropolitan area with world class amenities right at your door step.<p/>"
        )
        a15 = Apartment(
            a_name='Stunning views, great location, close to the CBD',
            location='Balmain',
            address='13 Gilchrist Pl, Balmain, New South Wales, Australia.',
            postcode='2041',
            longtitude='151.1906512',
            altitude='-33.8560522',
            price='60',
            type='apartment',
            bedroom=1,
            guest=2,
            wifi=True,
            parking=False,
            tv=True,
            bathroom=True,
            owner_id=u2.id,
            description=
            "<p>Private room with a queen size bed (shared bathroom and a second toilet) in a top floor apartment, ( the whole top floor ), 2 minutes walk to Balmain high street with lots of restaurants and cafes. You’ll love my place - the views are absolutely stunning - Cockatoo Island and the top of the Sydney Harbour Bridge. My place is good for couples, solo adventurers, and business travelers. The room can take a maximum of 2 people - there is a single mattress if you want to sleep separately.</p>"
        )
        # add the data to the session
        db.session.add_all(
            [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15])
        db.session.flush()

        # add order to database
        o1 = Order(user_id=u1.id,
                   apartment_id=a1.id,
                   checkin_date=date.today(),
                   checkout_date=date.today() + timedelta(days=7),
                   status=0)
        o2 = Order(user_id=u2.id,
                   apartment_id=a1.id,
                   checkin_date=date.today() + timedelta(days=10),
                   checkout_date=date.today() + timedelta(days=11),
                   status=1)
        db.session.add_all([o1, o2])
        # add review to database
        r1 = Review(
            score=3,
            user_id=u1.id,
            apartment_id=a1.id,
            content=
            'Absolutely incredible hosts. Went out of their way to help me out and gave me some valuable info about some of the must see things in Sydney.'
        )
        r2 = Review(
            score=4,
            user_id=u2.id,
            apartment_id=a1.id,
            content=
            'Great little place to stay in Sydney. It was very clean and nicely decorated.'
        )
        db.session.add_all([r1, r2])
        db.session.flush()

        # add messages to database
        m1 = Message(content='test01', from_id=u1.id, to_id=u2.id)
        m2 = Message(content='test 02', from_id=admin.id, to_id=u2.id)
        db.session.add_all([m1, m2])
        db.session.flush()
        m3 = Message(content='test reply to test01',
                     from_id=u2.id,
                     to_id=u1.id,
                     parent_id=m1.id)
        m4 = Message(content='test reply to test02',
                     from_id=u2.id,
                     to_id=admin.id,
                     parent_id=m2.id)
        db.session.add_all([m3, m4])

        # commit the data to the database
        db.session.commit()
Exemple #14
0
    def view_did_press_add_button(self, view, data):
        print(f"view_did_press_add_button: {data}")
        if isinstance(view, AddStudentView):
            self._db_manager.add(
                Students(id_student=data["Numer indeksu"],
                         imie=data["Imię"],
                         nazwisko=data["Nazwisko"],
                         telefon=data["Telefon"],
                         email=data["Email"]))
        elif isinstance(view, AddResearcherView):
            id_stopien_naukowy = self._db_manager.query(f"""
            SELECT id_stopienNaukowy FROM StopienNaukowy
            WHERE nazwaStopniaNaukowego = '{data["Stopień naukowy"]}'
            """)[0][0]
            id_katedra = self._db_manager.query(f"""
            SELECT id_Katedra FROM Katedra
            WHERE nazwaKatedry = '{data["Katedra"]}'
            """)[0][0]
            self._db_manager.add(
                Researchers(imie=data["Imię"],
                            nazwisko=data["Nazwisko"],
                            telefon=data["Telefon"],
                            email=data["Email"],
                            id_stopienNaukowy=id_stopien_naukowy,
                            id_katedra=id_katedra))
        elif isinstance(view, AddThesisView):
            id_promotor = self._db_manager.query(f"""
            SELECT id_pracownikNaukowy FROM PracownicyNaukowi
            WHERE CONCAT(imie, ' ', nazwisko) = '{data["Promotor"]}'
            """)[0][0]
            id_kierunek_studiow = self._db_manager.query(f"""
            SELECT id_kierunek FROM KierunekStudiow
            WHERE nazwaKierunku = '{data["Kierunek studiów"]}'
            """)[0][0]
            self._db_manager.add(
                Theses(tytul=data["Temat"],
                       id_promotor=id_promotor,
                       id_kierunekStudiow=id_kierunek_studiow))
            id_praca = self._db_manager.query(f"""
            SELECT id_praca FROM PraceDyplomowe
            WHERE tytul = '{data["Temat"]}' 
                AND id_kierunekStudiow = {id_kierunek_studiow} 
                AND id_promotor = {id_promotor}
            """)[0][0]
            for reviewer in data["Recenzenci"]:
                id_recenzujacy = self._db_manager.query(f"""
                SELECT id_pracownikNaukowy FROM PracownicyNaukowi
                WHERE CONCAT(imie, ' ', nazwisko) = '{reviewer}'
                """)[0][0]
                self._db_manager.add(
                    Review(id_praca=id_praca, id_recenzujacy=id_recenzujacy))
            for author in data["Autorzy"]:
                id_author = self._db_manager.query(f"""
                SELECT id_student FROM Studenci
                WHERE CONCAT(imie, ' ', nazwisko) = '{author}'
                """)[0][0]
                self._db_manager.add(
                    ThesesAuthors(id_student=id_author, id_praca=id_praca))
            for word in data["Słowa kluczowe"].split(","):
                word = word.lstrip().rstrip()
                id_slowo_kluczowe = self._db_manager.query(f"""
                SELECT id_slowoKluczowe FROM SlowaKluczowe
                WHERE slowoKluczowe = '{word}'
                """)
                if not id_slowo_kluczowe:
                    self._db_manager.add(Keywords(slowoKluczowe=word))
                    id_slowo_kluczowe = self._db_manager.query(f"""
                    SELECT id_slowoKluczowe FROM SlowaKluczowe
                    WHERE slowoKluczowe = '{word}'
                    """)

                self._db_manager.add(
                    ThesesKeywords(id_slowoKluczowe=id_slowo_kluczowe[0][0],
                                   id_praca=id_praca))
        elif isinstance(view, AddDefenseView):
            id_praca = self._db_manager.query(f"""
            SELECT id_praca FROM PraceDyplomowe
            WHERE tytul = '{data["Praca dyplomowa"]}'
            """)[0][0]
            id_komisja = self._db_manager.query(f"""
            SELECT KD.id_komisja FROM KomisjaDyplomowa KD
                INNER JOIN PracownicyNaukowi PN on KD.id_przewodniczacy = PN.id_pracownikNaukowy
            WHERE CONCAT(PN.imie, ' ', PN.nazwisko) = '{data["Przewodniczący komisji"]}'
            """)[0][0]
            id_lokalizacja = self._db_manager.query(f"""
            SELECT id_lokalizacja FROM Lokalizacja
            WHERE CONCAT(budynek, ', ', sala) = '{data["Miejsce obrony"]}'
            """)
            self._db_manager.add(
                Defense(data=data["Data obrony"],
                        id_praca=id_praca,
                        id_komisja=id_komisja,
                        id_lokalizacja=id_lokalizacja))
        elif isinstance(view, AddReviewView):
            id_praca = self._db_manager.query(f"""
            SELECT id_praca FROM PraceDyplomowe
            WHERE tytul = '{data["Praca dyplomowa"]}'
            """)[0][0]
            id_recenzujacy = self._db_manager.query(f"""
            SELECT id_recenzujacy FROM Recenzja
                LEFT JOIN PracownicyNaukowi PN on Recenzja.id_recenzujacy = PN.id_pracownikNaukowy
            WHERE CONCAT(imie, ' ', nazwisko) = '{self._user.split(": ")[-1]}'
            """)[0][0]
            self._db_manager.add(
                Review(id_praca=id_praca,
                       id_recenzujacy=id_recenzujacy,
                       ocena=data["Ocena"],
                       tekstRecenzji=data["Komentarz"],
                       dataWystawienia=datetime.now()))
Exemple #15
0
def load_matching_businesses(search_terms_result):
    """Load Yelp business data to Review table"""

    # print("delete last review table")
    Review.query.delete()

    print("loading businesses")
    for ttxid in search_terms_result:
        print(ttxid, "started loading")
        #if 'result' is None or does not exist and business is an empty list [] or does not exist
        if search_terms_result[ttxid].get('result', None) != None:
            if search_terms_result[ttxid].get('result', {}).get(
                    'businesses', []) != []:
                #if the yelp address1 is not None
                if search_terms_result[ttxid]['result']['businesses'][0].get(
                        'location', {}).get('address1', None) != None:
                    #if the db address matches the yelp result address
                    if search_terms_result[ttxid].get(
                            'full_business_address',
                            'oiokkokhh').lower() == search_terms_result[
                                ttxid]['result']['businesses'][0].get(
                                    'location',
                                    {}).get('address1',
                                            'asdfasdfadfaerwerda').lower():

                        review = Review(
                            yelp_id=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('id', None),
                            ttxid=ttxid,
                            alias=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('alias', None),
                            name=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('name', None),
                            image_url=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('image_url', None),
                            url=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('url', None),
                            review_count=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('review_count', None),
                            categories=str(search_terms_result[ttxid]['result']
                                           ['businesses'][0].get(
                                               'categories', None)),
                            rating=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('rating', None),
                            coordinates=str(search_terms_result[ttxid]
                                            ['result']['businesses'][0].get(
                                                'coordinates', None)),
                            longitude=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('coordinates',
                                                  None).get('longitude', None),
                            latitude=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('coordinates',
                                                  None).get('latitude', None),
                            transactions=str(search_terms_result[ttxid]
                                             ['result']['businesses'][0].get(
                                                 'transactions', None)),
                            price=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('price', None),
                            location=str(search_terms_result[ttxid]['result']
                                         ['businesses'][0].get(
                                             'location', None)),
                            address=str(search_terms_result[ttxid]
                                        ['result']['businesses'][0].get(
                                            'location',
                                            {}).get('address1', None)),
                            phone=search_terms_result[ttxid]['result']
                            ['businesses'][0].get('phone', None)
                            # search_result=xx
                        )
                        #dict_keys(['id', 'alias', 'name', 'image_url', 'is_closed', 'url', 'review_count', 'categories', 'rating', 'coordinates', 'transactions', 'price', 'location', 'phone', 'display_phone', 'distance'])

                        print(ttxid, "loaded")

                        # We need to add to the session or it won't ever be stored
                        db.session.add(review)
                        print(ttxid, "added to db")

    # Once we're done, we should commit our work
    db.session.commit()
    print("done loading businesses")
Exemple #16
0
def load_reviews_and_doctors(starting_page, ending_page, state_abbreviation="md"):
    """ Load reviews and doctors into database. """
   
   # TODO: Review over template
    base_url = URL_TEMPLATE.format(state_abbreviation)
    

    for page in range(starting_page, ending_page + 1): 
        print(f'Printing: {base_url}{page}')
        # ximport pdb; pdb.set_trace()
        # Request information from each page and return doctor profile
        r = requests.get(base_url + str(page))
        c = r.content
        soup = BeautifulSoup(c, 'html.parser')

        # Returns back list of div elements containing each doctor's profile
        all_doctors_profiles = soup.find_all("div", {"class": "search-item doctor-profile"})

        for doctor_profile in all_doctors_profiles:

            # TODO: Update try-except clauses to smaller portions of code
            try:

                # Parse the search link for current doctor
                doctor_url = doctor_profile.find("a", {"class": "search-item-doctor-link"})
                doctor_endpoint = doctor_url.get('href')
                doctor_url = "https://www.ratemds.com" + doctor_endpoint

                # Filter on all attributes containing class="rating comment"
                r = requests.get(doctor_url)
                c = r.content
                soup = BeautifulSoup(c, 'html.parser')
                review_text_body_list = soup.find_all(attrs={"class":"rating-comment-body"})
                review_date_list = soup.find_all(attrs={"class":"link-plain"})
                doctor_name_list = soup.h1.text.split()[1:]

                # Add doctors from list to db transaction and commit
                last_name = doctor_name_list[-1]
                first_name = doctor_name_list[0]
                doctor = Doctor(last_name=last_name, first_name=first_name)
                db.session.add(doctor)
                db.session.commit()

                doctor_id = doctor.doctor_id

                # Add reviews from review list to db transaction with appropriate doctor id
                for index in range(len(review_text_body_list)):
                    # import pdb; pdb.set_trace()
                    # Need to loop through both lists at the same time to ensure 
                    # dates match with reviews
                    review_text_body = review_text_body_list[index].text
                    review_date = review_date_list[index].text
                    review = Review(review_date=review_date, review_text_body=review_text_body, 
                                    doctor_id=doctor_id, review_site_id=1)
                    db.session.add(review)

                # To assist with notifying on progress on transction and committing
                db.session.commit()
                print("Committed up to Doctor ID:", doctor_id)
        
            except:
                print("Continue")
Exemple #17
0
def show_game_details(slug):
    """Display details of each game"""

    game_object = db.session.query(Game).filter(Game.slug == slug).first()
    reviews = db.session.query(Review).filter(
        Review.game_id == game_object.game_id).all()
    # screenshots and artwork links for the image gallery
    ss_artworks = []
    for url in game_object.screenshot_urls:
        replace_var = url.split('/')
        newurl = ('/').join(replace_var[:-2] + ['t_original'] +
                            replace_var[-1:])
        ss_artworks.append(newurl)

    for url in game_object.artwork_urls:
        replace_ = url.split('/')
        newurl = ('/').join(replace_[:-2] + ['t_original'] + replace_[-1:])
        ss_artworks.append(newurl)

    # get user's review from form
    review = request.form.get('ureview')
    game_object = db.session.query(Game).filter(Game.slug == slug).first()
    game_id = game_object.game_id
    # review date
    current_date = date.today()
    review_date = current_date.strftime("%Y-%b-%d")

    # total num of reviews for the game
    total = db.session.query(Rating).filter(Rating.game_id == game_id).count()
    # query for rating numbers
    get_rating = db.session.query(Rating).filter(Rating.game_id == game_id)
    r1 = get_rating.filter(Rating.rating == 1).count()
    r2 = get_rating.filter(Rating.rating == 2).count()
    r3 = get_rating.filter(Rating.rating == 3).count()
    r4 = get_rating.filter(Rating.rating == 4).count()
    r5 = get_rating.filter(Rating.rating == 5).count()
    if total != 0:
        rating1 = r1 / total * 100
        rating2 = r2 / total * 100
        rating3 = r3 / total * 100
        rating4 = r4 / total * 100
        rating5 = r5 / total * 100

        sum_ = 0
        for rating in get_rating:
            sum_ += rating.rating
        avg_rating = sum_ / total
    else:
        rating1 = 0
        rating2 = 0
        rating3 = 0
        rating4 = 0
        rating5 = 0
        avg_rating = "0"

    username = session.get("Username")
    # if user logged in
    if username:
        user = db.session.query(User).filter(User.username == username).first()
        # get user id by username
        user_id = user.user_id
        rating_obj = db.session.query(Rating).filter(
            Rating.user_id == user_id, Rating.game_id == game_id).first()
    else:
        user_id = None
        rating_obj = []
    # if button pressed to submit game review
    if request.method == 'POST':
        username = session['Username']
        user = User.query.filter_by(username=username).first()
        user_id = user.user_id
        # check if user has already reviewed specified game
        check_review_exists = db.session.query(Review).filter(
            Review.game_id == game_id, Review.user_id == user_id).first()
        if check_review_exists:
            flash("You have already reviewed this game!")
        # if user has not reviewed game - add review to database:
        if check_review_exists == None:
            db.session.add(
                Review(game_id=game_id,
                       review=review,
                       user_id=user_id,
                       review_date=review_date))
            db.session.commit()

    return render_template('game_details.html',
                           game_object=game_object,
                           ss_artworks=ss_artworks,
                           reviews=reviews,
                           user_rating=rating_obj,
                           user_id=user_id,
                           rating1=rating1,
                           rating2=rating2,
                           rating3=rating3,
                           rating4=rating4,
                           rating5=rating5,
                           total=total,
                           r1=r1,
                           r2=r2,
                           r3=r3,
                           r4=r4,
                           r5=r5,
                           avg=avg_rating)
Exemple #18
0
def example_data():
    UserImage.query.delete()
    Favorite.query.delete()
    Review.query.delete()
    Brand.query.delete()
    Foundation.query.delete()
    Recommendation.query.delete()
    User.query.delete()

    new_user = User(fname="Bobby",
                    lname="Bob",
                    email="*****@*****.**",
                    create_date=datetime.datetime.utcnow(),
                    birthday="1991-01-12 00:00:00")
    new_user.set_password("1234")
    db.session.add(new_user)
    db.session.commit()

    new_image = UserImage(
        hex_code="#BA977D",
        user_id=1,
        time_stamp=datetime.datetime.utcnow(),
        image_location=
        "/home/vagrant/src/Foundation_Project/static/uploads/girl-glowing-skin-blue-eyes.jpg"
    )
    db.session.add(new_image)
    db.session.commit()

    new_brand = Brand(
        product_id="P87985432",
        brand_name="FENTY BEAUTY by Rihanna",
        display_name="Pro Filt'r Soft Matte Longwear Foundation",
        target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432",
        rating=4.09740000000000038)
    db.session.add(new_brand)
    db.session.commit()

    new_brand_2 = Brand(
        product_id="P400888",
        brand_name="Black Up",
        display_name="Matifying Fluid Foundation",
        target_url="www.sephora.com/product/matifying-fluid-foundation-P400888",
        rating=4.2727)
    db.session.add(new_brand_2)
    db.session.commit()

    new_brand_3 = Brand(
        product_id="P432234",
        brand_name="Lawless",
        display_name="Woke Up Like This Flawless Finish Foundation",
        target_url=
        "www.sephora.com/product/woke-up-like-this-flawless-finish-foundation-P432234",
        rating=3.9836)
    db.session.add(new_brand_3)
    db.session.commit()

    new_brand_4 = Brand(
        product_id="P427301",
        brand_name="NARS",
        display_name="Natural Radiant Longwear Foundation",
        target_url=
        "www.sephora.com/product/natural-radiant-longwear-foundation-P427301",
        rating=3.6461)

    db.session.add(new_brand_4)
    db.session.commit()

    new_foundation = Foundation(
        sku_id=1925148,
        product_id="P87985432",
        foundation_hex_code="#F6D4C4",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925148",
        shade_image_url="www.sephora.com/productimages/sku/s1925148+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925148-main-Lhero.jpg")
    db.session.add(new_foundation)
    db.session.commit()

    new_foundation_2 = Foundation(
        sku_id=1925155,
        product_id="P87985432",
        foundation_hex_code="#F4D6B9",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925155",
        shade_image_url="www.sephora.com/productimages/sku/s1925155+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925155-main-Lhero.jpg")
    db.session.add(new_foundation_2)
    db.session.commit()

    new_foundation_3 = Foundation(
        sku_id=1925163,
        product_id="P87985432",
        foundation_hex_code="#EFD1B3",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925163",
        shade_image_url="www.sephora.com/productimages/sku/s1925163+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925163-main-Lhero.jpg")

    db.session.add(new_foundation_3)
    db.session.commit()

    new_foundation_4 = Foundation(
        sku_id=1925171,
        product_id="P87985432",
        foundation_hex_code="#E8D2BB",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925171",
        shade_image_url="www.sephora.com/productimages/sku/s1925171+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925171-main-Lhero.jpg")
    db.session.add(new_foundation_4)
    db.session.commit()

    new_foundation_5 = Foundation(
        sku_id=1925189,
        product_id="P87985432",
        foundation_hex_code="#F2CCB2",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925189",
        shade_image_url="www.sephora.com/productimages/sku/s1925189+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925189-main-Lhero.jpg")
    db.session.add(new_foundation_5)
    db.session.commit()

    new_foundation_6 = Foundation(
        sku_id=1925197,
        product_id="P87985432",
        foundation_hex_code="#EDC8B4",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925197",
        shade_image_url="www.sephora.com/productimages/sku/s1925197+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925197-main-Lhero.jpg")
    db.session.add(new_foundation_6)
    db.session.commit()

    new_foundation_7 = Foundation(
        sku_id=11925205,
        product_id="P87985432",
        foundation_hex_code="#EECDB1",
        foundation_target_url=
        "www.sephora.com/product/pro-filtr-soft-matte-longwear-foundation-P87985432?skuId=1925205",
        shade_image_url="www.sephora.com/productimages/sku/s1925205+sw.jpg",
        hero_image_url=
        "https://www.sephora.com/productimages/sku/s1925205-main-Lhero.jpg")
    db.session.add(new_foundation_7)
    db.session.commit()

    new_review = Review(user_id=1,
                        product_id="P87985432",
                        review_content="best brand ever ever")
    db.session.add(new_review)
    db.session.commit()

    new_recommendation = Recommendation(image_id=1, sku_id=1925148, user_id=1)
    db.session.add(new_recommendation)
    db.session.commit()

    new_recommendation_2 = Recommendation(image_id=1,
                                          sku_id=1925155,
                                          user_id=1)
    db.session.add(new_recommendation_2)
    db.session.commit()

    new_recommendation_3 = Recommendation(image_id=1,
                                          sku_id=1925163,
                                          user_id=1)
    db.session.add(new_recommendation_3)
    db.session.commit()

    new_recommendation_4 = Recommendation(image_id=1,
                                          sku_id=1925171,
                                          user_id=1)
    db.session.add(new_recommendation_4)
    db.session.commit()

    new_recommendation_5 = Recommendation(image_id=1,
                                          sku_id=1925189,
                                          user_id=1)
    db.session.add(new_recommendation_5)
    db.session.commit()

    new_recommendation_6 = Recommendation(image_id=1,
                                          sku_id=1925197,
                                          user_id=1)
    db.session.add(new_recommendation_6)
    db.session.commit()

    new_favorite = Favorite(sku_id=1925148, user_id=1)
    db.session.add(new_favorite)
    db.session.commit()