From 34fd57d576b0a8b0a1825067596dbd97a1556e79 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Sat, 8 May 2021 17:23:14 -0800 Subject: [PATCH] add url param --- mealie/core/config.py | 1 + mealie/routes/recipe/recipe_crud_routes.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mealie/core/config.py b/mealie/core/config.py index c08d75cb1..3abf9e6f9 100644 --- a/mealie/core/config.py +++ b/mealie/core/config.py @@ -95,6 +95,7 @@ def determine_sqlite_path(path=False, suffix=DB_VERSION) -> str: class AppSettings(BaseSettings): global DATA_DIR PRODUCTION: bool = Field(True, env="PRODUCTION") + BASE_URL: str = "http://localhost:8080" IS_DEMO: bool = False API_PORT: int = 9000 API_DOCS: bool = True diff --git a/mealie/routes/recipe/recipe_crud_routes.py b/mealie/routes/recipe/recipe_crud_routes.py index aa7918431..f1671ab4a 100644 --- a/mealie/routes/recipe/recipe_crud_routes.py +++ b/mealie/routes/recipe/recipe_crud_routes.py @@ -2,11 +2,13 @@ from shutil import copyfileobj from fastapi import APIRouter, BackgroundTasks, Depends, File, Form, HTTPException, status from fastapi.datastructures import UploadFile +from mealie.core.config import settings from mealie.core.root_logger import get_logger from mealie.db.database import db from mealie.db.db_setup import generate_session from mealie.routes.deps import get_current_user from mealie.schema.recipe import Recipe, RecipeAsset, RecipeURLIn +from mealie.schema.user import UserInDB from mealie.services.events import create_recipe_event from mealie.services.image.image import scrape_image, write_image from mealie.services.recipe.media import check_assets, delete_assets @@ -31,7 +33,7 @@ def create_from_json( background_tasks.add_task( create_recipe_event, "Recipe Created (URL)", - f"'{recipe.name}' by {current_user.full_name}", + f"'{recipe.name}' by {current_user.full_name} \n {settings.BASE_URL}/recipe/{recipe.slug}", session=session, attachment=recipe.image_dir.joinpath("min-original.webp"), ) @@ -44,7 +46,7 @@ def parse_recipe_url( background_tasks: BackgroundTasks, url: RecipeURLIn, session: Session = Depends(generate_session), - current_user=Depends(get_current_user), + current_user: UserInDB = Depends(get_current_user), ): """ Takes in a URL and attempts to scrape data and load it into the database """ @@ -54,7 +56,7 @@ def parse_recipe_url( background_tasks.add_task( create_recipe_event, "Recipe Created (URL)", - f"'{recipe.name}' by {current_user.full_name}", + f"'{recipe.name}' by {current_user.full_name} \n {settings.BASE_URL}/recipe/{recipe.slug}", session=session, attachment=recipe.image_dir.joinpath("min-original.webp"), )