StoryController - applebiter/gnatwriter GitHub Wiki

Story controller encapsulates story management functionality.

create_story()

create_story(title: str, description: str = None) -> Story

Takes a title, minimally, and an optional description. Returns the new Story.

update_story()

update_story(story_id: int, title: str, description: str = None) -> Type[Story]

Requires a Story id and accepts an updated title, description, or both. Returns the updated Story.

delete_story()

delete_story(story_id: int) -> bool

Takes a Story id and returns True if the specified Story is deleted from the database.

has_stories()

has_stories() -> bool

Returns True if the user has any Stories in the database.

count_stories()

count_stories() -> int

Returns the number of Stories in the database belonging to the user.

get_story_by_id()

get_story_by_id(story_id: int) -> Type[Story] | None

Takes a Story id and returns the specified Story if found in the database, None otherwise.

get_all_stories()

get_all_stories() -> List[Type[Story]]

Returns a list containing all Stories in the database belonging to the user.

get_all_stories_page()

get_all_stories_page(page: int, per_page: int) -> List[Type[Story]]

Takes a page number an an integer describing how many Stories to return per page of results. Returns a list containing the Stories corresponding to that page of data.

search_stories()

search_stories(search: str) -> List[Type[Story]]

Takes a search term and matches it against the title and description of all Stories in the database belonging to the user. Returns a list of all matching Stories, if any.

append_authors_to_story()

append_authors_to_story(story_id: int, author_ids: list) -> Type[Story]

Takes a Story id and a list containing one or more Author ids. Returns the updated Story.

detach_authors_from_story()

detach_authors_from_story(story_id: int, author_ids: list) -> Type[Story]

Takes a Story id and a list containing one or more Author ids. Removes any association between the specified story and author(s).

has_authors()

has_authors(story_id: int) -> bool

Takes a Story id and returns True if the Story has any Authors associated with it.

get_authors_by_story_id()

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

Takes a Story id and returns a list containing all associated Authors, if any.

has_chapters()

has_chapters(story_id: int) -> bool

Takes a Story id and returns True if the Story contains Chapters.

get_chapter_by_position()

get_chapter_by_position(story_id: int, position: int) -> Type[Chapter]

Takes a Story id and an integer representing the position of the Chapter to be selected. Returns the specified Chapter.

get_all_chapters_by_story_id()

get_all_chapters_by_story_id(story_id: int) -> List[Type[Chapter]]

Takes a Story id and returns a list containing all of its Chapters, if any.

append_characters_to_story()

append_characters_to_story(story_id: int, character_ids: list) -> Type[Story]

Takes a Story id and a list containing one or more Character ids. Returns the update Story.

has_characters()

has_characters(story_id: int) -> bool

Takes a Story id and returns True if the Story has any Characters associated with it.

get_characters_by_story_id()

get_characters_by_story_id(story_id: int) -> List[Type[Character]]

Takes a Story id and returns a list of all associated Characters,m if any.

get_characters_page_by_story_id()

get_characters_page_by_story_id(story_id: int, page: int, per_page: int) -> List[Type[Character]]

Takes a Story id, a page number, and an integer describing how many Characters to return per page of results. Returns a list containing the specified page's Characters.

append_links_to_story()

append_links_to_story(story_id: int, link_ids: list) -> Type[Story]

Takes a Story id and a list containing one or more Link ids. Returns the updated Story.

has_links()

has_links(story_id: int) -> bool

Takes a Story id and returns True if there are any Links associated with the specified Story.

get_links_by_story_id()

get_links_by_story_id(story_id: int) -> List[Type[Link]]

Takes a Story id and returns a list containing any associated Links.

append_notes_to_story()

append_notes_to_story(story_id: int, note_ids: list) -> Type[Story]

Takes a Story id and a list containing one or more Note ids. Returns the updated Story.

has_notes()

has_notes(story_id: int) -> bool

Returns True if the Story has any Notes associated with it.

get_notes_by_story_id()

get_notes_by_story_id(story_id: int) -> List[Type[Note]]

Takes a Story id and returns a list containing all Notes associated with the specified Story, if any.