def get_movie(movie_id: int, repo: AbstractRepository):
    movie = repo.get_movie(movie_id)

    if movie is None:
        raise NonExistentMovieException

    return movie_to_dict(movie)
def get_reviews_for_movie(movie_id, repo: AbstractRepository):
    movie = repo.get_movie(movie_id)

    if movie is None:
        raise NonExistentMovieException

    return reviews_to_dict(movie.reviews)
Example #3
0
def get_movie(movie_rank: int, repo: AbstractRepository):
    movie = repo.get_movie(movie_rank)

    if movie is None:
        raise NonExistentArticleException

    return movie_to_dict(movie)
def add_review(movie_id: int, review_text: str, user: User,
               repo: AbstractRepository):
    # Check that the movie exists.
    movie = repo.get_movie(movie_id)
    rating = 0
    review = Review(movie, review_text, rating, user)

    # Update the repository.
    repo.add_review(review, movie, user)
def add_review(movie_id: int, review_text: str, user: User, repo: AbstractRepository):
    # Check that the movie exists.
    movie = repo.get_movie(movie_id)
    if movie is None:
        raise NonExistentMovieException

    if user is None:
        raise UnknownUserException

    # Create review.
    review = make_review(review_text, user, movie)

    # Update the repository.
    repo.add_review(review)
Example #6
0
def add_comment(movie_id: int, comment_text: str, username: str,
                repo: AbstractRepository):
    # Check that the movie exists.
    movie = repo.get_movie(movie_id)
    if movie is None:
        raise NonExistentMovieException

    user = repo.get_user(username)
    if user is None:
        raise UnknownUserException

    # Create comment.
    comment = make_review(comment_text, user, movie)

    # Update the repository.
    repo.add_review(comment)
Example #7
0
def add_review(movie_rank: int, review_text: str, username: str,
               repo: AbstractRepository, review_int: int):
    # Check that the article exists.
    movie = repo.get_movie(movie_rank)
    if movie is None:
        raise NonExistentArticleException

    user = repo.get_user(username)
    if user is None:
        raise UnknownUserException

    # Create comment.
    review = make_review(review_text, user, movie, review_int)

    # Update the repository.
    repo.add_review(review)
Example #8
0
def select_movie(title, repo: AbstractRepository):
    return repo.get_movie(title)