feat(backend): rewrite mealplanner with simple api (#683)

* feat(backend):  new meal-planner feature

* feat(frontend):  new meal plan feature

* refactor(backend): ♻️ refactor base services classes and add mixins for crud

* feat(frontend):  add UI/API for mealplanner

* feat(backend):  add get_today and get_slice options for mealplanner

* test(backend):  add and update group mealplanner tests

* fix(backend): 🐛 Fix recipe_id column type for PG

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-09-12 11:05:09 -08:00
committed by GitHub
parent bdaf758712
commit b542583303
46 changed files with 869 additions and 255 deletions

View File

@@ -1,8 +1,7 @@
from fastapi import APIRouter
from . import app_about, app_defaults
from . import app_about
router = APIRouter(prefix="/app")
router.include_router(app_about.router, tags=["App: About"])
router.include_router(app_defaults.router, tags=["App: Defaults"])

View File

@@ -1,12 +0,0 @@
from fastapi import APIRouter
from mealie.schema.recipe.recipe_settings import RecipeSettings
router = APIRouter(prefix="/defaults")
@router.get("/recipe", response_model=RecipeSettings)
async def get_recipe_settings_defaults():
""" Returns the Default Settings for Recieps as set by ENV variables """
return RecipeSettings()

View File

@@ -1,16 +1,39 @@
from fastapi import APIRouter
from datetime import date, timedelta
from fastapi import APIRouter, Depends
from mealie.services._base_http_service import RouterFactory
from mealie.services.group_services import CookbookService, WebhookService
from mealie.services.group_services.meal_service import MealService
from . import categories, invitations, preferences, self_service
router = APIRouter()
router.include_router(self_service.user_router)
webhook_router = RouterFactory(service=WebhookService, prefix="/groups/webhooks", tags=["Groups: Webhooks"])
cookbook_router = RouterFactory(service=CookbookService, prefix="/groups/cookbooks", tags=["Groups: Cookbooks"])
router.include_router(self_service.user_router)
@router.get("/groups/mealplans/today", tags=["Groups: Mealplans"])
def get_todays_meals(m_service: MealService = Depends(MealService.private)):
return m_service.get_today()
meal_plan_router = RouterFactory(service=MealService, prefix="/groups/mealplans", tags=["Groups: Mealplans"])
@meal_plan_router.get("")
def get_all(start: date = None, limit: date = None, m_service: MealService = Depends(MealService.private)):
start = start or date.today() - timedelta(days=999)
limit = limit or date.today() + timedelta(days=999)
return m_service.get_slice(start, limit)
router.include_router(cookbook_router)
router.include_router(meal_plan_router)
router.include_router(categories.user_router)
router.include_router(webhook_router)
router.include_router(invitations.router, prefix="/groups/invitations", tags=["Groups: Invitations"])