完善视频提炼和视频复刻完善提交测试
This commit is contained in:
@@ -485,6 +485,20 @@ class ProjectViewSet(TeamScopedViewSetMixin, ModelViewSet):
|
||||
def quick_create(self, request):
|
||||
"""商品名称 + 1–9 张图 → 新建商品与项目,并启动完整自动生产流水线。"""
|
||||
require_worker_task("apps.projects.tasks.advance_quick_create_task")
|
||||
# 单飞闸:一个团队同时只允许一条一键成片。刷新页面时前端拉状态有空档,
|
||||
# 用户容易以为「没任务」再提交一次 —— 那会重复建商品、重复扣费。
|
||||
# get_inflight_quick_create 会跳过 30 分钟没动过的僵尸 job,不至于把人永久锁住。
|
||||
from .services.quick_create import get_inflight_quick_create
|
||||
|
||||
running_job = get_inflight_quick_create(self.get_team())
|
||||
if running_job is not None:
|
||||
return Response(
|
||||
{
|
||||
"detail": "已有一个一键成片正在进行中,完成或取消后才能再提交",
|
||||
"inflight": QuickCreateJobSerializer(running_job).data,
|
||||
},
|
||||
status=status.HTTP_409_CONFLICT,
|
||||
)
|
||||
name = str(request.data.get("name") or "").strip()
|
||||
uploads = request.FILES.getlist("images") or request.FILES.getlist("images[]")
|
||||
source_product_id = str(request.data.get("source_product_id") or "").strip()
|
||||
@@ -775,9 +789,14 @@ class ProjectViewSet(TeamScopedViewSetMixin, ModelViewSet):
|
||||
)
|
||||
.order_by("-created_at")
|
||||
)
|
||||
from .services.quick_create import get_inflight_quick_create
|
||||
|
||||
running = get_inflight_quick_create(self.get_team())
|
||||
return Response({
|
||||
"count": jobs.count(),
|
||||
"results": QuickCreateJobSerializer(jobs[:30], many=True).data,
|
||||
# 进行中的那条:前端刷新/重进页面据此恢复进度,不再显示成空表单
|
||||
"inflight": QuickCreateJobSerializer(running).data if running is not None else None,
|
||||
})
|
||||
|
||||
@transaction.atomic
|
||||
|
||||
Reference in New Issue
Block a user