cddb07a176
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from typing import Optional
|
|
|
|
from pydantic import Field
|
|
|
|
from invokeai.app.services.board_records.board_records_common import BoardRecord
|
|
|
|
|
|
class BoardDTO(BoardRecord):
|
|
"""Deserialized board record with cover image URL and image count."""
|
|
|
|
cover_image_name: Optional[str] = Field(description="The name of the board's cover image.")
|
|
"""The URL of the thumbnail of the most recent image in the board."""
|
|
image_count: int = Field(description="The number of images in the board.")
|
|
"""The number of images in the board."""
|
|
asset_count: int = Field(description="The number of assets in the board.")
|
|
"""The number of assets in the board."""
|
|
owner_username: Optional[str] = Field(default=None, description="The username of the board owner (for admin view).")
|
|
"""The username of the board owner (for admin view)."""
|
|
|
|
|
|
def board_record_to_dto(
|
|
board_record: BoardRecord,
|
|
cover_image_name: Optional[str],
|
|
image_count: int,
|
|
asset_count: int,
|
|
owner_username: Optional[str] = None,
|
|
) -> BoardDTO:
|
|
"""Converts a board record to a board DTO."""
|
|
return BoardDTO(
|
|
**board_record.model_dump(exclude={"cover_image_name"}),
|
|
cover_image_name=cover_image_name,
|
|
image_count=image_count,
|
|
asset_count=asset_count,
|
|
owner_username=owner_username,
|
|
)
|