mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-04 15:03:10 -05:00
refactor: ♻️ rewrite migrations frontend/backend (#841)
* refactor(frontend): ♻️ rewrite migrations UI * refactor(backend): ♻️ rewrite recipe migrations * remove vue-demi Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -2,11 +2,13 @@ from datetime import date, timedelta
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from mealie.schema.reports.reports import ReportCategory
|
||||
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 mealie.services.group_services.reports_service import GroupReportService
|
||||
|
||||
from . import categories, invitations, preferences, self_service
|
||||
from . import categories, invitations, migrations, preferences, self_service
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@@ -38,3 +40,16 @@ router.include_router(categories.user_router)
|
||||
router.include_router(webhook_router)
|
||||
router.include_router(invitations.router, prefix="/groups/invitations", tags=["Groups: Invitations"])
|
||||
router.include_router(preferences.router, prefix="/groups/preferences", tags=["Group: Preferences"])
|
||||
router.include_router(migrations.router, prefix="/groups/migrations", tags=["Group: Migrations"])
|
||||
|
||||
report_router = RouterFactory(service=GroupReportService, prefix="/groups/reports", tags=["Groups: Reports"])
|
||||
|
||||
|
||||
@report_router.get("")
|
||||
def get_all_reports(
|
||||
report_type: ReportCategory = None, gm_service: GroupReportService = Depends(GroupReportService.private)
|
||||
):
|
||||
return gm_service._get_all(report_type)
|
||||
|
||||
|
||||
router.include_router(report_router)
|
||||
|
||||
26
mealie/routes/groups/migrations.py
Normal file
26
mealie/routes/groups/migrations.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import shutil
|
||||
|
||||
from fastapi import Depends, File, Form
|
||||
from fastapi.datastructures import UploadFile
|
||||
|
||||
from mealie.core.dependencies import temporary_zip_path
|
||||
from mealie.routes.routers import UserAPIRouter
|
||||
from mealie.schema.group.group_migration import SupportedMigrations
|
||||
from mealie.schema.reports.reports import ReportSummary
|
||||
from mealie.services.group_services.migration_service import GroupMigrationService
|
||||
|
||||
router = UserAPIRouter()
|
||||
|
||||
|
||||
@router.post("", response_model=ReportSummary)
|
||||
def start_data_migration(
|
||||
migration_type: SupportedMigrations = Form(...),
|
||||
archive: UploadFile = File(...),
|
||||
temp_path: str = Depends(temporary_zip_path),
|
||||
gm_service: GroupMigrationService = Depends(GroupMigrationService.private),
|
||||
):
|
||||
# Save archive to temp_path
|
||||
with temp_path.open("wb") as buffer:
|
||||
shutil.copyfileobj(archive.file, buffer)
|
||||
|
||||
return gm_service.migrate(migration_type, temp_path)
|
||||
Reference in New Issue
Block a user