Example #1
0
def add_review(movie_id: int, review_text: str, username: str, rating: int, repo: AbstractRepository):
    movie = repo.get_movie(movie_id)
    if movie is None:
        raise NonExistentArticleException
    user = repo.get_user(username)
    if user is None:
        raise UnknownUserException

    review = Review(movie, review_text, user, rating)
    review.movie = movie
    movie.add_review(review)
    user.add_review(review)
    repo.add_review(review)
Example #2
0
def add_comment(title: str, comment_text: str, username: str, repo: AbstractRepository):
    # Check that the article exists.
    movie = repo.get_movies_by_title(title)
    if movie is None:
        raise NonExistentArticleException

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

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

    # Update the repository.
    repo.add_review(comment)
Example #3
0
def add_review(movie_id: int, review_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 review.
    review = make_review(review_text, user, movie)

    # Update the repository.
    repo.add_review(review)