Beispiel #1
0
def render_specific_search_results(keyword):
    """Serve up search results based on user's specific input parameters"""

    current_user = crud.get_user_by_email(session['email'])
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    search_result = crud.get_movies_by_title(keyword)

    if search_result != None:
        flash(f"    {keyword}")
        session['render-search-results'] = "many"
        return render_template("homepage.html",
                               user=current_user,
                               user_genres=current_user_preferred_genres,
                               all_genres=GENRES,
                               languages=LANGUAGES,
                               current_recommendations=search_result)

    else:
        flash(f"...crickets chirping....  	🦗")
        flash(f"try a different search term, {session['name']}?")
        return redirect('/')
Beispiel #2
0
def homepage():
    """View homepage."""

    all_genres = crud.get_stored_genres()

    session['render-search-results'] = "splash"

    try:
        session['logged_in']

        if session['logged_in'] == True:
            login_user = crud.get_user_by_email(session['email'])
            user_preferred_genres = crud.get_user_genre_preferences_active(
                login_user)

            # flash(f"enter your search criteria here")
            return render_template('homepage.html',
                                   user=login_user,
                                   all_genres=GENRES,
                                   user_genres=user_preferred_genres,
                                   languages=LANGUAGES)

        else:
            return render_template('base.html')

    except KeyError:
        return render_template('base.html')
Beispiel #3
0
def show_user():
    """Show details for one particular user."""

    login_user = crud.get_user_by_email(session['email'])
    all_genres = crud.get_stored_genres()
    user_preferred_genres = crud.get_user_genre_preferences_active(login_user)

    if login_user:
        return render_template('profile.html',
                               user=login_user,
                               all_genres=GENRES,
                               user_genres=user_preferred_genres,
                               languages=LANGUAGES)

    else:
        flash(f'Your account was not found, please login or create an account')
        session['name'] = 'no-account-found-please-create-account'
        return redirect('/')
Beispiel #4
0
def show_title(filmid):
    """Show full details on a particular title."""

    title = crud.get_full_details_with_movie_id(filmid)

    current_user = crud.get_user_by_email(session['email'])
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    session['render-search-results'] = "one"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=title)
Beispiel #5
0
def get_titles_with_original_language(iso_639_1_id, english_name):
    """Show results for a particular original recorded language."""

    current_user = crud.get_user_by_email(session['email'])

    films_of_genre = crud.get_titles_with_original_language(iso_639_1_id)
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    flash(f"{english_name}")
    session['render-search-results'] = "many"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=films_of_genre)
Beispiel #6
0
def show_all_films_by_person_name(person_id, person_name):
    """Show film results for a particular person."""

    filmography = crud.get_titles_with_person(person_id)

    current_user = crud.get_user_by_email(session['email'])
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    flash(f'{person_name}')
    session['render-search-results'] = "many"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=filmography)
Beispiel #7
0
def show_top10_films_by_keyword(keyword):
    """Show films results for a particular keyword."""

    keyword_id = crud.get_keyword_id_by_name(keyword)
    current_user = crud.get_user_by_email(session['email'])

    films_of_keyword = crud.get_titles_with_keyword(keyword_id)
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    flash(f"{keyword}")
    session['render-search-results'] = "many"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=films_of_keyword)
Beispiel #8
0
def show_films_by_genre_name(genre_id, genre_name):
    """Show top-10 best rated films results for a particular genre."""

    genre_name = unquote(genre_name)
    current_user = crud.get_user_by_email(session['email'])

    films_of_genre = crud.get_titles_with_genre(genre_id)
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    flash(f"{genre_name}")
    session['render-search-results'] = "many"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=films_of_genre)
Beispiel #9
0
def get_films_from_a_given_studio(studio_id, studio_name):
    """Show films results from a particular production studio."""

    studio = crud.get_studio_info_from_name(studio_name)

    films_from_studio = crud.get_titles_from_studio(studio_id)

    current_user = crud.get_user_by_email(session['email'])
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    flash(f"{studio_name}")
    session['render-search-results'] = "many"

    return render_template(
        'homepage.html',
        user=current_user,
        # user_genres=current_user_preferred_genres,
        all_genres=GENRES,
        languages=LANGUAGES,
        current_recommendations=films_from_studio,
        studio=studio)