mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-25 10:03:11 -05:00
* update tag route * search.and * offset for mobile * relative imports * get settings * new page * category/tag CRUD * bulk assign frontend * Bulk assign * debounce search * remove dev data * recipe store refactor * fix mobile view * fix failing tests * commit test data Co-authored-by: hay-kot <hay-kot@pm.me>
44 lines
815 B
Python
44 lines
815 B
Python
from typing import List, Optional
|
|
|
|
from fastapi_camelcase import CamelModel
|
|
from mealie.schema.recipe import Recipe
|
|
from pydantic.utils import GetterDict
|
|
|
|
|
|
class CategoryIn(CamelModel):
|
|
name: str
|
|
|
|
|
|
class CategoryBase(CategoryIn):
|
|
id: int
|
|
slug: str
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
@classmethod
|
|
def getter_dict(_cls, name_orm):
|
|
return {
|
|
**GetterDict(name_orm),
|
|
"total_recipes": len(name_orm.recipes),
|
|
}
|
|
|
|
|
|
class RecipeCategoryResponse(CategoryBase):
|
|
recipes: Optional[List[Recipe]]
|
|
|
|
class Config:
|
|
schema_extra = {"example": {"id": 1, "name": "dinner", "recipes": [{}]}}
|
|
|
|
|
|
class TagIn(CategoryIn):
|
|
pass
|
|
|
|
|
|
class TagBase(CategoryBase):
|
|
pass
|
|
|
|
|
|
class RecipeTagResponse(RecipeCategoryResponse):
|
|
pass
|