Skip to content

Task List

CLASS DESCRIPTION
TaskList

Python interface for Planka TaskLists

TaskList

TaskList(schema: Schema, session: Planka)

Bases: PlankaModel[TaskList]

Python interface for Planka TaskLists

METHOD DESCRIPTION
add_task

Create a new Task in the TaskList

copy

Create a deepcopy of the model and its associated schema.

delete

Delete the TaskList

diff

Get a schema diff between two model schemas.

positon

Set the TaskList position within the Card

sync

Sync the TaskList with the Planka server

update

Update the TaskList

ATTRIBUTE DESCRIPTION
__formatter__

Formatter func that allows overriding str behavior for models

TYPE: ModelFormatter[Self]

card

The Card the TaskList belongs to

TYPE: Card

created_at

When the TaskList was created

TYPE: datetime

hide_completed_tasks

Whether to hide completed Tasks

TYPE: bool

name

Name/title of the TaskList

TYPE: str

position

Position of the TaskList within the Card

TYPE: int

show_on_front_of_card

Whether to show the TaskList on the front of the Card

TYPE: bool

tasks

All Tasks associated with the TaskList

TYPE: list[Task]

updated_at

When the TaskList was last updated

TYPE: datetime

Source code in src/plankapy/v2/models/_base.py
30
31
32
33
34
35
36
def __init__(self, schema: Schema, session: Planka) -> None:
    self._schema = schema
    self.session = session
    self.endpoints = session.endpoints
    self.client = session.client
    self.current_role = session.current_role
    self.current_id = session.current_id

__formatter__ class-attribute instance-attribute

__formatter__: ModelFormatter[Self] = DEFAULT_FORMATTER

Formatter func that allows overriding str behavior for models

card property

card: Card

The Card the TaskList belongs to

created_at property

created_at: datetime

When the TaskList was created

hide_completed_tasks property writable

hide_completed_tasks: bool

Whether to hide completed Tasks

name property writable

name: str

Name/title of the TaskList

position property

position: int

Position of the TaskList within the Card

show_on_front_of_card property writable

show_on_front_of_card: bool

Whether to show the TaskList on the front of the Card

tasks property

tasks: list[Task]

All Tasks associated with the TaskList

updated_at property

updated_at: datetime

When the TaskList was last updated

add_task

add_task(name: str, *, is_completed: bool = False, position: Position = 'top', linked_card: Card | None = None) -> Task

Create a new Task in the TaskList

PARAMETER DESCRIPTION

name

The name of the task

TYPE: str

is_completed

Is the task completed or not (default: False)

TYPE: bool DEFAULT: False

position

Position of the task in the TaskList (default: top)

TYPE: Position | int DEFAULT: 'top'

linked_card

Optional Card to link the Task to (default: None)

TYPE: Card | None DEFAULT: None

Source code in src/plankapy/v2/models/task_list.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def add_task(self, name: str, *, 
             is_completed: bool=False, 
             position: Position='top',
             linked_card: Card|None=None) -> Task:
    """Create a new Task in the TaskList

    Args:
        name (str): The name of the task
        is_completed (bool): Is the task completed or not (default: `False`)
        position (Position | int): Position of the task in the TaskList (default: `top`)
        linked_card (Card|None): Optional Card to link the Task to (default: `None`)
    """
    args = { # type: ignore
        'name': name,
        'position': get_position(self.tasks, position),
        'isCompleted': is_completed
    }
    if linked_card is not None:
        args['linkedCardId'] = linked_card.id

    return Task(
        self.endpoints.createTask(
            self.id, 
            **args, # type: ignore
            )['item'],  
        self.session
    )

copy

copy() -> Self

Create a deepcopy of the model and its associated schema.

Note

Since the endpoints for both instances of the Model are the same, any calls to update will restore the state and bring both copies into sync. copies like this are meant more for comparing changes when running a sync or update/assignemnt operation.

Example:

    >>> card_copy = card.copy()
    >>> card.name = 'Updated Name'
    >>> card_copy.name
    'Original Name'
    >>> card.name
    'Updated Name'
    >>> # This update may have had side effects
    >>> print(card_copy.diff(card))
    {'name': ('Original Name', 'Updated Name'), 'updatedAt': ('...2:00pm', '...2:45pm'), ...}

Source code in src/plankapy/v2/models/_base.py
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def copy(self) -> Self:
    """Create a deepcopy of the model and its associated schema.

    Note:
        Since the endpoints for both instances of the Model are the same, any 
        calls to update will restore the state and bring both copies into sync. 
        copies like this are meant more for comparing changes when running a sync 
        or update/assignemnt operation.

    Example:
    ```python
        >>> card_copy = card.copy()
        >>> card.name = 'Updated Name'
        >>> card_copy.name
        'Original Name'
        >>> card.name
        'Updated Name'
        >>> # This update may have had side effects
        >>> print(card_copy.diff(card))
        {'name': ('Original Name', 'Updated Name'), 'updatedAt': ('...2:00pm', '...2:45pm'), ...}
    ```
    """
    return copy.deepcopy(self)

delete

delete()

Delete the TaskList

Source code in src/plankapy/v2/models/task_list.py
96
97
98
def delete(self):
    """Delete the TaskList"""
    self.endpoints.deleteTaskList(self.id)

diff

diff(other: PlankaModel[Schema]) -> Diff

Get a schema diff between two model schemas.

Note

Only matching keys are diffed. Any schema keys that are not in the source schema will not be checked in the target schema

Source code in src/plankapy/v2/models/_base.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def diff(self, other: PlankaModel[Schema]) -> Diff:
    """Get a schema diff between two model schemas.

    Note:
        Only matching keys are diffed. Any schema keys that are not in the source schema 
        will not be checked in the target schema
    """
    return {
        k: (source, delta) 
        for k, source in self.schema
        if k in other.schema
        and (delta := other.schema[k]) 
        and delta != source
    }

positon

positon(position: int) -> None

Set the TaskList position within the Card

Source code in src/plankapy/v2/models/task_list.py
46
47
48
49
@position.setter
def positon(self, position: int) -> None:
    """Set the TaskList position within the Card"""
    self.update(position=position)

sync

sync()

Sync the TaskList with the Planka server

Source code in src/plankapy/v2/models/task_list.py
88
89
90
def sync(self):
    """Sync the TaskList with the Planka server"""
    self.schema = self.endpoints.getTaskList(self.id)['item']

update

update(**kwargs: Unpack[Request_updateTaskList])

Update the TaskList

Source code in src/plankapy/v2/models/task_list.py
92
93
94
def update(self, **kwargs: Unpack[paths.Request_updateTaskList]):
    """Update the TaskList"""
    self.schema = self.endpoints.updateTaskList(self.id, **kwargs)['item']