The montador sends each stamp to storage, splits the list into items of at most 20 sources and 4000 copies, packs each one with the Site's engine and creates the order in Arte recebida: typed customer, pickup, the Site's table price, payment 'faturado', origin dropflow for Expedição and atendimento otherwise. Until Dropstar decides, these orders do not go to Tiny and the customer gets no paid e-mail. Vendedor and Expedição may now upload through the operator upload routes (can_any). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
67 lines
3.2 KiB
Python
67 lines
3.2 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 .. import proof
|
|
from ..artwork import submit_files
|
|
from ..core.auth import can, can_any, operator
|
|
from ..core.models import ArtworkSubmission, UploadStart
|
|
from ..runtime import file_rows, operator_identity
|
|
from .uploads import begin_upload, cancel_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(can('produce'))):
|
|
if not body.name.lower().endswith('.png'):
|
|
raise HTTPException(422, 'O arquivo final precisa ser PNG transparente a 300 DPI. Converta PDF/TIFF antes de enviar.')
|
|
with db.connect() as c:
|
|
row = c.execute('SELECT id,state,parent_id,proof_ok_at FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()
|
|
if not row: raise HTTPException(404, 'Order not found')
|
|
if row['parent_id']:
|
|
raise HTTPException(409, 'A prova recebe o PNG final automaticamente.')
|
|
if not proof.manual_source_needed(c, row):
|
|
proof.require_unlocked(c, row)
|
|
if row['state'] not in ('rec','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))
|
|
|
|
# The parts of an upload its operator started: a final (produce) or the
|
|
# photo of a signed pickup receipt (deliver, which includes produce).
|
|
@router.post('/api/operator/uploads/{uid}/parts/{number}')
|
|
def final_part(uid: UUID, number: int, user=Depends(can_any('deliver', 'assemble'))):
|
|
return part_url(uid,number,session_id=operator_identity(user))
|
|
|
|
@router.post('/api/operator/uploads/{uid}/complete')
|
|
def final_complete(uid: UUID, user=Depends(can_any('deliver', 'assemble'))):
|
|
return complete_upload(uid,session_id=operator_identity(user))
|
|
|
|
@router.delete('/api/operator/uploads/{uid}')
|
|
def final_cancel(uid: UUID, user=Depends(can_any('deliver', 'assemble'))):
|
|
return cancel_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(can('produce'))):
|
|
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')
|
|
if order['parent_id']:
|
|
raise HTTPException(409, 'O arquivo final da prova é gerado automaticamente. Use Gerar de novo se falhar.')
|
|
if not proof.manual_source_needed(c, order):
|
|
proof.require_unlocked(c, order)
|
|
return submit_files(c,order,body,operator_identity(user),'final',user)
|