示例#1
0
def add_user(username: str, password: str, repo: AbstractRepository):
    user = repo.get_user(username.lower())
    if user is not None:
        raise NameNotUniqueException

    hashed_password = generate_password_hash(password)

    user = User(username, hashed_password)
    repo.add_user(user)
示例#2
0
def validate_user(username: str, password: str, repo: AbstractRepository):
    validated = False

    user = repo.get_user(username.lower())
    if user is not None:
        validated = check_password_hash(user.password, password)
    if not validated:
        raise ValidationException
示例#3
0
def get_movies(id_list, repo: AbstractRepository):
    movies = repo.get_movies_for_browse(id_list)
    return movies
示例#4
0
def get_ids_of_movies(repo: AbstractRepository):
    id_list = repo.get_ids_of_movies()
    return id_list
示例#5
0
def get_user(username: str, repo: AbstractRepository):
    user = repo.get_user(username.lower())
    if user is None:
        raise UnknownUserException

    return user
示例#6
0
def get_movies_by_actor(movie_ids: list, repo: AbstractRepository):
    movies = repo.get_movies_by_actor(movie_ids)
    return movies
示例#7
0
def get_movies_ids_by_director(director, repo: AbstractRepository):
    movie_ids = repo.get_movies_ids_by_director(director)
    return movie_ids
示例#8
0
def get_movies_ids_by_genre(genre, repo: AbstractRepository):
    movie_ids = repo.get_movies_ids_by_genre(genre)
    return movie_ids
示例#9
0
def get_movies_ids_by_title(title, repo: AbstractRepository):
    movie_ids = repo.get_movies_ids_by_title(title)
    return movie_ids