mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-23 18:55:15 -05:00
feat: Offline Shopping List (#3760)
Co-authored-by: boc-the-git <3479092+boc-the-git@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import UUID4, ConfigDict, field_validator, model_validator
|
||||
from sqlalchemy.orm import joinedload, selectinload
|
||||
@@ -75,8 +76,21 @@ class ShoppingListItemBase(RecipeIngredientBase):
|
||||
|
||||
|
||||
class ShoppingListItemCreate(ShoppingListItemBase):
|
||||
id: UUID4 | None = None
|
||||
"""The unique id of the item to create. If not supplied, one will be generated."""
|
||||
recipe_references: list[ShoppingListItemRecipeRefCreate] = []
|
||||
|
||||
@field_validator("id", mode="before")
|
||||
def validate_id(cls, v):
|
||||
v = v or None
|
||||
if not v or isinstance(v, UUID):
|
||||
return v
|
||||
|
||||
try:
|
||||
return UUID(v)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
class ShoppingListItemUpdate(ShoppingListItemBase):
|
||||
recipe_references: list[ShoppingListItemRecipeRefCreate | ShoppingListItemRecipeRefUpdate] = []
|
||||
|
||||
@@ -22,7 +22,7 @@ class SuccessResponse(BaseModel):
|
||||
error: bool = False
|
||||
|
||||
@classmethod
|
||||
def respond(cls, message: str) -> dict:
|
||||
def respond(cls, message: str = "") -> dict:
|
||||
"""
|
||||
This method is an helper to create an object and convert to a dictionary
|
||||
in the same call, for use while providing details to a HTTPException
|
||||
|
||||
Reference in New Issue
Block a user