mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-30 23:54:15 -05:00
* added related user to mealplans * made timeline event message actually optional * added task to create events for mealplan recipes * replaced fk constraint ops with bulk ops * fixed event creation and adjusted query range * indentation is hard * added missing recipe id query filter * added tests
63 lines
1.3 KiB
Python
63 lines
1.3 KiB
Python
from datetime import date
|
|
from enum import Enum
|
|
from uuid import UUID
|
|
|
|
from pydantic import validator
|
|
|
|
from mealie.schema._mealie import MealieModel
|
|
from mealie.schema.recipe.recipe import RecipeSummary
|
|
from mealie.schema.response.pagination import PaginationBase
|
|
|
|
|
|
class PlanEntryType(str, Enum):
|
|
breakfast = "breakfast"
|
|
lunch = "lunch"
|
|
dinner = "dinner"
|
|
side = "side"
|
|
|
|
|
|
class CreateRandomEntry(MealieModel):
|
|
date: date
|
|
entry_type: PlanEntryType = PlanEntryType.dinner
|
|
|
|
|
|
class CreatePlanEntry(MealieModel):
|
|
date: date
|
|
entry_type: PlanEntryType = PlanEntryType.breakfast
|
|
title: str = ""
|
|
text: str = ""
|
|
recipe_id: UUID | None
|
|
|
|
@validator("recipe_id", always=True)
|
|
@classmethod
|
|
def id_or_title(cls, value, values):
|
|
if bool(value) is False and bool(values["title"]) is False:
|
|
raise ValueError(f"`recipe_id={value}` or `title={values['title']}` must be provided")
|
|
|
|
return value
|
|
|
|
|
|
class UpdatePlanEntry(CreatePlanEntry):
|
|
id: int
|
|
group_id: UUID
|
|
user_id: UUID | None
|
|
|
|
|
|
class SavePlanEntry(CreatePlanEntry):
|
|
group_id: UUID
|
|
user_id: UUID | None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class ReadPlanEntry(UpdatePlanEntry):
|
|
recipe: RecipeSummary | None
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class PlanEntryPagination(PaginationBase):
|
|
items: list[ReadPlanEntry]
|