Feature/restore-recipe-functionality (#810)

* feat(frontend):  add back support for assets

* feat(backend):  add back support for assets

* feat(frontend):  add support for recipe tools

* feat(backend):  add support for recipe tools

* feat(frontend):  add onHand support for recipe toosl

* feat(backend):  add onHand support for backend

* refactor(frontend): ♻️ move items to recipe folder and break apart types

* feat(frontend):  add support for recipe comments

* feat(backend):  Add support for recipe comments

* fix(backend): 💥 disable comments import

* fix(frontend): 🐛 fix rendering issue with titles when moving steps

* add tools to changelog

* fix type errors

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-11-22 20:10:48 -09:00
committed by GitHub
parent 912cc6d956
commit 7afdd5b577
43 changed files with 1221 additions and 423 deletions

View File

@@ -11,12 +11,13 @@ from mealie.core.config import get_app_dirs
from mealie.db.models.recipe.recipe import RecipeModel
from .recipe_asset import RecipeAsset
from .recipe_comments import CommentOut
from .recipe_comments import RecipeCommentOut
from .recipe_ingredient import RecipeIngredient
from .recipe_notes import RecipeNote
from .recipe_nutrition import Nutrition
from .recipe_settings import RecipeSettings
from .recipe_step import RecipeStep
from .recipe_tool import RecipeTool
app_dirs = get_app_dirs()
@@ -101,7 +102,7 @@ class Recipe(RecipeSummary):
recipe_ingredient: Optional[list[RecipeIngredient]] = []
recipe_instructions: Optional[list[RecipeStep]] = []
nutrition: Optional[Nutrition]
tools: Optional[list[str]] = []
tools: list[RecipeTool] = []
# Mealie Specific
settings: Optional[RecipeSettings] = RecipeSettings()
@@ -109,7 +110,7 @@ class Recipe(RecipeSummary):
notes: Optional[list[RecipeNote]] = []
extras: Optional[dict] = {}
comments: Optional[list[CommentOut]] = []
comments: Optional[list[RecipeCommentOut]] = []
@staticmethod
def directory_from_slug(slug) -> Path:
@@ -143,7 +144,6 @@ class Recipe(RecipeSummary):
# "recipe_ingredient": [x.note for x in name_orm.recipe_ingredient],
# "recipe_category": [x.name for x in name_orm.recipe_category],
# "tags": [x.name for x in name_orm.tags],
"tools": [x.tool for x in name_orm.tools],
"extras": {x.key_name: x.value for x in name_orm.extras},
}

View File

@@ -1,8 +1,8 @@
from datetime import datetime
from typing import Optional
from uuid import UUID
from fastapi_camelcase import CamelModel
from pydantic.utils import GetterDict
class UserBase(CamelModel):
@@ -14,31 +14,27 @@ class UserBase(CamelModel):
orm_mode = True
class CreateComment(CamelModel):
class RecipeCommentCreate(CamelModel):
recipe_id: int
text: str
class SaveComment(CreateComment):
recipe_slug: str
user: int
class Config:
orm_mode = True
class RecipeCommentSave(RecipeCommentCreate):
user_id: int
class CommentOut(CreateComment):
id: int
uuid: str
recipe_slug: str
date_added: datetime
class RecipeCommentUpdate(CamelModel):
id: UUID
text: str
class RecipeCommentOut(RecipeCommentCreate):
id: UUID
recipe_id: int
created_at: datetime
update_at: datetime
user_id: int
user: UserBase
class Config:
orm_mode = True
@classmethod
def getter_dict(_cls, name_orm):
return {
**GetterDict(name_orm),
"recipe_slug": name_orm.recipe.slug,
}

View File

@@ -1,7 +1,8 @@
from typing import Optional
from uuid import UUID
from uuid import UUID, uuid4
from fastapi_camelcase import CamelModel
from pydantic import Field
class IngredientReferences(CamelModel):
@@ -16,6 +17,7 @@ class IngredientReferences(CamelModel):
class RecipeStep(CamelModel):
id: Optional[UUID] = Field(default_factory=uuid4)
title: Optional[str] = ""
text: str
ingredient_references: list[IngredientReferences] = []

View File

@@ -0,0 +1,13 @@
from fastapi_camelcase import CamelModel
class RecipeToolCreate(CamelModel):
name: str
on_hand: bool = False
class RecipeTool(RecipeToolCreate):
id: int
class Config:
orm_mode = True