feat: Add the ability to flag a food as "on hand", to exclude from shopping list (#3777)

This commit is contained in:
boc-the-git
2024-06-29 01:16:04 +10:00
committed by GitHub
parent 4831adb0f3
commit a062a4beaa
8 changed files with 112 additions and 9 deletions

View File

@@ -36,6 +36,7 @@ class UnitFoodBase(MealieModel):
plural_name: str | None = None
description: str = ""
extras: dict | None = {}
on_hand: bool = False
@field_validator("id", mode="before")
def convert_empty_id_to_none(cls, v):
@@ -79,13 +80,19 @@ class IngredientFood(CreateIngredientFood):
created_at: datetime.datetime | None = None
update_at: datetime.datetime | None = None
_searchable_properties: ClassVar[list[str]] = ["name_normalized", "plural_name_normalized"]
_searchable_properties: ClassVar[list[str]] = [
"name_normalized",
"plural_name_normalized",
]
_normalize_search: ClassVar[bool] = True
model_config = ConfigDict(from_attributes=True)
@classmethod
def loader_options(cls) -> list[LoaderOption]:
return [joinedload(IngredientFoodModel.extras), joinedload(IngredientFoodModel.label)]
return [
joinedload(IngredientFoodModel.extras),
joinedload(IngredientFoodModel.label),
]
class IngredientFoodPagination(PaginationBase):