feat: the proof's photo or video opens beside Prova OK and from its order, also after the answer
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 6m43s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m11s

Marcus could not reach the review photo of the proof of #30 (card #31):
in Revisão it sat at the end of the card's Pedido tab, away from the
answer, and once the seller answered, the card left the board and the
photo with it.

- The board sends each order's proof card with its photos and videos.
- "Responder a prova" has "Ver foto" / "Ver vídeo" beside Prova OK, or
  says the Revisor has not sent one yet.
- The parent shows a Prova section (the card, its answer, who and when)
  with the same buttons, and "Aguardando prova" offers them too.
- The viewer drops the print-file line for a review photo and reports a
  photo it could not load, in red and to Sentry.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-17 10:37:33 -03:00
parent 5d9a78b63c
commit c61ac27ca4
5 changed files with 71 additions and 13 deletions

View File

@@ -217,12 +217,17 @@ def with_print_files(c, orders):
([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)
# The proof card's go on its order too: an answered card leaves the board,
# and the photo the seller answered on must stay a click away (Marcus,
# 2026-11-17, the proof of #30).
proof_reviews = reviews.by_order(c, [r['id'] for r in children.values()])
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')}
order['proof_card'] = child and {**{k: child[k] for k in ('id', 'number', 'state', 'proof_result',
'proof_decided_at', 'proof_decided_by', 'proof_reason')},
'reviews': proof_reviews.get(str(child['id']), [])}
parent = parents.get(order.get('parent_id'))
order['proof_parent'] = parent and {'id': parent['id'], 'number': parent['number'], 'state': parent['state']}
order['correction_reason'] = reasons.get(order['id']) if order['state'] == 'cor' else None

View File

@@ -294,8 +294,17 @@ def run():
wait_print(client, card['id'], 'ready')
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (card['id'],))
# The proof's photo, taken in Revisão, stays reachable from its order once
# the answered card leaves the board (the proof of #30, 2026-11-17).
with db.connect() as c:
c.execute('''INSERT INTO dtf_local.order_reviews(order_id,seq,upload_id,kind,width,height,created_by)
VALUES(%s,1,%s,'photo',1600,1200,'Revisor')''', (card['id'], readable))
client.call('/operator/orders/' + card['id'] + '/proof-answer', {'result': 'ok'}, operator=True)
mine = next(o for o in client.call('/operator/board', operator=True)['orders'] if o['id'] == parent['id'])
assert [r['kind'] for r in mine['proof_card']['reviews']] == ['photo'], mine['proof_card']
view = client.call('/operator/orders/' + card['id'] + '/reviews/' + str(mine['proof_card']['reviews'][0]['id'])
+ '/view', operator=True)
assert view['url'] and view['kind'] == 'photo', view
assert mine['state'] == 'tra' and mine['final_items'] == [0], mine
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok', mine
with db.connect() as c:

View File

@@ -268,12 +268,17 @@ function nextBox(order){
note(manual?'O Prumo não abriu o original. Prepare o PNG completo deste pedido; a prova será gerada automaticamente a partir dele.'
:'O pedido segue para Arte conferida após Prova OK no card da prova. Você pode abrir o arquivo para consultar.');
if(manual&&may('produce'))main.push(button('Preparar arquivo para a prova',()=>finalDialog(order,readyFinals(order)),'btn pri lg'));
if(order.proof_card.reviews?.length)more.push(...reviewButtons(order.proof_card.id,order.proof_card.reviews,order.proof_card.number));
return composeNext(title,body,main,more);
}
// A proof card in Revisão waits for its answer (Dropstar, 2026-11-03).
if(order.proof_parent&&st==='rev'){
title='Responder a prova';
note('Prova do pedido #'+order.proof_parent.number+'. Com a prova impressa conferida'+(order.snapshot.proof?' e o aceite do cliente':'')+', responda aqui.');
// The photo or video the answer rests on, beside the answer (Marcus, 2026-11-17).
const media=order.reviews||[];
if(media.length)main.push(...reviewButtons(order.id,media,order.number));
else note('A foto ou o vídeo da prova ainda não foi enviado: o Revisor envia em “Revisar”, no card.');
if(may('proof')){main.push(button('Prova OK',()=>proofAnswer(order,'ok'),'btn pri lg'));
more.push(button('Prova reprovada',()=>proofReject(order),'btn quiet lg'));}
else note('Quem responde é o Vendedor, a Gestão ou o Administrador.');
@@ -899,8 +904,42 @@ function treatDialog(order){
paint();
})();
}
// The reviews recorded on the order: what was checked, when and by whom. A
// photo opens in the viewer; a video cannot, so it opens in a new tab. In
// A review's photo opens in the viewer; a video cannot, so it opens in a new
// tab. `orderId` is the order it was taken on: a proof's is its proof card.
async function openReview(orderId,review,number){
const view=await api('/orders/'+orderId+'/reviews/'+review.id+'/view');
if(review.kind==='photo'&&window.openViewer)openViewer([{name:view.name,picture:view.url,photo:true}],{title:'Revisão #'+number});
else{const link=node('a');link.href=view.url;link.target='_blank';link.rel='noopener noreferrer';link.click();}
}
// "Ver foto" / "Ver vídeo", one per review, numbered when there are several.
function reviewButtons(orderId,reviews,number,className='btn lg'){
const count={photo:0,video:0};
for(const review of reviews)count[review.kind]++;
return reviews.map(review=>{
const b=button((review.kind==='video'?'Ver vídeo':'Ver foto')+(count[review.kind]>1?' '+review.seq:''),
()=>openReview(orderId,review,number),className);
b.prepend(svgIcon(review.kind==='video'?IC.camera:IC.eye||IC.file,'i m'));return b;});
}
// The order's proof (app/proof.py): its card, where it stands or its answer,
// and the photo or video it was answered on. An answered card leaves the
// board, so this is where its media stays (Marcus, 2026-11-17, the proof of #30).
function proofSection(order){
const card=order.proof_card;
if(!card)return null;
const box=node('section',undefined,'reviewsec');box.setAttribute('aria-label','Prova');
const info=node('div',undefined,'iinfo');
const answer=card.proof_result==='ok'?'Prova OK':card.proof_result==='rejected'?'Prova reprovada':
'Aguardando a resposta'+(card.state==='rev'?', em Revisão':'');
info.append(node('span','Prova','lbl'),node('h3','Prova do #'+card.number+' · '+answer));
if(card.proof_result)info.append(node('p',(card.proof_decided_by||'')+' · '+when(card.proof_decided_at)+
(card.proof_reason?' · '+card.proof_reason:''),'nnote'));
const media=card.reviews||[];
if(media.length){const row=node('div',undefined,'nact proofmedia');row.append(...reviewButtons(card.id,media,card.number,'btn'));info.append(row);}
else info.append(node('p',card.proof_result?'Nenhuma foto ou vídeo foi enviado na prova.':'A foto ou o vídeo da prova entra quando o Revisor enviar.','nnote'));
box.append(info);
return box;
}
// The reviews recorded on the order: what was checked, when and by whom. In
// Revisão a reviewer may remove one.
function reviewSection(order){
if(!order.reviews?.length)return null;
@@ -914,11 +953,7 @@ function reviewSection(order){
open.append(node('span','Revisão · '+(review.kind==='video'?'vídeo':'foto')+' · '+
when(review.created_at)+' · '+review.created_by));
open.onclick=async()=>{
try{
const view=await api('/orders/'+order.id+'/reviews/'+review.id+'/view');
if(review.kind==='photo'&&window.openViewer)openViewer([{name:view.name,picture:view.url}],{title:'Revisão #'+order.number});
else{const link=node('a');link.href=view.url;link.target='_blank';link.rel='noopener noreferrer';link.click();}
}catch(error){say(error.message,true);}
try{await openReview(order.id,review,order.number);}catch(error){say(error.message,true);}
};
row.append(open);
if(order.state==='rev'&&may('inspect')){
@@ -941,6 +976,7 @@ function orderView(order){
const s=order.snapshot;
s.items.forEach((item,index)=>view.append(itemCard(order,item,index)));
view.append(orderFacts(order));
const proof=proofSection(order);if(proof)view.append(proof);
const reviews=reviewSection(order);if(reviews)view.append(reviews);
if(order.reworks?.length)view.append(reworkSection(order));
return view;

View File

@@ -8,8 +8,8 @@
width at the zoom shown (app/printtiles.py), only those on screen.
openViewer(files, {title, onClose}): files are [{name, label, manifest,
picture}], each with its strips' manifest (and their urls), or only a
picture when it has none. */
picture, photo}], each with its strips' manifest (and their urls), or only a
picture when it has none; `photo` marks a review photo, which is whole. */
(function(){
const BG_KEY='dtf-viewer-bg';
const BACKGROUNDS=[['light','Claro'],['dark','Escuro'],['check','Xadrez']];
@@ -103,8 +103,15 @@
for(const b of tabs.children)b.setAttribute('aria-pressed',String(b===tab));
name.textContent=title?title+' · '+f.name:f.name;
if(!f.manifest){
note.textContent=f.picture?'Este arquivo não tem os pedaços para 100%: veja a prévia ou baixe o arquivo.':'Este arquivo não tem prévia: baixe para conferir.';
if(f.picture){try{const r=await fetch(f.picture);picture=await createImageBitmap(await r.blob());}catch(_){}}
// A review photo is the whole picture; a print file without pieces is only its preview.
note.textContent=f.photo?'':f.picture?'Este arquivo não tem os pedaços para 100%: veja a prévia ou baixe o arquivo.':'Este arquivo não tem prévia: baixe para conferir.';
if(f.picture){
try{const r=await fetch(f.picture);if(!r.ok)throw new Error('erro '+r.status);picture=await createImageBitmap(await r.blob());}
catch(e){
const text='Não foi possível abrir '+(f.photo?'a foto':'a prévia')+' '+f.name+' ('+e.message+').';
note.textContent=text;window.dtfObservability?.uiError?.(text,'kanban');
}
}
}
zoom=fitZoom();x=0;y=0;clamp();zoomText.textContent=Math.round(zoom*100)+'%';draw();
}

View File

@@ -313,6 +313,7 @@ main{padding:0}
.modal.reviewdialog .dfoot{padding-top:14px;border-top:1px solid var(--ln)}
.reviewlist{display:flex;flex-direction:column;max-height:220px;overflow:auto;border-top:1px solid var(--ln)}
.reviewsec{padding-top:22px;border-top:1px solid var(--ln)}
.proofmedia{margin-top:10px}
.reviewrow{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid var(--ln)}
.reviewopen{flex:1;min-width:0;padding:5px 2px;border:0;background:none;color:var(--tx);font:inherit;font-size:13px;text-align:left;cursor:pointer}
.reviewopen:hover,.reviewopen:focus-visible{color:var(--acc)}