AuthorController - applebiter/gnatwriter GitHub Wiki

Author controller encapsulates author management functionality.

create_author()

create_author(name: str, initials: str = None, is_pseudonym: bool = False) -> Author

Initials are optional. A user might enter their own name or they might enter a pseudonym, instead. Returns an Author.

update_author()

update_author(author_id: int, name: str, initials: str = None) -> Type[Author]

Takes an Author id and allows the name and initials to be revised. Returns the updated Author.

change_pseudonym_status()

change_pseudonym_status(author_id: int, is_pseudonym: bool) -> Type[Author]

Takes an Author id and a boolean. Returns the updated Author.

delete_author_by_id()

delete_author_by_id(author_id: int) -> bool

Takes an Author id and returns True if successful.

get_author_by_id()

get_author_by_id(author_id: int) -> Type[Author] | None

Takes an author id, returns an Author if found, and None if not.

get_author_by_name()

get_author_by_name(name: str) -> Type[Author] | None

Takes an author name, returns an Author if found, and None if not.

get_author_count()

get_author_count() -> int

Returns the number of Authors in the database.

get_all_authors()

get_all_authors() -> List[Author]

Returns a list of all Authors in the database.

get_authors_page()

get_authors_page(page: int, per_page: int) -> List[Author]

Returns one page of results at a time in case there are a large number of return rows. Internally, Noveler uses a generator to yield a page's worth of items from the database result.

get_authors_by_story_id()

get_authors_by_story_id(story_id: int) -> List[Author]

Takes a story id and returns a list of Authors to whom it is attributed. It is possible to have an arbitrary number of authors attached to any story.

search_authors()

search_authors(search: str) -> List[Author]

Takes a search term and returns any matching Authors.