mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-22 22:59:41 +02:00
feat(backend): ✨ add initial cookbook support
This commit is contained in:
parent
83ab858e46
commit
d24e95c091
27 changed files with 284 additions and 490 deletions
38
mealie/schema/cookbook/cookbook.py
Normal file
38
mealie/schema/cookbook/cookbook.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
from fastapi_camelcase import CamelModel
|
||||
from pydantic import validator
|
||||
from slugify import slugify
|
||||
|
||||
from ..recipe.recipe_category import CategoryBase
|
||||
|
||||
|
||||
class CreateCookBook(CamelModel):
|
||||
name: 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 UpdateCookBook(CreateCookBook):
|
||||
id: int
|
||||
|
||||
|
||||
class SaveCookBook(CreateCookBook):
|
||||
group_id: int
|
||||
|
||||
|
||||
class ReadCookBook(UpdateCookBook):
|
||||
group_id: int
|
||||
categories: list[CategoryBase] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
Loading…
Add table
Add a link
Reference in a new issue