Bug Fixes (#467)

* fixes #463

* fixes #465

* fixes #461

* fixes #458 key error

* Fixes #459

* Fixes comments shown when printing

* fix meal-image not return on API call

* return better status

* reorganize docs

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-06-04 18:45:13 -08:00
committed by GitHub
parent d126f74d35
commit 59f8b74460
21 changed files with 72 additions and 46 deletions

View File

@@ -45,6 +45,25 @@ def get_today(session: Session = Depends(generate_session), current_user: UserIn
return recipe
@router.get("/today/image", tags=["Meal Plan"])
def get_todays_image(session: Session = Depends(generate_session), group_name: str = "Home"):
"""
Returns the image for todays meal-plan.
"""
group_in_db: GroupInDB = db.groups.get(session, group_name, "name")
recipe = get_todays_meal(session, group_in_db)
if recipe:
recipe_image = recipe.image_dir.joinpath(image.ImageOptions.ORIGINAL_IMAGE)
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)
if recipe_image:
return FileResponse(recipe_image)
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)
@router.get("/{id}", response_model=MealPlanOut)
def get_meal_plan(
id,
@@ -106,22 +125,3 @@ def delete_meal_plan(
)
except Exception:
raise HTTPException(status.HTTP_400_BAD_REQUEST)
@router.get("/today/image", tags=["Meal Plan"])
def get_todays_image(session: Session = Depends(generate_session), group_name: str = "Home"):
"""
Returns the image for todays meal-plan.
"""
group_in_db: GroupInDB = db.groups.get(session, group_name, "name")
recipe = get_todays_meal(session, group_in_db)
if recipe:
recipe_image = recipe.image_dir.joinpath(image.ImageOptions.ORIGINAL_IMAGE)
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)
if recipe_image:
return FileResponse(recipe_image)
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)

View File

@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, HTTPException, status
from mealie.db.database import db
from mealie.db.db_setup import generate_session
from mealie.routes.deps import get_current_user
@@ -35,4 +35,7 @@ def test_webhooks(
""" Run the function to test your webhooks """
group_entry: GroupInDB = db.groups.get(session, current_user.group, "name")
return post_webhooks(group_entry.id, session)
try:
post_webhooks(group_entry.id, session)
except Exception:
return HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR)