CharacterController - applebiter/gnatwriter GitHub Wiki

Character controller encapsulates characters management functionality.

create_character()

create_character(
    title: str = None, honorific: str = None, first_name: str = None,
    middle_name: str = None, last_name: str = None, nickname: str = None, 
    gender: str = None, sex: str = None, ethnicity: str = None, 
    race: str = None, tribe_or_clan: str = None, nationality: str = None,
    religion: str = None, occupation: str = None, education: str = None, 
    marital_status: str = None, children: bool = None, 
    date_of_birth: str = None, date_of_death: str = None,
    description: str = None, mbti: str = None, enneagram: str = None,
    wounds: str = None
) -> Character

No individual parameter is necessary, but in order to create a new Character, at least one of these arguments must contain a value. Returns a new Character.

update_character()

update_character(
    character_id: int = None, title: str = None, 
    honorific: str = None, first_name: str = None, 
    middle_name: str = None, last_name: str = None, 
    nickname: str = None, gender: str = None, sex: str = None, 
    ethnicity: str = None, race: str = None, 
    tribe_or_clan: str = None, nationality: str = None,
    religion: str = None, occupation: str = None, 
    education: str = None, marital_status: str = None, 
    children: bool = None, date_of_birth: str = None, 
    date_of_death: str = None, description: str = None, 
    mbti: str = None, enneagram: str = None, 
    wounds: str = None
) -> Type[Character]

Just like the create_character() method, no specific parameter requires a value, but at least one of the arguments must contain a value. Returns the updated Character.

delete_character()

delete_character(character_id: int) -> bool

Takes a Character id and returns True if the Character is deleted. Note that Characters are complex, nested objects that may contain associated Links and Notes along with other subordinate objects. All of those objects will also be deleted along with the Character.

get_character_by_id()

get_character_by_id(character_id: int) -> Type[Character] | None

Takes a Character id and returns the specified Character if found, None otherwise.

get_character_count()

get_character_count() -> int

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

get_all_characters()

get_all_characters() -> List[Type[Character]]

Returns all Characters in the database belonging to the user.

get_all_characters_page()

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

Takes a page number and another integer describing how many Characters to return per page, then returns a list of Character objects for that page.

get_character_count_by_story_id()

get_character_count_by_story_id(story_id: int) -> int

Takes a Story id and returns the number of Characters in the database appearing in that Story.

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 Characters appearing in the specified Story.

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, and returns a list containing that page of Characters.

search_characters()

search_characters(search: str) -> List[Type[Character]]

Takes a search terms and returns a list of matching Characters, if any.

search_characters_by_story_id()

search_characters_by_story_id(story_id: int, search: str) -> List[Type[Character]]

Takes a Story id and a search term, and returns any matching Characters appearing in the specified Story, if any.

create_relationship()

create_relationship(
    parent_id: int, related_id: int, relationship_type: str,
    description: str = None, start_date: str = None, end_date: str = None
) -> CharacterRelationship

Character Relationships defined for a Character reference that Character as "parent" and the Character to whom parent is related as "related". I half-assedly implemented an enum to specify the base relationship types, but left it up to whomever to actually stick to that plan. The method returns a CharacterRelationship, which is otherwise found in a list as an updated Character's relationships attribute.

update_relationship()

update_relationship(
    relationship_id: int, parent_id: int, related_id: int,
    relationship_type: str, description: str = None, start_date: str = None,
    end_date: str = None
) -> Type[CharacterRelationship]

Almost exactly the same as create_relationship() except with the addition of a CharacterRelationship id. Returns the updated CharacterRelationship.

change_relationship_position()

change_relationship_position(relationship_id: int, position: int) -> Type[CharacterRelationship]

As CharacterRelationships are appended to a Character, they are assigned the next available position. The position can be arbitrarily changed, and the target object's siblings will also be updated to accommodate the new position.

delete_relationship()

delete_relationship(relationship_id: int) -> bool

Takes a CharacterRelationship id and returns True if that object is deleted from the database.

get_relationship_by_id()

get_relationship_by_id(relationship_id: int) -> Type[CharacterRelationship] | None

Takes a CharacterRelationship id and returns the specified CharacterRelationship if found, None otherwise.

get_relationships_by_character_id()

get_relationships_by_character_id(parent_id: int) -> List[Type[CharacterRelationship]]

Takes a Character id and returns a list of CharacterRelationships defined in the target Character.

get_relationships_page_by_character_id()

get_relationships_page_by_character_id(
    parent_id: int, page: int, per_page: int
) -> List[Type[CharacterRelationship]]

Takes a Character id (as the parent_id argument), a page number, and an integer describing how many CharacterRelationships to include per page of results. Returns a list of CharacterRelationships belonging to that page of results.

create_trait()

create_trait(character_id: int, name: str, magnitude: int) -> CharacterTrait

Takes a Character id, the name of a trait you want to define, and then an integer value between 0 and 100 representing the magnitude of the named trait's presence in the Character. Returns a CharacterTrait.

update_trait()

update_trait(trait_id: int, name: str, magnitude: int) -> Type[CharacterTrait]

Takes a CharacterTrait id, name, and magnitude. Returns the updated CharacterTrait.

change_trait_position()

change_trait_position(trait_id: int, position: int) -> Type[CharacterTrait]

As each CharacterTrait is defined, it is assigned to the next available position. The position can be arbitrarily changed and the sibling CharacterTraits will also be updated to accommodate the target object's new position.

delete_trait()

delete_trait(trait_id: int) -> bool

Takes a CharacterTrait id and returns True when the specified object is deleted from the database.

get_trait_by_id()

def get_trait_by_id(self, trait_id: int) -> Type[CharacterTrait] | None

Takes a CharacterTrait id and returns the specified CharacterTrait if found, None otherwise.

get_traits_by_character_id()

get_traits_by_character_id(character_id: int) -> List[Type[CharacterTrait]]

Takes a Character id and returns a list of CharacterTraits belonging to the specified Character.

get_traits_page_by_character_id()

get_traits_page_by_character_id(
    character_id: int, page: int, per_page: int
) -> List[Type[CharacterTrait]]

Takes a Character id, a page number, and an integer specifying how many CharacterTraits to include per page of results. Returns a list of CharacterTraits corresponding to the specified page.

append_events_to_character()

append_events_to_character(character_id: int, event_ids: list) -> Type[Character]

Takes a Character id and one or more Event ids. The corresponding Events will be associated with the Character in the overall timeline of Events. Returns the updated Character.

get_events_by_character_id()

get_events_by_character_id(character_id: int) -> List[Type[Event]]

Takes a Character id and returns a list of Events with which the Character is associated.

get_events_page_by_character_id()

get_events_page_by_character_id(character_id: int, page: int, per_page: int) -> List[Type[Event]]

Takes a Character id, a page number, and an integer specifying how many Events to include per page of results. Returns a list of Characters corresponding to that page of results.

append_links_to_character()

append_links_to_character(character_id: int, link_ids: list) -> Type[Character]

Takes a Character id and a list containing one or more Link ids. The corresponding links are associated with the Character. Returns the updated Character object containing the Links.

get_links_by_character_id()

get_links_by_character_id(character_id: int) -> List[Type[Link]]

Takes a Character id and returns a list of associated Links, if any.

get_links_page_by_character_id()

get_links_page_by_character_id(character_id: int, page: int, per_page: int) -> List[Type[Link]]

Takes a Character id, a page number, and an integer describing how many Links to return per page of results. Returns a list of Links corresponding to that page.

append_notes_to_character()

append_notes_to_character(character_id: int, note_ids: list) -> Type[Character]

Takes a Character id and a list containing one or more Note ids. Returns the updated Character containing the Note(s).

get_notes_by_character_id()

get_notes_by_character_id(character_id: int) -> List[Type[Note]]

Takes a Character id and returns a list of Notes associated with that Character

get_notes_page_by_character_id()

get_notes_page_by_character_id(character_id: int, page: int, per_page: int) -> List[Type[Note]]

Takes a Character id, a page number, and an integer describing how many Notes to return per page of results. Returns a list of Notes corresponding to that page.

append_images_to_character()

append_images_to_character(character_id: int, image_ids: list) -> Type[Character]

Takes a Character id and a list containing one or more Image ids. Returns the updated Character containing the associated Image.

change_image_position()

change_image_position(image_id: int, position: int) -> Type[CharacterImage]

Takes an Image id and a position and assigns the new position to the Image within the Character. The sibling Images are also updated to accommodate the target Image's new position. Returns the target Image.

change_image_default_status()

change_image_default_status(image_id: int, is_default: bool) -> Type[CharacterImage]

delete_image()

delete_image(image_id: int) -> bool

Takes an Image id and returns True if the Image is deleted from the database.

get_image_count_by_character_id()

get_image_count_by_character_id(character_id: int) -> int

Takes a Character id and returns the number of Images are associated with it.

get_images_by_character_id()

get_images_by_character_id(character_id: int) -> List[Type[Image]]

Takes a Character id and returns all Images associated with it.

get_images_page_by_character_id()

get_images_page_by_character_id(character_id: int, page: int, per_page: int) -> List[Type[Image]]

Takes a Character id, a page number, and an integer describing how many Images to return per page of results. Returns a list of Images corresponding to that page.