mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-22 22:59:41 +02:00
* update to GUIDs * fix cookbook id relationships * update webhook keys * cleanup naming and attribute orders * remove old database tables * fix meal-plan images * remove dashbaord and events api * use recipe-id instead of id * cleanup documentation assets * cleanup docs for v1 beta-release * add depends_on for docker-compose * use docker volumes for examples * move caddy to frontend container
47 lines
982 B
Python
47 lines
982 B
Python
from fastapi_camelcase import CamelModel
|
|
from pydantic import UUID4, validator
|
|
from slugify import slugify
|
|
|
|
from ..recipe.recipe_category import CategoryBase, RecipeCategoryResponse
|
|
|
|
|
|
class CreateCookBook(CamelModel):
|
|
name: str
|
|
description: str = ""
|
|
slug: str = None
|
|
position: int = 1
|
|
categories: list[CategoryBase] = []
|
|
|
|
@validator("slug", always=True, pre=True)
|
|
def validate_slug(slug: str, values):
|
|
name: str = values["name"]
|
|
calc_slug: str = slugify(name)
|
|
|
|
if slug != calc_slug:
|
|
slug = calc_slug
|
|
|
|
return slug
|
|
|
|
|
|
class SaveCookBook(CreateCookBook):
|
|
group_id: UUID4
|
|
|
|
|
|
class UpdateCookBook(SaveCookBook):
|
|
id: UUID4
|
|
|
|
|
|
class ReadCookBook(UpdateCookBook):
|
|
group_id: UUID4
|
|
categories: list[CategoryBase] = []
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class RecipeCookBook(ReadCookBook):
|
|
group_id: UUID4
|
|
categories: list[RecipeCategoryResponse]
|
|
|
|
class Config:
|
|
orm_mode = True
|