Skip to content

Custom Field Value

CLASS DESCRIPTION
CustomFieldValue

Python interface for Planka CustomFieldValues

CustomFieldValue

CustomFieldValue(schema: Schema, session: Planka)

Bases: PlankaModel[CustomFieldValue]

Python interface for Planka CustomFieldValues

METHOD DESCRIPTION
copy

Create a deepcopy of the model and its associated schema.

delete

Delete the CustomFieldValue

diff

Get a schema diff between two model schemas.

sync

Sync the CustomFieldValue with the Planka server

update

Update the CustomFieldValue

ATTRIBUTE DESCRIPTION
__formatter__

Formatter func that allows overriding str behavior for models

TYPE: ModelFormatter[Self]

card

The Card the CustomFieldValue belongs to

TYPE: Card

content

Content/value of the custom field

TYPE: str

created_at

When the CustomFieldValue was created

TYPE: datetime

custom_field

The CustomField the CustomFieldValue belongs to

TYPE: CustomField

custom_field_group

The CustomFieldGroup the CustomFieldValue belongs to

TYPE: CustomFieldGroup

updated_at

When the CustomFieldValue 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 CustomFieldValue belongs to

content property writable

content: str

Content/value of the custom field

created_at property

created_at: datetime

When the CustomFieldValue was created

custom_field property

custom_field: CustomField

The CustomField the CustomFieldValue belongs to

custom_field_group property

custom_field_group: CustomFieldGroup

The CustomFieldGroup the CustomFieldValue belongs to

updated_at property

updated_at: datetime

When the CustomFieldValue was last updated

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 CustomFieldValue

Source code in src/plankapy/v2/models/custom_field_value.py
75
76
77
78
79
80
81
def delete(self):
    """Delete the CustomFieldValue"""
    self.endpoints.deleteCustomFieldValue(
        cardId=self.schema['cardId'],
        customFieldGroupId=self.schema['customFieldGroupId'],
        customFieldId=self.schema['customFieldId'],
    )

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
    }

sync

sync()

Sync the CustomFieldValue with the Planka server

Source code in src/plankapy/v2/models/custom_field_value.py
61
62
63
64
65
def sync(self):
    """Sync the CustomFieldValue with the Planka server"""
    _cfvs = [cfv for cfv in self.card.custom_field_values if cfv.id == self.id]
    if _cfvs:
        self.schema = _cfvs.pop().schema

update

Update the CustomFieldValue

Source code in src/plankapy/v2/models/custom_field_value.py
67
68
69
70
71
72
73
def update(self, **kwargs: Unpack[paths.Request_updateCustomFieldValue]):
    """Update the CustomFieldValue"""
    self.schema = self.endpoints.updateCustomFieldValue(
        cardId=self.schema['cardId'],
        customFieldGroupId=self.schema['customFieldGroupId'],
        customFieldId=self.schema['customFieldId'],
        **kwargs)['item']