mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-16 12:53:12 -05:00
Feature/shopping lists second try (#927)
* generate types * use generated types * ui updates * init button link for common styles * add links * setup label views * add delete confirmation * reset when not saved * link label to foods and auto set when adding to shopping list * generate types * use inheritence to manage exception handling * fix schema generation and add test for open_api generation * add header to api docs * move list consilidation to service * split list and list items controller * shopping list/list item tests - PARTIAL * enable recipe add/remove in shopping lists * generate types * linting * init global utility components * update types and add list item api * fix import cycle and database error * add container and border classes * new recipe list component * fix tests * breakout item editor * refactor item editor * update bulk actions * update input / color contrast * type generation * refactor controller dependencies * include food/unit editor * remove console.logs * fix and update type generation * fix incorrect type for column * fix postgres error * fix delete by variable * auto remove refs * fix typo
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from fastapi_camelcase import CamelModel
|
||||
@@ -6,6 +8,19 @@ from pydantic import UUID4
|
||||
from mealie.schema.recipe.recipe_ingredient import IngredientFood, IngredientUnit
|
||||
|
||||
|
||||
class ShoppingListItemRecipeRef(CamelModel):
|
||||
recipe_id: int
|
||||
recipe_quantity: float
|
||||
|
||||
|
||||
class ShoppingListItemRecipeRefOut(ShoppingListItemRecipeRef):
|
||||
id: UUID4
|
||||
shopping_list_item_id: UUID4
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListItemCreate(CamelModel):
|
||||
shopping_list_id: UUID4
|
||||
checked: bool = False
|
||||
@@ -16,30 +31,41 @@ class ShoppingListItemCreate(CamelModel):
|
||||
note: Optional[str] = ""
|
||||
quantity: float = 1
|
||||
unit_id: int = None
|
||||
unit: IngredientUnit = None
|
||||
unit: Optional[IngredientUnit]
|
||||
food_id: int = None
|
||||
food: IngredientFood = None
|
||||
recipe_id: Optional[int] = None
|
||||
food: Optional[IngredientFood]
|
||||
|
||||
label_id: Optional[UUID4] = None
|
||||
recipe_references: list[ShoppingListItemRecipeRef] = []
|
||||
|
||||
|
||||
class ShoppingListItemOut(ShoppingListItemCreate):
|
||||
class ShoppingListItemUpdate(ShoppingListItemCreate):
|
||||
id: UUID4
|
||||
label: "Optional[MultiPurposeLabelSummary]" = None
|
||||
|
||||
|
||||
class ShoppingListItemOut(ShoppingListItemUpdate):
|
||||
label: Optional[MultiPurposeLabelSummary]
|
||||
recipe_references: list[ShoppingListItemRecipeRefOut] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListCreate(CamelModel):
|
||||
"""
|
||||
Create Shopping List
|
||||
"""
|
||||
|
||||
name: str = None
|
||||
|
||||
|
||||
class ShoppingListRecipeRefOut(CamelModel):
|
||||
id: UUID4
|
||||
shopping_list_id: UUID4
|
||||
recipe_id: int
|
||||
recipe_quantity: float
|
||||
recipe: RecipeSummary
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
class ShoppingListSave(ShoppingListCreate):
|
||||
group_id: UUID4
|
||||
|
||||
@@ -56,10 +82,14 @@ class ShoppingListUpdate(ShoppingListSummary):
|
||||
|
||||
|
||||
class ShoppingListOut(ShoppingListUpdate):
|
||||
recipe_references: list[ShoppingListRecipeRefOut]
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
from mealie.schema.labels import MultiPurposeLabelSummary
|
||||
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary
|
||||
from mealie.schema.recipe.recipe import RecipeSummary
|
||||
|
||||
ShoppingListRecipeRefOut.update_forward_refs()
|
||||
ShoppingListItemOut.update_forward_refs()
|
||||
|
||||
Reference in New Issue
Block a user