mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-10 11:01:21 -05:00
Merge branch 'master' of https://github.com/hay-kot/mealie into 0.1.0
This commit is contained in:
@@ -7,9 +7,8 @@ from utils.snackbar import SnackResponse
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/backups/avaiable/", tags=["Import / Export"])
|
||||
async def avaiable_imports():
|
||||
""" Returns this weeks meal plan """
|
||||
@router.get("/api/backups/available/", tags=["Import / Export"])
|
||||
async def available_imports():
|
||||
imports = []
|
||||
templates = []
|
||||
for archive in BACKUP_DIR.glob("*.zip"):
|
||||
@@ -23,24 +22,22 @@ async def avaiable_imports():
|
||||
|
||||
@router.post("/api/backups/export/database/", tags=["Import / Export"], status_code=201)
|
||||
async def export_database(data: BackupJob):
|
||||
""" Returns this weeks meal plan """
|
||||
|
||||
try:
|
||||
export_db(data.tag, data.template)
|
||||
export_path = export_db(data.tag, data.template)
|
||||
except:
|
||||
HTTPException(
|
||||
status_code=400,
|
||||
detail=SnackResponse.error("Error Creating Backup. See Log File"),
|
||||
)
|
||||
|
||||
return SnackResponse.success("Backup Created in /data/backups")
|
||||
return SnackResponse.success("Backup Created at " + export_path)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/api/backups/{file_name}/import/", tags=["Import / Export"], status_code=200
|
||||
)
|
||||
async def import_database(file_name: str):
|
||||
""" Returns this weeks meal plan """
|
||||
imported = import_from_archive(file_name)
|
||||
return imported
|
||||
|
||||
@@ -51,7 +48,6 @@ async def import_database(file_name: str):
|
||||
status_code=200,
|
||||
)
|
||||
async def delete_backup(backup_name: str):
|
||||
""" Returns this weeks meal plan """
|
||||
|
||||
try:
|
||||
BACKUP_DIR.joinpath(backup_name).unlink()
|
||||
|
||||
@@ -9,7 +9,7 @@ router = APIRouter()
|
||||
|
||||
@router.get("/api/meal-plan/all/", tags=["Meal Plan"])
|
||||
async def get_all_meals():
|
||||
""" Returns a list of all avaiable meal plans """
|
||||
""" Returns a list of all available meal plans """
|
||||
|
||||
return MealPlan.get_all()
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ def export_db(tag=None, templates=None):
|
||||
shutil.rmtree(backup_folder)
|
||||
shutil.rmtree(TEMP_DIR)
|
||||
|
||||
return str(zip_path.absolute()) + ".zip"
|
||||
|
||||
|
||||
|
||||
def export_images(dest_dir) -> Path:
|
||||
|
||||
Reference in New Issue
Block a user