feat(backend): 🗃️ Add CRUD opertaions for Food and Units

This commit is contained in:
hay-kot
2021-08-22 13:10:18 -08:00
parent c894d3d880
commit 122d35ec09
9 changed files with 255 additions and 99 deletions

View File

@@ -11,6 +11,7 @@ from pydantic.utils import GetterDict
from slugify import slugify
from .comments import CommentOut
from .units_and_foods import IngredientFood, IngredientUnit
class CreateRecipe(CamelModel):
@@ -73,23 +74,11 @@ class Nutrition(CamelModel):
orm_mode = True
class RecipeIngredientFood(CamelModel):
name: str = ""
description: str = ""
class Config:
orm_mode = True
class RecipeIngredientUnit(RecipeIngredientFood):
pass
class RecipeIngredient(CamelModel):
title: Optional[str]
note: Optional[str]
unit: Optional[RecipeIngredientUnit]
food: Optional[RecipeIngredientFood]
unit: Optional[IngredientUnit]
food: Optional[IngredientFood]
disable_amount: bool = True
quantity: int = 1

View File

@@ -0,0 +1,24 @@
from fastapi_camelcase import CamelModel
class CreateIngredientFood(CamelModel):
name: str
description: str = ""
class CreateIngredientUnit(CreateIngredientFood):
abbreviation: str = ""
class IngredientFood(CreateIngredientFood):
id: int
class Config:
orm_mode = True
class IngredientUnit(CreateIngredientUnit):
id: int
class Config:
orm_mode = True