move kontor_model in kontor-api (#98)
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Co-authored-by: Thomas Peetz <thomas.peetz@cimt-ag.de> Reviewed-on: #98
This commit was merged in pull request #98.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Schema definitions for Comics.
|
||||
"""
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, AnyUrl
|
||||
|
||||
from src.db.models.comic import Comic
|
||||
|
||||
|
||||
class ComicResponse(BaseModel):
|
||||
"""
|
||||
Pydantic model for returning Comic objects.
|
||||
"""
|
||||
id: str
|
||||
created_date: datetime
|
||||
last_modified_date: datetime
|
||||
version: int
|
||||
title: str
|
||||
publisher_id: str
|
||||
current_order: bool
|
||||
completed: bool
|
||||
weblink: Optional[str]
|
||||
|
||||
def comic_to_response(comic: Comic) -> ComicResponse:
|
||||
response: ComicResponse = ComicResponse(
|
||||
id=comic.id,
|
||||
created_date=comic.created_date,
|
||||
last_modified_date=comic.last_modified_date,
|
||||
version=comic.version,
|
||||
title=str(comic.title),
|
||||
publisher_id=str(comic.publisher_id),
|
||||
current_order=bool(comic.current_order),
|
||||
completed=bool(comic.completed),
|
||||
weblink=str(comic.weblink)
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
class ComicSchema(BaseModel):
|
||||
"""
|
||||
Pydantic model for uploading Comic object.
|
||||
"""
|
||||
id: str
|
||||
title: str
|
||||
weblink: Optional[AnyUrl]
|
||||
completed: Optional[bool]
|
||||
current_order: Optional[bool]
|
||||
Reference in New Issue
Block a user