mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-16 08:52:21 -05:00
45 lines
782 B
Python
45 lines
782 B
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from fastapi_camelcase import CamelModel
|
|
from pydantic.utils import GetterDict
|
|
|
|
|
|
class UserBase(CamelModel):
|
|
id: int
|
|
username: Optional[str]
|
|
admin: bool
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class CommentIn(CamelModel):
|
|
text: str
|
|
|
|
|
|
class CommentSaveToDB(CommentIn):
|
|
recipe_slug: str
|
|
user: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class CommentOut(CommentIn):
|
|
id: int
|
|
uuid: str
|
|
recipe_slug: str
|
|
date_added: datetime
|
|
user: UserBase
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
@classmethod
|
|
def getter_dict(_cls, name_orm):
|
|
return {
|
|
**GetterDict(name_orm),
|
|
"recipe_slug": name_orm.recipe.slug,
|
|
}
|