Пример #1
0
def home():
    users_stack_based_on_zipcode = User.query.filter_by(
        zipcode=current_user.zipcode).all()
    exists = db.session.query(
        db.exists().where(Interest.interest_id == current_user.id)).scalar()
    if exists == False:
        return redirect(url_for('add_interests'))

    return render_template(
        'home.html', users_stack_based_on_zipcode=users_stack_based_on_zipcode)
Пример #2
0
def add_interests():
    #form = InterestForm()
    all_interests = [all_book_genres(), all_movie_genres(),all_music_genres(),all_fav_cuisines(),all_hobbies(),
    all_religions(),all_outdoors()]

    user_id = current_user.id
    book_genre_id = request.form.get("Favorite book genre")
    movie_genre_id = request.form.get("Favorite movie genre")
    music_genre_id = request.form.get("Favorite music genre")
    fav_cuisine_id = request.form.get('Preferred cuisine type')
    hobby_id = request.form.get('Favorite hobby')
    outdoor_id = request.form.get('Favorite Outdoor activity')
    religion_id = request.form.get('Religion')

    exist = db.session.query(db.exists().where(User.id == user_id)).scalar()

    if request.method == 'POST' and exist==False:
          #add user interests for the specific user
        interest = Interest(
            user_id=user_id,
            book_genre_id=book_genre_id,
            movie_genre_id=movie_genre_id,
            music_genre_id=music_genre_id,
            fav_cuisine_id=fav_cuisine_id,
            hobby_id=hobby_id,
            outdoor_id=outdoor_id,
            religion_id=religion_id
        )

        db.session.add(interest)
        db.session.commit()
        return redirect(url_for('account'))
    else:
        flash("You already have interests, you can update them!")

    return render_template('interestform.html', title='Add Interests', all_interests=all_interests)
Пример #3
0
    all_interests = [all_book_genres(), all_movie_genres(),all_music_genres(),all_fav_cuisines(),all_hobbies(),
    all_religions(),all_outdoors()]

    user_id = current_user.id
    book_genre_id = request.form.get("Favorite book genre")
    movie_genre_id = request.form.get("Favorite movie genre")
    music_genre_id = request.form.get("Favorite music genre")
    fav_cuisine_id = request.form.get('Preferred cuisine type')
    hobby_id = request.form.get('Favorite hobby')
    outdoor_id = request.form.get('Favorite Outdoor activity')
    religion_id = request.form.get('Religion')

<<<<<<< HEAD
    if request.method == 'POST':
=======
    exist = db.session.query(db.exists().where(User.id == user_id)).scalar()

    if request.method == 'POST' and exist==False:
>>>>>>> cd19436a448a259059cae3a8092d31ed974a804f
          #add user interests for the specific user
        interest = Interest(
            user_id=user_id,
            book_genre_id=book_genre_id,
            movie_genre_id=movie_genre_id,
            music_genre_id=music_genre_id,
            fav_cuisine_id=fav_cuisine_id,
            hobby_id=hobby_id,
            outdoor_id=outdoor_id,
            religion_id=religion_id
        )