Beispiel #1
0
def genre():
    """
    """
    search_form = utils.MovieSearchForm()
    genre = request.args.get('genre')
    if genre:
        try:
            movie_data = services.get_movies_by_genre(genre,
                                                      repo.repo_instance)
            for movie in movie_data:
                movie['url'] = url_for('movie_bp.movie',
                                       title=movie['title'],
                                       year=movie['year'])
            movie_data.sort(key=lambda x: x['rank'])
            return render_template(
                'genre/genre.html',
                title=genre,
                watchlist=utils.get_user_watchlist(),
                movies=utils.get_added_movies(movie_data,
                                              utils.get_user_watchlist()),
                search_form=search_form,
            )
        except services.UnknownGenreException:
            return redirect(url_for('home_bp.home'))
        return redirect(url_for('home_bp.home'))
    else:
        return redirect(url_for('home_bp.home'))
Beispiel #2
0
def actor():
    """
    """
    search_form = utils.MovieSearchForm()
    fullname = request.args.get('fullname')
    if fullname:
        try:
            movie_data, collegues = services.get_movies_by_actor(
                fullname, repo.repo_instance)
            for movie in movie_data:
                movie['url'] = url_for('movie_bp.movie',
                                       title=movie['title'],
                                       year=movie['year'])
            for collegue in collegues:
                collegue['url'] = url_for('.actor',
                                          fullname=collegue['fullname'])
            return render_template(
                'person/person.html',
                title="Actor",
                fullname=fullname,
                watchlist=utils.get_user_watchlist(),
                movies=utils.get_added_movies(movie_data,
                                              utils.get_user_watchlist()),
                collegues=collegues,
                search_form=search_form,
            )
        except services.PersonException:
            return redirect(url_for('home_bp.home'))
    else:
        return redirect(url_for('home_bp.home'))
Beispiel #3
0
def movies_by_first_letter():
    """
    """
    character = request.args.get('character')
    search_form = utils.MovieSearchForm()
    if character:
        movies = services.get_movies_by_first_letter(character,
                                                     repo.repo_instance)
        for movie in movies:
            movie['url'] = url_for('movie_bp.movie',
                                   title=movie['title'],
                                   year=movie['year'])
        return render_template('browse/browse-movies.html',
                               title=f"Movies Starting With: {character}",
                               watchlist=utils.get_user_watchlist(),
                               movies=utils.get_added_movies(
                                   movies, utils.get_user_watchlist()),
                               search_form=search_form)
    else:
        letters = services.get_all_movie_first_letter(repo.repo_instance)
        letter_urls = []
        for letter in letters:
            letter_urls.append(
                dict(letter=letter,
                     url=url_for('.movies_by_first_letter', character=letter)))
        letter_urls.insert(0, dict(letter="All Movies",
                                   url=url_for('.movies')))
        return render_template(
            'browse/browse-a-z.html',
            title="Movies A-Z",
            a_to_z=letter_urls,
            search_form=search_form,
        )
Beispiel #4
0
def movies():
    """
    """
    search_form = utils.MovieSearchForm()
    movies = services.get_movies(repo.repo_instance)
    for movie in movies:
        movie['url'] = url_for('movie_bp.movie',
                               title=movie['title'],
                               year=movie['year'])
    return render_template('browse/browse-movies.html',
                           title='All Movies By Rank',
                           watchlist=utils.get_user_watchlist(),
                           movies=utils.get_added_movies(
                               movies, utils.get_user_watchlist()),
                           search_form=search_form)
Beispiel #5
0
def home():
    """
    """
    search_form = utils.MovieSearchForm()
    movies = services.get_top_100movies(repo.repo_instance)
    for movie in movies:
        movie['url'] = url_for('movie_bp.movie',
                               title=movie['title'],
                               year=movie['year'])

    return render_template(
        'home/home.html',
        title='Home',
        watchlist=utils.get_user_watchlist(),
        movies=utils.get_added_movies(movies, utils.get_user_watchlist()),
        search_form=search_form,
    )
Beispiel #6
0
def search_results(search_form):
    """
    """
    movies = services.get_search_results(search_form.actors.data,
                                         search_form.genres.data,
                                         search_form.director.data,
                                         search_form.fuzzy.data,
                                         repo.repo_instance)
    for movie in movies:
        movie['url'] = url_for('movie_bp.movie',
                               title=movie['title'],
                               year=movie['year'])
    return render_template(
        'search/results.html',
        search_form=search_form,
        title="Search",
        watchlist=utils.get_user_watchlist(),
        movies=utils.get_added_movies(movies, utils.get_user_watchlist()),
    )
Beispiel #7
0
def movie():
    """
    """
    title = request.args.get('title')
    year = request.args.get('year')
    search_form = utils.MovieSearchForm()
    try:
        movie_data = services.get_movie(title, year, repo.repo_instance)
        movie_data['add_review_url'] = url_for('movie_bp.review_movie',
                                               movie_title=movie_data['title'],
                                               movie_year=movie_data['year'])
        return render_template(
            'movie/movie.html',
            title="Movie",
            movie=utils.get_added_movies([movie_data],
                                         utils.get_user_watchlist())[0],
            search_form=search_form,
        )
    except services.UnknownMovieException:
        return redirect(url_for('home_bp.home'))
    return redirect(url_for('home_bp.home'))
Beispiel #8
0
def director():
    """
    """
    search_form = utils.MovieSearchForm()
    fullname = request.args.get('fullname')
    if fullname is not None:
        try:
            movie_data = services.get_movies_by_director(
                fullname, repo.repo_instance)
            for movie in movie_data:
                movie['url'] = url_for('movie_bp.movie',
                                       title=movie['title'],
                                       year=movie['year'])
            return render_template('person/person.html',
                                   title="Director",
                                   fullname=fullname,
                                   watchlist=utils.get_user_watchlist(),
                                   movies=utils.get_added_movies(
                                       movie_data, utils.get_user_watchlist()),
                                   search_form=search_form)
        except ValueError:
            return render_template(redirect(url_for('home_bp.home')))
    return render_template(redirect(url_for('home_bp.home')))