feat(E): add MediaAsset catalog — model, CRUD API, MediaBrowser UI
Migration 040: media_assets table with RLS (tenant_isolation + admin_bypass). domains/media/: MediaAsset model, schemas, service, router with ZIP-download. publish_asset Celery task in rendering/tasks.py. core/storage.py: download_bytes() method for MinIO + LocalStorage. frontend: MediaBrowser.tsx (grid/list, multi-select, zip-download, pagination) + api/media.ts. Route /media (AdminRoute) + sidebar link with Image icon for admin+pm. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -220,6 +220,44 @@ def render_turntable_task(
|
||||
}
|
||||
|
||||
|
||||
@celery_app.task(
|
||||
name="rendering.publish_asset",
|
||||
queue="step_processing",
|
||||
)
|
||||
def publish_asset(
|
||||
order_line_id: str,
|
||||
asset_type: str,
|
||||
storage_key: str,
|
||||
render_config: dict | None = None,
|
||||
) -> str | None:
|
||||
"""Create a MediaAsset record after a successful render."""
|
||||
import asyncio
|
||||
|
||||
async def _run() -> str | None:
|
||||
from app.database import AsyncSessionLocal
|
||||
from app.domains.media.models import MediaAsset, MediaAssetType
|
||||
from app.domains.orders.models import OrderLine
|
||||
from sqlalchemy import select
|
||||
|
||||
async with AsyncSessionLocal() as db:
|
||||
res = await db.execute(select(OrderLine).where(OrderLine.id == order_line_id))
|
||||
line = res.scalar_one_or_none()
|
||||
if not line:
|
||||
return None
|
||||
asset = MediaAsset(
|
||||
tenant_id=getattr(line, "tenant_id", None),
|
||||
order_line_id=line.id,
|
||||
asset_type=MediaAssetType(asset_type),
|
||||
storage_key=storage_key,
|
||||
render_config=render_config,
|
||||
)
|
||||
db.add(asset)
|
||||
await db.commit()
|
||||
return str(asset.id)
|
||||
|
||||
return asyncio.get_event_loop().run_until_complete(_run())
|
||||
|
||||
|
||||
def _build_ffmpeg_cmd(
|
||||
frames_dir: Path, output_mp4: Path, fps: int = 30, bg_color: str = ""
|
||||
) -> list:
|
||||
|
||||
Reference in New Issue
Block a user