fix: full-width content area + auto-create MediaAssets on render complete
- Remove max-w-* constraints from all data/table pages so content fills available width after sidebar (Billing, MediaBrowser, OrderDetail, WorkerManagement, WorkerActivity, Materials, Tenants, AssetLibrary, NewProductOrder, ProductDetail) - Narrow form/settings pages keep their max-width (NotificationSettings, Preferences, NewOrder, Notifications) - render_order_line_task: create MediaAsset record on render success so results immediately appear in Media Browser without requiring the retroactive import button Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -644,6 +644,32 @@ def render_order_line_task(self, order_line_id: str):
|
||||
)
|
||||
session.commit()
|
||||
|
||||
if success:
|
||||
# Create MediaAsset so the render appears in the Media Browser
|
||||
try:
|
||||
from app.domains.media.models import MediaAsset, MediaAssetType as MAT
|
||||
_ext = str(output_path).rsplit(".", 1)[-1].lower() if "." in str(output_path) else "bin"
|
||||
_mime = "video/mp4" if _ext in ("mp4", "webm") else ("image/jpeg" if _ext in ("jpg", "jpeg") else "image/png")
|
||||
_is_anim = bool(line.output_type and line.output_type.is_animation)
|
||||
_at = MAT.turntable if _is_anim else MAT.still
|
||||
_tenant_id = line.product.cad_file.tenant_id if (line.product and line.product.cad_file) else None
|
||||
_existing = session.execute(
|
||||
select(MediaAsset.id).where(MediaAsset.storage_key == output_path).limit(1)
|
||||
).scalar_one_or_none()
|
||||
if not _existing:
|
||||
_asset = MediaAsset(
|
||||
tenant_id=_tenant_id,
|
||||
order_line_id=line.id,
|
||||
product_id=line.product_id,
|
||||
asset_type=_at,
|
||||
storage_key=output_path,
|
||||
mime_type=_mime,
|
||||
)
|
||||
session.add(_asset)
|
||||
session.commit()
|
||||
except Exception:
|
||||
logger.exception("Failed to create MediaAsset for order_line %s", order_line_id)
|
||||
|
||||
if success:
|
||||
emit(order_line_id, f"Render completed in {elapsed:.1f}s", "success")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user