All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 1m25s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images and notify Portainer (push) Successful in 1m31s
local/ held six unrelated things under a name that stopped being true once it
became the production runtime: the service, the frontend, the tests, the ops
commands, the container definitions and the dependency lock, 65 files with
nothing to tell them apart.
app/ the service: api/ routers, core/ for identity, database, models,
prices and secret loading, and the worker, bootstrap and schema
tests/ the twelve suites, no longer inside the shipped package
ops/ backup, readiness, dependency audit, security summary
infra/ Dockerfiles, gateway templates, ClamAV and storage configuration,
the requirements and their hash lock
web/ the Site, Kanban and portal pages with their scripts
deploy/Dockerfile.api now copies app/ alone, so the tests stop shipping to
production; the local image still carries them, because the suites run inside
the stack's network.
Five kinds of reference had to follow, and each was found by something different
rather than by reading. Imports of the form "from . import db" survived a rewrite
that only matched "from .db import". Tests kept relative imports of modules that
had left the package. A mock.patch target names its module in a string, where no
import rewriting can see it. The browser test resolves a fixture by path. And the
release gate's markers pointed at local/runtime.py and local/worker.py, which is
the decay its new marker test exists to catch — it caught it.
Verified from docker compose down -v: the stack starts, all six integration
suites, both browser suites and the twenty-nine unit tests pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
"""Operator artwork handling: final files, and the uploads that carry them.
|
|
|
|
These reuse the customer upload routes with the operator's derived identity, so
|
|
one transport serves both and there is only one place where parts are signed.
|
|
"""
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
|
from ..core import db
|
|
from ..artwork import submit_files
|
|
from ..core.auth import operator
|
|
from ..core.models import ArtworkSubmission, UploadStart
|
|
from ..runtime import file_rows, operator_identity
|
|
from .uploads import begin_upload, complete_upload, part_url, upload_status
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post('/api/operator/orders/{oid}/uploads')
|
|
def begin_final(oid: UUID, body: UploadStart, user=Depends(operator)):
|
|
with db.connect() as c:
|
|
row = c.execute('SELECT state FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()
|
|
if not row: raise HTTPException(404, 'Order not found')
|
|
if row['state'] not in ('rec','tra','cor'): raise HTTPException(409, 'Order is not in artwork review')
|
|
return begin_upload(body, session_id=operator_identity(user))
|
|
|
|
@router.get('/api/operator/uploads/{uid}')
|
|
def final_status(uid: UUID, user=Depends(operator)):
|
|
return upload_status(uid,session_id=operator_identity(user))
|
|
|
|
@router.post('/api/operator/uploads/{uid}/parts/{number}')
|
|
def final_part(uid: UUID, number: int, user=Depends(operator)):
|
|
return part_url(uid,number,session_id=operator_identity(user))
|
|
|
|
@router.post('/api/operator/uploads/{uid}/complete')
|
|
def final_complete(uid: UUID, user=Depends(operator)):
|
|
return complete_upload(uid,session_id=operator_identity(user))
|
|
|
|
@router.get('/api/operator/orders/{oid}/files')
|
|
def operator_files(oid: UUID, user=Depends(operator)):
|
|
with db.connect() as c:
|
|
return file_rows(c,oid)
|
|
|
|
@router.post('/api/operator/orders/{oid}/final-files')
|
|
def final_files(oid: UUID, body: ArtworkSubmission, user=Depends(operator)):
|
|
with db.connect() as c:
|
|
order = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (oid,)).fetchone()
|
|
if not order: raise HTTPException(404, 'Order not found')
|
|
return submit_files(c,order,body,operator_identity(user),'final',user)
|