Exemplo n.º 1
0
def create(username, password, first_name, last_name, **options):
    """
    creates a new user based on given inputs.

    :param str username: username.
    :param str password: password.
    :param str first_name: first name.
    :param str last_name: last name.
    """

    get_component(UsersPackage.COMPONENT_NAME).create(username, password,
                                                      first_name, last_name,
                                                      **options)
Exemplo n.º 2
0
def get_all():
    """
    gets all languages.

    :rtype: list[LanguageEntity]
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).get_all()
Exemplo n.º 3
0
def get_all():
    """
    gets all genres.

    :rtype: list[GenreEntity]
    """

    return get_component(GenresPackage.COMPONENT_NAME).get_all()
Exemplo n.º 4
0
def create(id, **options):
    """
    creates a new actor.

    :param int id: person id.
    """

    return get_component(ActorsPackage.COMPONENT_NAME).create(id, **options)
Exemplo n.º 5
0
def get_all():
    """
    gets all actors.

    :rtype: list[PersonEntity]
    """

    return get_component(ActorsPackage.COMPONENT_NAME).get_all()
Exemplo n.º 6
0
def create(name, province_id, **options):
    """
    creates a city.

    :param str name: city name.
    :param int province_id: province id.
    """

    return get_component(CityPackage.COMPONENT_NAME).create(name, province_id, **options)
Exemplo n.º 7
0
def create(name, **options):
    """
    creates a province.

    :param str name: province name.
    """

    return get_component(ProvincePackage.COMPONENT_NAME).create(
        name, **options)
Exemplo n.º 8
0
def get_all(**options):
    """
    gets a list of all users.

    :returns: list[UserEntity]
    :rtype: list
    """

    return get_component(UsersPackage.COMPONENT_NAME).get_all(**options)
Exemplo n.º 9
0
def exists(name):
    """
    gets a value indicating that a language with given name exists.

    :param str name: language name.

    :rtype: bool
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).exists(name)
Exemplo n.º 10
0
def get(**options):
    """
    gets the current user info.

    :raises UserNotFoundError: user not found error.

    :rtype: UserEntity
    """

    return get_component(UsersPackage.COMPONENT_NAME).get(**options)
Exemplo n.º 11
0
def find(**filters):
    """
    finds languages with given filters.

    :keyword str name: language name.

    :rtype: list[LanguageEntity]
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).find(**filters)
Exemplo n.º 12
0
def find(**filters):
    """
    finds genres with given filters.

    :keyword str name: genre name.
    :keyword bool is_main: is main genre.

    :rtype: list[GenreEntity]
    """

    return get_component(GenresPackage.COMPONENT_NAME).find(**filters)
Exemplo n.º 13
0
def delete(id):
    """
    deletes a language with given id.

    :param int id: language id.

    :returns: count of deleted items.
    :rtype: int
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).delete(id)
Exemplo n.º 14
0
def get_all(**options):
    """
    gets all provinces.

    :returns: list[dict(int id,
                        str name)]

    :rtype: list
    """

    return get_component(ProvincePackage.COMPONENT_NAME).get_all(**options)
Exemplo n.º 15
0
def delete(id):
    """
    deletes an actor with given id.

    :param int id: person id.

    :returns: count of deleted items.
    :rtype: int
    """

    return get_component(ActorsPackage.COMPONENT_NAME).delete(id)
Exemplo n.º 16
0
def register_handler(instance, **options):
    """
    registers a person handler.

    :param AbstractPersonHandler instance: handler instance.

    :raises InvalidPersonHandlerTypeError: invalid person handler type error.
    :raises PersonHandlerNameRequiredError: person handler name required error.
    :raises DuplicatedPersonHandlerError: duplicated person handler error.
    """

    return get_component(PersonsPackage.COMPONENT_NAME).register_handler(instance, **options)
Exemplo n.º 17
0
def get_by_name(name):
    """
    gets a genre by name.

    it returns None if genre does not exist.

    :param str name: genre name.

    :rtype: GenreEntity
    """

    return get_component(GenresPackage.COMPONENT_NAME).get_by_name(name)
Exemplo n.º 18
0
def get_by_name(name):
    """
    gets a language by name.

    it returns None if language does not exist.

    :param str name: language name.

    :rtype: LanguageEntity
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).get_by_name(name)
Exemplo n.º 19
0
def find(**filters):
    """
    finds provinces with given filters.

    :keyword str name: province name.

    :returns: list[dict(int id,
                        str name)]

    :rtype: list
    """

    return get_component(ProvincePackage.COMPONENT_NAME).find(**filters)
Exemplo n.º 20
0
def has_permission(user, permissions, **options):
    """
    gets a value indicating that given user has the specified permissions.

    :param user: user identity to check its permissions.
    :param list[PermissionBase] permissions: permissions to check for user.

    :rtype: bool
    """

    return get_component(SecurityPackage.COMPONENT_NAME).has_permission(user,
                                                                        permissions,
                                                                        **options)
Exemplo n.º 21
0
def create(name, **options):
    """
    creates a new genre.

    :param str name: genre name.

    :raises ValidationError: validation error.

    :returns: created genre id.
    :rtype: int
    """

    return get_component(GenresPackage.COMPONENT_NAME).create(name, **options)
Exemplo n.º 22
0
def exists(**options):
    """
    gets a value indicating that an actor exists.

    it searches using given imdb page link but if it
    fails, it searches with given name if provided.

    :keyword str imdb_page: imdb page link.
    :keyword str fullname: fullname.

    :rtype: bool
    """

    return get_component(ActorsPackage.COMPONENT_NAME).exists(**options)
Exemplo n.º 23
0
def get(id):
    """
    gets genre with given id.

    it raises an error if genre does not exist.

    :param int id: genre id.

    :raises GenreDoesNotExistError: genre does not exist error.

    :rtype: GenreEntity
    """

    return get_component(GenresPackage.COMPONENT_NAME).get(id)
Exemplo n.º 24
0
def get(id):
    """
    gets actor with given id.

    it raises an error if actor does not exist.

    :param int id: person id.

    :raises ActorDoesNotExistError: actor does not exist error.

    :rtype: PersonEntity
    """

    return get_component(ActorsPackage.COMPONENT_NAME).get(id)
Exemplo n.º 25
0
def get(id):
    """
    gets person with given id.

    it raises an error if person does not exist.

    :param int id: person id.

    :raises PersonDoesNotExistError: person does not exist error.

    :rtype: PersonEntity
    """

    return get_component(PersonsPackage.COMPONENT_NAME).get(id)
Exemplo n.º 26
0
def get(id):
    """
    gets language with given id.

    it raises an error if language does not exist.

    :param int id: language id.

    :raises LanguageDoesNotExistError: language does not exist error.

    :rtype: LanguageEntity
    """

    return get_component(LanguagesPackage.COMPONENT_NAME).get(id)
Exemplo n.º 27
0
def find(**filters):
    """
    finds cities with given filters.

    :keyword str name: city name.
    :keyword int province_id: province id.

    :returns: list[dict(int id,
                        str name,
                        int province_id: province id)]

    :rtype: list
    """

    return get_component(CityPackage.COMPONENT_NAME).find(**filters)
Exemplo n.º 28
0
def try_get(**options):
    """
    gets an actor with given imdb page link or fullname.

    it searches using given imdb page link but if it
    fails, it searches with given name if provided.
    it returns None if actor not found.

    :keyword str imdb_page: imdb page link.
    :keyword str fullname: fullname.

    :rtype: PersonEntity
    """

    return get_component(ActorsPackage.COMPONENT_NAME).try_get(**options)
Exemplo n.º 29
0
def login(username, password, **options):
    """
    logs in the provided user and gets a valid token.

    :param str username: username.
    :param str password: password.

    :raises InvalidUserInfoError: invalid user info error.
    :raises UserNotFoundError: user not found error.
    :raises UserIsNotActiveError: user is not active error.

    :returns: a valid token.
    :rtype: str
    """

    return get_component(SecurityPackage.COMPONENT_NAME).login(username, password, **options)
Exemplo n.º 30
0
def get(province_id, **options):
    """
    gets the specified province.

    :param int province_id: province id to get its info.

    :raises ProvinceNotFoundError: province not found error.

    :returns: dict(int id,
                   str name)

    :rtype: dict
    """

    return get_component(ProvincePackage.COMPONENT_NAME).get(
        province_id, **options)