Beispiel #1
0
def browse_movies_actor():
    q_name = request.args.get("actor")
    q_page = request.args.get("page")

    if q_page is None:
        q_page = 0
    elif int(q_page) < 0:
        q_page = 0
    else:
        q_page = int(q_page)

    mv_list_raw = services.search(q_name, "actor", repo.repository_instance)
    # print(mv_list_raw)
    mv_list = mv_list_raw[(q_page * 8):(q_page * 8 + 8)]

    prev_page_url = url_for('browse_bp.browse_movies_actor',
                            actor=q_name,
                            page=q_page - 1)
    next_page_url = url_for('browse_bp.browse_movies_actor',
                            actor=q_name,
                            page=q_page + 1)

    while len(mv_list) < 8:
        mv_list.append(Movie(title="...", year=2016))

    # gen pages
    return render_template('content/browse.html',
                           mv_list=mv_list,
                           prev_year_url="prev_year_url",
                           next_year_url="next_year_url",
                           prev_page_url=prev_page_url,
                           next_page_url=next_page_url,
                           featured_title="Showing results for actor: " +
                           q_name,
                           type="actor")
Beispiel #2
0
def movie_info():
    try:
        username = session['username']
    except KeyError:
        username = "******"

    form = CommentForm()

    # POST
    if form.validate_on_submit():
        movie_name = form.movie_name.data

        # call service to store comment
        services.add_review(movie_name,
                            '"' + form.comment.data + '" - ' + username,
                            repo.repository_instance)
        print('POST sucess')
        # refresh page
        return redirect(url_for('browse_bp.movie_info', movie=movie_name))

    # GET
    if request.method == 'GET':
        q_name = request.args.get("movie")
        # form.movie_name.data = q_name
        # services.add_views(q_name, 1, repo.repository_instance)
        # movie_desc = "..."

        # review = services.get_review(q_name, repo.repository_instance)
        # views = services.get_views(q_name, repo.repository_instance)
        # s_query = services.search(q_name, 'movie', repo.repository_instance)
        # trailer = services.get_trailer(q_name, repo.repository_instance)

        # if len(s_query) != 0:
        #    movie_desc = s_query[0].description
    else:
        q_name = form.movie_name.data

    # q_name = request.args.get("movie")

    movie_desc = "..."

    review = services.get_review(q_name, repo.repository_instance)
    views = services.get_views(q_name, repo.repository_instance)
    s_query = services.search(q_name, 'movie', repo.repository_instance)
    trailer = services.get_trailer(q_name, repo.repository_instance)

    if len(s_query) != 0:
        movie_desc = s_query[0].description

    form.movie_name.data = q_name
    services.add_views(q_name, 1, repo.repository_instance)

    return render_template('content/movie_info.html',
                           featured_title=q_name,
                           handler_url=url_for('browse_bp.movie_info',
                                               movie=q_name),
                           form=form,
                           review=review,
                           movie_views=views,
                           movie_desc=movie_desc,
                           movie_trailer_url=trailer)
Beispiel #3
0
def test_search_actor(in_memory_repo):
    result = cont_services.search("hayden", "actor", in_memory_repo)

    assert len(result) == 2
Beispiel #4
0
def test_search_genre(in_memory_repo):
    result = cont_services.search("horror", "genre", in_memory_repo)

    assert len(result) > 0
Beispiel #5
0
def test_search_movie(in_memory_repo):
    result = cont_services.search("dark knight", "movie", in_memory_repo)

    assert len(result) == 2