add actions to board and image DTO

This commit is contained in:
Mary Hipp 2023-12-06 13:16:02 -05:00
parent db58efbe65
commit a2d8af0024
2 changed files with 14 additions and 1 deletions

View File

@ -12,12 +12,18 @@ class BoardDTO(BoardRecord):
"""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."""
actions: Optional[dict[str, bool]] = Field(
default=None,
description="Allowed actions on board."
)
"""Allowed actions on board."""
def board_record_to_dto(board_record: BoardRecord, cover_image_name: Optional[str], image_count: int) -> BoardDTO:
def board_record_to_dto(board_record: BoardRecord, cover_image_name: Optional[str], image_count: int, actions: Optional[dict[str, bool]]) -> 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,
actions=actions
)

View File

@ -29,6 +29,11 @@ class ImageDTO(ImageRecord, ImageUrlsDTO):
description="The workflow that generated this image.",
)
"""The workflow that generated this image."""
actions: Optional[dict[str, bool]] = Field(
default=None,
description="Allowed actions on image."
)
"""Allowed actions on image."""
def image_record_to_dto(
@ -37,6 +42,7 @@ def image_record_to_dto(
thumbnail_url: str,
board_id: Optional[str],
workflow_id: Optional[str],
actions: Optional[dict[str, bool]]
) -> ImageDTO:
"""Converts an image record to an image DTO."""
return ImageDTO(
@ -45,4 +51,5 @@ def image_record_to_dto(
thumbnail_url=thumbnail_url,
board_id=board_id,
workflow_id=workflow_id,
actions=actions
)