コード例 #1
0
def set_meal_plan(data: MealPlan,
                  session: Session = Depends(generate_session)):
    """ Creates a meal plan database entry """
    data.process_meals(session)
    data.save_to_db(session)

    return SnackResponse.success("Mealplan Created")
コード例 #2
0
def update_meal_plan(plan_id: str,
                     meal_plan: MealPlan,
                     session: Session = Depends(generate_session)):
    """ Updates a meal plan based off ID """
    meal_plan.process_meals(session)
    meal_plan.update(session, plan_id)

    return SnackResponse.info("Mealplan Updated")
コード例 #3
0
ファイル: meal_routes.py プロジェクト: richardmitic/mealie
def set_meal_plan(data: MealPlan):
    """ Creates a meal plan database entry """
    data.process_meals()
    data.save_to_db()

    #     raise HTTPException(
    #         status_code=404,
    #         detail=SnackResponse.error("Unable to Create Mealplan See Log"),
    #     )

    return SnackResponse.success("Mealplan Created")
コード例 #4
0
ファイル: meal_routes.py プロジェクト: djbr22/mealie
async def update_meal_plan(plan_id: str, meal_plan: MealPlan):
    """ Updates a meal plan based off ID """

    try:
        meal_plan.process_meals()
        meal_plan.update(plan_id)
    except:
        raise HTTPException(
            status_code=404,
            detail=SnackResponse.error("Unable to Update Mealplan"),
        )

    return SnackResponse.success("Mealplan Updated")
コード例 #5
0
ファイル: meal_routes.py プロジェクト: richardmitic/mealie
def get_today():
    """
    Returns the recipe slug for the meal scheduled for today.
    If no meal is scheduled nothing is returned
    """

    return MealPlan.today()
コード例 #6
0
def get_today(session: Session = Depends(generate_session)):
    """
    Returns the recipe slug for the meal scheduled for today.
    If no meal is scheduled nothing is returned
    """

    return MealPlan.today(session)
コード例 #7
0
    def export_meals(self):
        #! Problem Parseing Datetime Objects... May come back to this
        meal_plans = MealPlan.get_all(self.session)
        if meal_plans:
            meal_plans = [x.dict() for x in meal_plans]

        out_file = self.mealplans_dir.joinpath("mealplans.json")
        ExportDatabase._write_json_file(meal_plans, out_file)
コード例 #8
0
def post_webhooks():
    all_settings = SiteSettings.get_site_settings()

    if all_settings.webhooks.enabled:
        todays_meal = Recipe.get_by_slug(MealPlan.today()).dict()
        urls = all_settings.webhooks.webhookURLs

        for url in urls:
            requests.post(url, json.dumps(todays_meal, default=str))
コード例 #9
0
ファイル: post_webhooks.py プロジェクト: wengtad/mealie
def post_webhooks():
    session = create_session()
    all_settings = db.get(session, "main")
    all_settings = SiteSettings(**all_settings)

    if all_settings.webhooks.enabled:
        todays_meal = Recipe.get_by_slug(MealPlan.today()).dict()
        urls = all_settings.webhooks.webhookURLs

        for url in urls:
            requests.post(url, json.dumps(todays_meal, default=str))

    session.close()
コード例 #10
0
ファイル: meal_routes.py プロジェクト: richardmitic/mealie
def get_this_week():
    """ Returns the meal plan data for this week """

    return MealPlan.this_week()
コード例 #11
0
ファイル: meal_routes.py プロジェクト: richardmitic/mealie
def delete_meal_plan(plan_id):
    """ Removes a meal plan from the database """

    MealPlan.delete(plan_id)

    return SnackResponse.success("Mealplan Deleted")
コード例 #12
0
ファイル: meal_routes.py プロジェクト: richardmitic/mealie
def get_all_meals():
    """ Returns a list of all available Meal Plan """

    return MealPlan.get_all()
コード例 #13
0
def delete_meal_plan(plan_id, session: Session = Depends(generate_session)):
    """ Removes a meal plan from the database """

    MealPlan.delete(session, plan_id)

    return SnackResponse.error("Mealplan Deleted")
コード例 #14
0
def get_this_week(session: Session = Depends(generate_session)):
    """ Returns the meal plan data for this week """

    return MealPlan.this_week(session)
コード例 #15
0
def get_all_meals(session: Session = Depends(generate_session)):
    """ Returns a list of all available Meal Plan """

    return MealPlan.get_all(session)