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:
|
||||
|
||||
Reference in New Issue
Block a user