ChapterController - applebiter/gnatwriter GitHub Wiki
Chapter controller encapsulates chapter management functionality.
create_chapter()
create_chapter(story_id: int, title: str, description: str = None) -> Chapter
Takes a Story id and a title at minimum, also accepts an optional description of the Story. Returns the new Story.
update_chapter()
update_chapter(chapter_id: int, title: str, description: str = None) -> Type[Chapter]
Takes the Chapter id, title and an optional description of the Story. Returns the updated Story.
delete_chapter()
delete_chapter(chapter_id: int) -> bool
Takes a Chapter id and returns True if the corresponding Chapter is deleted. Deleting a Chapter automatically any Scene objects attached to it, and any Link or Note objects attached to the Chapter and its Scenes.
change_chapter_position()
change_chapter_position(chapter_id: int, position: int) -> Type[Chapter]
When Chapters are added to a Story, they are assigned to the next available position within a Story, but the Chapter position can be changed arbitrarily using this method. The sibling Chapter positions are also updated to accommodate the new position. Returns the updated Chapter.
get_chapter_by_id()
get_chapter_by_id(chapter_id: int) -> Type[Chapter] | None
Takes a Chapter id and returns the matching Chapter if found, None otherwise.
get_all_chapters()
get_all_chapters() -> List[Chapter]
Returns a list of all Chapters from all Stories belonging to the user.
get_all_chapters_page()
get_all_chapters_page(page: int, per_page: int) -> List[Chapter]
Takes a page number and the number of items to consider a page of data, and returns a page worth of results.
get_chapters_by_story_id()
get_chapters_by_story_id(story_id: int) -> List[Chapter]
Takes a Story id and returns all of its Chapters.
get_chapters_page_by_story_id()
get_chapters_page_by_story_id(story_id: int, page: int, per_page: int -> List[Chapter]
Takes a Story id, a page number, and the number of return items that should constitute a page's worth, and return's a page's worth of Chapters belonging to the specified Story.
count_chapters_by_story_id()
count_chapters_by_story_id(story_id: int) -> int
Takes a Story id and returns the number of Chapters it contains.
search_chapters()
search_chapters(search: str) -> List[Chapter]
Takes a search terms and searches for matches in all Chapters of all Stories belonging to the user.
search_chapters_by_story_id()
search_chapters_by_story_id(story_id: int, search: str) -> List[Chapter]
Takes a Story id and a search terms, and returns a list of all Chapters matching the search term in the specified Story.
has_scenes()
has_scenes(chapter_id: int) -> bool
Takes a Chapter id and returns True if the specified Chapter contains Scenes.
get_scene_by_position()
get_scene_by_position(chapter_id: int, position: int) -> Type[Scene] | None
Takes a Chapter id and a position number and returns the matching Scene, if it exists, None otherwise.
get_all_scenes_by_chapter_id()
get_all_scenes_by_chapter_id(chapter_id: int) -> List[Type[Scene]]
Takes a Chapter id and returns a list containing all of its Scenes.
append_links_to_chapter()
append_links_to_chapter(chapter_id: int, link_ids: list) -> Type[Chapter]
Takes a Chapter id and a list of Link ids and returns the updated Chapter containing the appended Links.
get_links_by_chapter_id()
get_links_by_chapter_id(chapter_id: int) -> List[Type[Link]]
Takes a Chapter id and returns a list containing its Links, if there are any.
append_notes_to_chapter()
append_notes_to_chapter(chapter_id: int, note_ids: list) -> Type[Chapter]
Takes a Chapter id and a list of Note ids and returns the updated Chapter containing the appended Notes.
get_notes_by_chapter_id()
get_notes_by_chapter_id(chapter_id: int) -> List[Type[Note]]
Takes a Chapter id and returns a list containing its Notes, if there are any.