Skip to content

List

Bases: List_

Source code in src/plankapy/interfaces.py
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
class List(List_):

    @property
    def board(self) -> Board:
        """Board the list belongs to

        Returns:
            Board: Board instance
        """
        board_route = self.routes.get_board(id=self.boardId)
        return Board(**board_route()['item']).bind(self.routes)

    @property
    def cards(self) -> QueryableList[Card]:
        """All cards in the list

        Returns:
            Queryable List of all cards in the list
        """
        return QueryableList([
            card
            for card in self.board.cards
            if card.listId == self.id
        ])

    @overload
    def create_card(self, card: Card) -> Card: ...

    @overload
    def create_card(self, name: str, position: int=0, 
                    description: str=None, dueDate: datetime=None,
                    isDueDateCompleted: bool=None,
                    stopwatch: Stopwatch=None, boardId: int=None,
                    listId: int=None, creatorUserId: int=None,
                    coverAttachmentId: int=None, isSubscribed: bool=None) -> Card: ...

    def create_card(self, *args, **kwargs) -> Card:
        """Creates a card in the list

        Args:
            name (str): Name of the card (required)
            position (int): Position of the card (default: 0)
            description (str): Description of the card (optional)
            dueDate (datetime): Due date of the card (optional)
            isDueDateCompleted (bool): Whether the due date is completed (optional)
            stopwatch (Stopwatch): Stopwatch of the card (optional)
            boardId (int): Board id of the card (optional)
            listId (int): List id of the card (optional)
            creatorUserId (int): Creator user id of the card (optional)
            coverAttachmentId (int): Cover attachment id of the card (optional)
            isSubscribed (bool): Whether the card is subscribed (optional)

        Args: Alternate
            card (Card): Card instance to create

        Returns:
            Card: New card instance
        """
        overload = parse_overload(
            args, kwargs, 
            model='card', 
            options=('name', 'position', 'description', 'dueDate', 
                    'isDueDateCompleted', 'stopwatch', 
                    'creatorUserId', 'coverAttachmentId', 
                    'isSubscribed'), 
            required=('name',))

        overload['boardId'] = self.boardId
        overload['listId'] = self.id
        overload['position'] = overload.get('position', 0)

        route = self.routes.post_card(id=self.id)
        return Card(**route(**overload)['item']).bind(self.routes)

    def _sort(self, sort: SortOption) -> None:
        route = self.routes.post_sort_list(id=self.id)
        route(**{'type': ListSorts[sort]})

    def sort_by_name(self) -> None:
        """Sorts cards in the list by name

        Note:
            After sorting, a call to `list.cards` will return a sorted list of cards
        """
        self._sort('Name')

    def sort_by_due_date(self) -> None:
        """Sorts cards in the list by due date

        Note:
            After sorting, a call to `list.cards` will return a sorted list of cards
        """
        self._sort('Due date')

    def sort_by_newest(self) -> None:
        """Sorts cards in the list by newest first

        Note:
            After sorting, a call to `list.cards` will return a sorted list of cards
        """
        self._sort('Newest First')

    def sort_by_oldest(self) -> None:
        """Sorts cards in the list by oldest first

        Note:
            After sorting, a call to `list.cards` will return a sorted list of cards
        """
        self._sort('Oldest First')

    def delete(self) -> List:
        """Deletes the list

        Danger:
            This action is irreversible and cannot be undone

        Returns:
            List: Deleted list instance
        """
        self.refresh()
        route = self.routes.delete_list(id=self.id)
        route()
        return self

    @overload
    def update(self) -> List: ...

    @overload
    def update(self, list: List) -> List: ...

    @overload
    def update(self, name: str=None, position: int=None) -> List: ...

    def update(self, *args, **kwargs) -> List:
        """Updates the list with new values

        Tip:
            If you want to update a list, it's better to use the `editor()` context manager

            Example:
            ```python
            >>> with list_.editor():
            ...    list_.name = 'New List Name'
            ...    list_.position = 1

            >>> list
            List(id=1, name='New List Name', position=1, ...)
            ```

        Args:
            name (str): Name of the list (optional)
            position (int): Position of the list (optional)

        Args: Alternate
            list (List): List instance to update (required)

        Note:
            If no arguments are provided, the list will update itself with the current values stored in its attributes

        Returns:
            List: Updated list instance
        """
        overload = parse_overload(
            args, kwargs, 
            model='list', 
            options=('name', 'position'),
            noarg=self)

        route = self.routes.patch_list(id=self.id)
        self.__init__(**route(**overload)['item'])
        return self

    def refresh(self) -> None:
        """Refreshes the list data"""
        for _list in self.board.lists:
            if _list.id == self.id:
                self.__init__(**_list)

board property

Board the list belongs to

Returns:

Name Type Description
Board Board

Board instance

cards property

All cards in the list

Returns:

Type Description
QueryableList[Card]

Queryable List of all cards in the list

create_card(*args, **kwargs)

create_card(card: Card) -> Card
create_card(name: str, position: int = 0, description: str = None, dueDate: datetime = None, isDueDateCompleted: bool = None, stopwatch: Stopwatch = None, boardId: int = None, listId: int = None, creatorUserId: int = None, coverAttachmentId: int = None, isSubscribed: bool = None) -> Card

Creates a card in the list

Parameters:

Name Type Description Default
name str

Name of the card (required)

required
position int

Position of the card (default: 0)

required
description str

Description of the card (optional)

required
dueDate datetime

Due date of the card (optional)

required
isDueDateCompleted bool

Whether the due date is completed (optional)

required
stopwatch Stopwatch

Stopwatch of the card (optional)

required
boardId int

Board id of the card (optional)

required
listId int

List id of the card (optional)

required
creatorUserId int

Creator user id of the card (optional)

required
coverAttachmentId int

Cover attachment id of the card (optional)

required
isSubscribed bool

Whether the card is subscribed (optional)

required

Alternate

Name Type Description Default
card Card

Card instance to create

required

Returns:

Name Type Description
Card Card

New card instance

Source code in src/plankapy/interfaces.py
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
def create_card(self, *args, **kwargs) -> Card:
    """Creates a card in the list

    Args:
        name (str): Name of the card (required)
        position (int): Position of the card (default: 0)
        description (str): Description of the card (optional)
        dueDate (datetime): Due date of the card (optional)
        isDueDateCompleted (bool): Whether the due date is completed (optional)
        stopwatch (Stopwatch): Stopwatch of the card (optional)
        boardId (int): Board id of the card (optional)
        listId (int): List id of the card (optional)
        creatorUserId (int): Creator user id of the card (optional)
        coverAttachmentId (int): Cover attachment id of the card (optional)
        isSubscribed (bool): Whether the card is subscribed (optional)

    Args: Alternate
        card (Card): Card instance to create

    Returns:
        Card: New card instance
    """
    overload = parse_overload(
        args, kwargs, 
        model='card', 
        options=('name', 'position', 'description', 'dueDate', 
                'isDueDateCompleted', 'stopwatch', 
                'creatorUserId', 'coverAttachmentId', 
                'isSubscribed'), 
        required=('name',))

    overload['boardId'] = self.boardId
    overload['listId'] = self.id
    overload['position'] = overload.get('position', 0)

    route = self.routes.post_card(id=self.id)
    return Card(**route(**overload)['item']).bind(self.routes)

delete()

Deletes the list

Danger

This action is irreversible and cannot be undone

Returns:

Name Type Description
List List

Deleted list instance

Source code in src/plankapy/interfaces.py
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
def delete(self) -> List:
    """Deletes the list

    Danger:
        This action is irreversible and cannot be undone

    Returns:
        List: Deleted list instance
    """
    self.refresh()
    route = self.routes.delete_list(id=self.id)
    route()
    return self

refresh()

Refreshes the list data

Source code in src/plankapy/interfaces.py
2537
2538
2539
2540
2541
def refresh(self) -> None:
    """Refreshes the list data"""
    for _list in self.board.lists:
        if _list.id == self.id:
            self.__init__(**_list)

sort_by_due_date()

Sorts cards in the list by due date

Note

After sorting, a call to list.cards will return a sorted list of cards

Source code in src/plankapy/interfaces.py
2451
2452
2453
2454
2455
2456
2457
def sort_by_due_date(self) -> None:
    """Sorts cards in the list by due date

    Note:
        After sorting, a call to `list.cards` will return a sorted list of cards
    """
    self._sort('Due date')

sort_by_name()

Sorts cards in the list by name

Note

After sorting, a call to list.cards will return a sorted list of cards

Source code in src/plankapy/interfaces.py
2443
2444
2445
2446
2447
2448
2449
def sort_by_name(self) -> None:
    """Sorts cards in the list by name

    Note:
        After sorting, a call to `list.cards` will return a sorted list of cards
    """
    self._sort('Name')

sort_by_newest()

Sorts cards in the list by newest first

Note

After sorting, a call to list.cards will return a sorted list of cards

Source code in src/plankapy/interfaces.py
2459
2460
2461
2462
2463
2464
2465
def sort_by_newest(self) -> None:
    """Sorts cards in the list by newest first

    Note:
        After sorting, a call to `list.cards` will return a sorted list of cards
    """
    self._sort('Newest First')

sort_by_oldest()

Sorts cards in the list by oldest first

Note

After sorting, a call to list.cards will return a sorted list of cards

Source code in src/plankapy/interfaces.py
2467
2468
2469
2470
2471
2472
2473
def sort_by_oldest(self) -> None:
    """Sorts cards in the list by oldest first

    Note:
        After sorting, a call to `list.cards` will return a sorted list of cards
    """
    self._sort('Oldest First')

update(*args, **kwargs)

update() -> List
update(list: List) -> List
update(name: str = None, position: int = None) -> List

Updates the list with new values

Tip

If you want to update a list, it's better to use the editor() context manager

Example:

>>> with list_.editor():
...    list_.name = 'New List Name'
...    list_.position = 1

>>> list
List(id=1, name='New List Name', position=1, ...)

Parameters:

Name Type Description Default
name str

Name of the list (optional)

required
position int

Position of the list (optional)

required

Alternate

Name Type Description Default
list List

List instance to update (required)

required
Note

If no arguments are provided, the list will update itself with the current values stored in its attributes

Returns:

Name Type Description
List List

Updated list instance

Source code in src/plankapy/interfaces.py
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
def update(self, *args, **kwargs) -> List:
    """Updates the list with new values

    Tip:
        If you want to update a list, it's better to use the `editor()` context manager

        Example:
        ```python
        >>> with list_.editor():
        ...    list_.name = 'New List Name'
        ...    list_.position = 1

        >>> list
        List(id=1, name='New List Name', position=1, ...)
        ```

    Args:
        name (str): Name of the list (optional)
        position (int): Position of the list (optional)

    Args: Alternate
        list (List): List instance to update (required)

    Note:
        If no arguments are provided, the list will update itself with the current values stored in its attributes

    Returns:
        List: Updated list instance
    """
    overload = parse_overload(
        args, kwargs, 
        model='list', 
        options=('name', 'position'),
        noarg=self)

    route = self.routes.patch_list(id=self.id)
    self.__init__(**route(**overload)['item'])
    return self