fix: before approving, the panel learns that a file cannot be a final and says to treat the art (DTF-WEB-11)
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 7m15s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 2m28s
All checks were successful
Build and deploy / Validate source (push) Successful in 8s
Build and deploy / Integration suite on a real stack (push) Successful in 7m15s
Build and deploy / Secret scan and release gate (push) Successful in 9s
Build and deploy / Publish images (push) Successful in 2m28s
The panel offered the customer's correction (or an original) as ready to
approve, and the server refused it as not a transparent 300 DPI PNG,
an error for Sentry. POST /orders/{id}/final-check reads the header of
the order's own files with the same check as the approval and answers
200 with the problems; "Aprovar arquivo final" asks it first and, when a
file cannot be a final, says why and to use "Tratar a arte".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,15 @@ 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 pydantic import Field
|
||||
|
||||
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 ..core.models import ArtworkSubmission, StrictModel, UploadStart
|
||||
from ..printpng_validate import final_png_problem
|
||||
from ..runtime import file_rows, operator_identity, storage
|
||||
from .uploads import begin_upload, cancel_upload, complete_upload, part_url, upload_status
|
||||
|
||||
router = APIRouter()
|
||||
@@ -54,6 +56,35 @@ def operator_files(oid: UUID, user=Depends(operator)):
|
||||
with db.connect() as c:
|
||||
return file_rows(c,oid)
|
||||
|
||||
class FinalCheck(StrictModel):
|
||||
uploads: list[UUID] = Field(min_length=1, max_length=400)
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{oid}/final-check')
|
||||
def final_check(oid: UUID, body: FinalCheck, user=Depends(can('produce'))):
|
||||
"""Whether these files of the order can be approved as its finals, asked
|
||||
before approving (Sentry DTF-WEB-11): a customer's correction or an
|
||||
original may not be the transparent 300 DPI PNG a final must be. The
|
||||
answer lists the problems with 200, so a file to treat is guidance in
|
||||
the panel, not a refusal. Only the order's own files are read."""
|
||||
with db.connect() as c:
|
||||
order = c.execute('SELECT snapshot FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()
|
||||
if not order:
|
||||
raise HTTPException(404, 'Pedido não encontrado.')
|
||||
originals = {uid for item in order['snapshot']['items'] for uid in item['uploads']}
|
||||
rows = c.execute('''SELECT u.id,u.name,u.object_key FROM dtf_local.uploads u WHERE u.id=ANY(%s) AND (
|
||||
u.id::text=ANY(%s)
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=%s AND f.upload_id=u.id)
|
||||
OR EXISTS (SELECT 1 FROM dtf_local.print_parts p WHERE p.order_id=%s AND p.upload_id=u.id))''',
|
||||
(body.uploads, list(originals), oid, oid)).fetchall()
|
||||
problems = []
|
||||
for row in rows:
|
||||
issue = final_png_problem(storage, row)
|
||||
if issue:
|
||||
problems.append({'upload_id': str(row['id']), 'name': row['name'], 'message': issue})
|
||||
return {'problems': problems}
|
||||
|
||||
|
||||
@router.post('/api/operator/orders/{oid}/final-files')
|
||||
def final_files(oid: UUID, body: ArtworkSubmission, user=Depends(can('produce'))):
|
||||
with db.connect() as c:
|
||||
|
||||
@@ -47,12 +47,18 @@ def final_png_issue(data):
|
||||
return None
|
||||
|
||||
|
||||
def require_final_png(storage, upload):
|
||||
from fastapi import HTTPException
|
||||
def final_png_problem(storage, upload):
|
||||
"""Why this upload cannot be a final file, or None: its name and the
|
||||
header chunks of the stored file."""
|
||||
if not upload['name'].lower().endswith('.png'):
|
||||
raise HTTPException(422, 'O arquivo final precisa ser PNG transparente a 300 DPI. Converta PDF/TIFF antes de enviar.')
|
||||
return 'O arquivo final precisa ser PNG transparente a 300 DPI. Converta PDF/TIFF antes de enviar.'
|
||||
response = storage.client.get_object(Bucket=storage.bucket, Key=upload['object_key'],
|
||||
Range=f'bytes=0-{HEADER_BYTES - 1}')
|
||||
issue = final_png_issue(response['Body'].read())
|
||||
return final_png_issue(response['Body'].read())
|
||||
|
||||
|
||||
def require_final_png(storage, upload):
|
||||
from fastapi import HTTPException
|
||||
issue = final_png_problem(storage, upload)
|
||||
if issue:
|
||||
raise HTTPException(422, issue)
|
||||
|
||||
@@ -280,6 +280,16 @@ def run():
|
||||
assert red[3] == 255 and red[0] > 200 and red[1] < 60, red
|
||||
print('PASS: PDF artwork drawn into the PNG print file at 300 DPI')
|
||||
|
||||
# Before approving, the panel asks whether the files can be finals: the
|
||||
# generated PNG can, the customer's PDF original cannot, and the answer
|
||||
# says why without a refusal (Sentry DTF-WEB-11). Another order's file is
|
||||
# not read.
|
||||
check = client.call('/operator/orders/' + pdf_order['id'] + '/final-check',
|
||||
{'uploads': [str(pdf_row['upload_id']), pdf_upload, str(row['upload_id'])]}, operator=True)
|
||||
assert [p['upload_id'] for p in check['problems']] == [pdf_upload], check
|
||||
assert '300 DPI' in check['problems'][0]['message'], check
|
||||
print('PASS: the panel learns before approving that a file cannot be a final')
|
||||
|
||||
# The proof card (Dropstar, 2026-10-30 and 2026-11-03): an order above
|
||||
# 10 m gets a child card "Prova"; the order waits outside the queue until
|
||||
# the card in Revisão gets its answer.
|
||||
|
||||
@@ -535,7 +535,19 @@ async function saveFinalFiles(order, files, note){
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// A customer's correction or an original may not be the transparent 300 DPI
|
||||
// PNG a final must be: asked before approving, it is guidance with the way
|
||||
// out, not a refusal (Sentry DTF-WEB-11). Returns whether all can be approved.
|
||||
async function finalsOk(order,uploads){
|
||||
const {problems}=await api('/orders/'+order.id+'/final-check',{uploads});
|
||||
if(!problems.length)return true;
|
||||
const first=problems[0];
|
||||
say(first.name+' não pode ser o arquivo final como está: '+first.message.replace(/\.$/,'')+
|
||||
'. Use “Tratar a arte” e envie o PNG preparado.'+(problems.length>1?' (e mais '+(problems.length-1)+')':''),false,12000);
|
||||
return false;
|
||||
}
|
||||
async function approveReady(order,ready){
|
||||
if(!await finalsOk(order,ready.flatMap(r=>r.files.map(f=>f.upload_id))))return;
|
||||
const many=ready.length>1;
|
||||
if(!await ask('Aprovar o arquivo final?','Conferiu? É este arquivo que vai para a impressão: '+
|
||||
ready.map((r,i)=>(many?'item '+(i+1)+', ':'')+r.label).join('; ')+'.','Aprovar arquivo final',{host:$('drawer')}))return;
|
||||
|
||||
Reference in New Issue
Block a user