mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-21 22:13:31 -07:00
fixup
Signed-off-by: Litchi Pi <litchi.pi@proton.me>
This commit is contained in:
parent
8de0b4e6d1
commit
8728bb372d
1 changed files with 11 additions and 5 deletions
|
@ -36,7 +36,15 @@ from mealie.services.scraper import cleaner
|
|||
|
||||
from .template_service import TemplateService
|
||||
|
||||
POSSIBLE_NONE_FIELDS = ["image", "recipe_yield"]
|
||||
MANDATORY_FIELDS = [
|
||||
"name",
|
||||
"user_id",
|
||||
"household_id",
|
||||
"group_id",
|
||||
"tags",
|
||||
"recipe_ingredient",
|
||||
"recipe_instructions",
|
||||
]
|
||||
|
||||
|
||||
class RecipeServiceBase(BaseService):
|
||||
|
@ -140,6 +148,7 @@ class RecipeService(RecipeServiceBase):
|
|||
if not additional_attrs.get("recipe_instructions"):
|
||||
additional_attrs["recipe_instructions"] = [RecipeStep(text=self.t("recipe.recipe-defaults.step-text"))]
|
||||
|
||||
assert all(f in additional_attrs for f in MANDATORY_FIELDS)
|
||||
return Recipe(**additional_attrs)
|
||||
|
||||
def get_one(self, slug_or_id: str | UUID) -> Recipe:
|
||||
|
@ -389,10 +398,7 @@ class RecipeService(RecipeServiceBase):
|
|||
|
||||
if strict:
|
||||
for field in new_data.__class__.model_fields:
|
||||
if field in POSSIBLE_NONE_FIELDS:
|
||||
continue
|
||||
|
||||
if getattr(new_data, field) is None:
|
||||
if field in MANDATORY_FIELDS and getattr(new_data, field) is None:
|
||||
raise exceptions.IncompleteData("Incomplete recipe", field)
|
||||
|
||||
if recipe is None or recipe.settings is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue