feat: review photo or video in Revisão (front 2)
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 6m4s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m6s

In Revisão the card gets "Revisar": a photo or a video of up to 30 s of
the printed sheet, from the computer's or the phone's camera in the
browser, or a file already recorded. It is attached to the order as
DTF-<n>-revisao-<seq> with when and who, kept 180 days, and copied by
the computers with the order folders to Kanban/Revisões/. A photo needs
1600 px on its longer side. An order above 1 m cannot reach Finalizado
without one. In Finalizado the customer's order page shows the photo.

The Revisor, Gestão and the administrators take it (capability
"inspect"). Dialogs opened from a card's face or the board (Revisar,
Editar tempos) now show over the page when the order panel is closed;
inside the closed panel they were invisible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-09 11:39:15 -03:00
parent 5aafd9ee91
commit b280e0cfa6
18 changed files with 725 additions and 22 deletions

View File

@@ -18,7 +18,7 @@ from ..core.auth import (COOKIE_SECURE, DUMMY_PASSWORD_HASH, MOVERS, audit, can,
login_failed, may_move, may_reorder, password_matches, throttle)
from ..core.models import Contraction, Move, OperatorLogin, Resolution, Review, StrictModel, UploadStart
from ..printjobs import CLAIM_TIMEOUT, file_prefix, queue as queue_print_files
from .. import cnpj, hotfolder, machines, mail, payments, proof, prumo, quote_review, receipt, unpaid
from .. import cnpj, hotfolder, machines, mail, payments, proof, prumo, quote_review, receipt, reviews, unpaid
from .. import tiny
from ..payments import release_files
from ..runtime import (BACK, BOARD_FINISHED_LIMIT, BOARD_QUOTE_LIMIT, ENVIRONMENT, PUBLIC_ORIGIN, STATES,
@@ -338,8 +338,11 @@ def with_print_files(c, orders):
WHERE parent_id=ANY(%s) AND cancelled_at IS NULL ORDER BY parent_id, created_at DESC''', (ids,)).fetchall()}
parents = {r['id']: r for r in c.execute('SELECT id,number,state FROM dtf_local.orders WHERE id=ANY(%s)',
([o['parent_id'] for o in orders if o.get('parent_id')],)).fetchall()}
# Every order's review photos and videos, in one query like the print files.
review_rows = reviews.by_order(c, ids)
for order in orders:
order['hot'] = hot.get(order['id'])
order['reviews'] = review_rows.get(str(order['id']), [])
child = children.get(order['id'])
order['proof_card'] = child and {k: child[k] for k in ('id', 'number', 'state', 'proof_result',
'proof_decided_at', 'proof_decided_by', 'proof_reason')}
@@ -1177,6 +1180,11 @@ def move(uid: UUID, body: Move, request: Request, user=Depends(operator)):
raise HTTPException(409, 'Aguardando prova: o pedido entra na fila com Prova OK no card da prova.')
if body.state == 'fin' and not row.get('parent_id') and proof.needs_proof(row['snapshot']) and not row['proof_ok_at']:
raise HTTPException(409, 'Falta a prova: confira a prova impressa e marque Prova OK antes de finalizar.')
# Above 1 m the review photo is the evidence the sheet was checked; a
# proof card is no sale and skips this (app/reviews.py).
if (body.state == 'fin' and not back and not row.get('parent_id')
and reviews.required(row['snapshot']) and not reviews.has_photo(c, uid)):
raise HTTPException(409, 'Pedido acima de 1 m: tire a foto da revisão antes de finalizar.')
if body.state == 'cor':
c.execute("UPDATE dtf_local.order_files SET active=false WHERE order_id=%s AND kind='final'", (uid,))
# Who moved it, and on which machine: the one it goes to print on, or
@@ -1856,9 +1864,19 @@ def queue_folder(body: FolderSync, user=Depends(can('print'))):
due = c.execute('''SELECT id, number FROM dtf_local.orders WHERE receipt_due_at IS NOT NULL
AND receipt_saved_at IS NULL AND cancelled_at IS NULL AND (%s::timestamptz IS NULL OR receipt_due_at>=%s)
ORDER BY receipt_due_at''', (body.since, body.since)).fetchall() if body.early else []
# The review photos and videos to copy into Revisões/ (front 2). Without
# `since`, the last 30 days, so a new computer catches up.
since = body.since or datetime.now(timezone.utc) - timedelta(days=30)
review_rows = c.execute('''SELECT r.id,r.order_id,o.number,r.upload_id,u.name
FROM dtf_local.order_reviews r
JOIN dtf_local.orders o ON o.id=r.order_id
JOIN dtf_local.uploads u ON u.id=r.upload_id
WHERE o.cancelled_at IS NULL AND r.created_at>=%s ORDER BY r.created_at,r.id''', (since,)).fetchall()
return {'files': files,
'states': {str(o['id']): 'cancelled' if o['cancelled_at'] else o['state'] for o in held},
'receipts': [{'order': str(o['id']), 'number': o['number'], 'name': receipt.file_name(o)} for o in due]}
'receipts': [{'order': str(o['id']), 'number': o['number'], 'name': receipt.file_name(o)} for o in due],
'reviews': [{'id': r['id'], 'order': str(r['order_id']), 'number': r['number'],
'upload_id': str(r['upload_id']), 'name': r['name']} for r in review_rows]}
@router.get('/api/operator/uploads/{uid}/download')