Exemplo n.º 1
0
def register_form():
    """Send genres and user's preferences to registration form"""
    genres = mu.Genre.query.all()

    if "logged_in_user_id" in session:
        user_id = session["logged_in_user_id"]
        user = mu.get_user(user_id)
        user_genres = mu.get_user_genres(user_id)
        return jsonify(rh.create_info_user_json(genres, user, user_genres))
    return jsonify({"User": "******"})
Exemplo n.º 2
0
def get_random_movie_id_genres(url_genres, user_id):
    """ Return list of random movie ids based on genres which user prefers."""
    genres = mu.get_user_genres(user_id)
    movie_ids = []

    for genre in genres:
        url = "{0}{1}".format(url_genres, genre[2])
        movie_ids.append(get_random_movie_id_based_url(url))

    return movie_ids
Exemplo n.º 3
0
def show_user(user_id):
    """Return page showing the user's movie list."""
    if user_id == session.get("logged_in_user_id", 0):
        user = mu.get_user(user_id)
        movies = mu.get_user_movies(user_id)
        genres = mu.get_user_genres(user_id)

        return render_template("user_details.html",
                               user=user,
                               movies=movies,
                               genres=genres)
    flash("Invalid credentials.")
    return redirect('/')
Exemplo n.º 4
0
 def test_get_user_genres(self):
     """Test fetching user's genre preference"""
     user_id = 1
     self.assertEqual(len(mu.get_user_genres(user_id)), 4)
     user_id = 2
     self.assertEqual(len(mu.get_user_genres(user_id)), 0)