From 857eea33791e30603d3288255f36edc8126f6c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 30 Nov 2026 11:28:24 -0300 Subject: [PATCH] feat: copies from the file name, the proof in the summaries, the grade off the customer's screen (Rodada 5, B3, B6, D6) B6: "12x nome.png" enters with 12 copies, art or ready sheet (up to 200; "1920x1080.png" is not read as copies). B3: the DPI refusal speaks per art, the cart and payment summaries list "Prova antes de imprimir" when chosen, and below 10 m the proof box stays, closed, saying the rule. D6: the Ajuste Fino refusal no longer shows the grade number (Site and server); the unused motivoNota helper is gone. Co-Authored-By: Claude Opus 5.5 --- app/grade_rules.py | 5 +++-- tests/grade_rules_test.py | 2 +- tests/test_grade_rules.py | 2 +- web/checkout.js | 1 + web/index.html | 1 + web/site-cart.js | 12 +++++++++--- web/site-config.js | 4 ++++ web/site-packing.js | 13 ------------- web/site-quality.js | 2 +- web/site-upload.js | 4 ++-- web/site-v2.css | 2 ++ 11 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app/grade_rules.py b/app/grade_rules.py index 303fb63..5cd254c 100644 --- a/app/grade_rules.py +++ b/app/grade_rules.py @@ -29,6 +29,7 @@ def triggered(rules: dict, items, treatment_offered: bool) -> dict: def treatment_message(grade: int) -> str: - """The refusal the customer sees when Ajuste Fino is required.""" - return (f'Sua arte tem nota {grade}: para imprimir com qualidade, o Ajuste Fino ' + """The refusal the customer sees when Ajuste Fino is required. The grade + stays on the Kanban: the customer never sees the number (Rodada 5, D6).""" + return ('Sua arte está abaixo da resolução mínima, então o Ajuste Fino ' 'é obrigatório neste pedido.') diff --git a/tests/grade_rules_test.py b/tests/grade_rules_test.py index b11469e..2e8270e 100644 --- a/tests/grade_rules_test.py +++ b/tests/grade_rules_test.py @@ -48,7 +48,7 @@ def run(): 'quality_status': 'warning', 'quality_acknowledged': True} refused = client.call('/quotes', quote_body(item, False, mail), expected=422) - assert refused['detail'] == ('Sua arte tem nota 50: para imprimir com qualidade, ' + assert refused['detail'] == ('Sua arte está abaixo da resolução mínima, então ' 'o Ajuste Fino é obrigatório neste pedido.'), refused made = client.call('/quotes', quote_body(item, True, mail)) diff --git a/tests/test_grade_rules.py b/tests/test_grade_rules.py index cb0889b..8ffa42d 100644 --- a/tests/test_grade_rules.py +++ b/tests/test_grade_rules.py @@ -34,7 +34,7 @@ class GradeRulesTest(unittest.TestCase): def test_treatment_message(self): self.assertEqual( treatment_message(45), - 'Sua arte tem nota 45: para imprimir com qualidade, o Ajuste Fino ' + 'Sua arte está abaixo da resolução mínima, então o Ajuste Fino ' 'é obrigatório neste pedido.') diff --git a/web/checkout.js b/web/checkout.js index 351e3f1..37a333e 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -214,6 +214,7 @@ rows.push(linha('Ajuste Fino Redesenho'+(arts?' · '+arts+(arts===1?' arte':' artes'):'')+' · +48 h', rs(quote.redesign.cents/100))); } + if(approved.proof) rows.push(linha('Prova antes de imprimir','Grátis')); if(approved.coupon) rows.push(linha('Cupom '+approved.coupon.code, '− '+rs(approved.coupon.discount_cents/100))); rows.push(linha('Total', rs(approved.total_cents/100), 'tot')); diff --git a/web/index.html b/web/index.html index 905c761..d30edcd 100644 --- a/web/index.html +++ b/web/index.html @@ -1124,6 +1124,7 @@ h2 em{font-style:normal;color:var(--laranja)} Quero aprovar uma prova antes de imprimir Imprimimos uma prova de até 30 cm e mandamos a foto pelo WhatsApp. O resto sai depois que você aprovar. Até 3 provas por pedido, sem custo. + ':'')+ (redesenho?'
Ajuste Fino Redesenho · '+artesRedesenho+ (artesRedesenho===1?' arte':' artes')+' · +48 h'+rs(redesenho)+'
':'')+ + ($('fProva')?.checked?'
Prova antes de imprimir'+ + 'Grátis
':'')+ '
Revisão e reencaixe'+ 'Grátis
'; $('carrTot').textContent=rs(soma); @@ -268,9 +270,12 @@ function pintaPedido(){ : n>1 ? 'Pagar os '+n+' itens de uma vez' : 'Ir para o pagamento'; - // The proof is only for orders above 10 m (Dropstar, 2026-10-28): below it the box is gone. + // The proof is only for orders above 10 m (Dropstar, 2026-10-28; the server's + // PROOF_ABOVE_METRES). Below it the box stays, closed, and says the rule + // (Rodada 5, B3). const prova=$('fProva'); - if(prova){ const longo=aPagar.reduce((t,it)=>t+(it.cob||0),0)>10; prova.closest('.cxE').hidden=!longo; if(!longo) prova.checked=false; } + if(prova){ const longo=aPagar.reduce((t,it)=>t+(it.cob||0),0)>10; + prova.disabled=!longo; if(!longo) prova.checked=false; $('provaMin').hidden=longo; } $('bPagar').disabled = !cartPodeEnviar() || !entrega.cotado || !clienteOk() || !enderecoOk() || falta>0; if(pedido.length || itemAtual) $('carr').classList.add('on'); if($('cartN')){ $('cartN').textContent=noCarrinho>99?'99+':noCarrinho; $('cartN').hidden=!noCarrinho; @@ -374,6 +379,7 @@ function avisaDesfazer(texto,acao){ function fechaDesfazer(){ clearTimeout(desfazerTimer); desfazerAcao=null; $('desfazer').hidden=true; } addEventListener('dtf-page-changed',fechaDesfazer); $('desfazerBtn').addEventListener('click',()=>{ const acao=desfazerAcao; fechaDesfazer(); if(acao) acao(); }); +$('fProva')?.addEventListener('change',()=>pintaPedido()); $('fTratamento')?.addEventListener('change',()=>{ if($('fTratamento').checked){ ajusteTudo=true; limpaRedesenho(); } else limpaAjuste(); diff --git a/web/site-config.js b/web/site-config.js index cdb66a2..a129872 100644 --- a/web/site-config.js +++ b/web/site-config.js @@ -223,3 +223,7 @@ const dpiDe=a=>a.cm>0? (a.giro?a.py:a.px)/(a.cm/2.54) : 0; // girar 90° inverte a proporção · espelhar não muda medida, só o desenho const propDe=a=>{ const p=a.prop||1; return a.giro? 1/p : p; }; const TAMANHOS={57:[10,15,20,25,28.2], 27:[5,8,10,13,26.7]}; +// "12x nome.png" já entra com 12 cópias (Rodada 5, B6; a BinnFlow faz assim): +// até 3 dígitos, um x e um separador, para "1920x1080.png" não virar cópias. +const copiasDoNome=nome=>{ const m=/^(\d{1,3})\s*[xX×][\s_-]+\S/.exec(nome||''); + return m? Math.max(1,Math.min(200,+m[1]||1)) : 1; }; diff --git a/web/site-packing.js b/web/site-packing.js index 43e5a7e..8b79d30 100644 --- a/web/site-packing.js +++ b/web/site-packing.js @@ -273,19 +273,6 @@ function montaFolhasDeTraco(grupos,W){ area.replaceChildren(painel); } -function motivoNota(){ - if(!nota) return 'sem nota ainda · conferimos antes de imprimir'; - if(!ehFolha()){ - const ruins=artes.filter(a=>a.cm>0 && dpiDe(a)<300); - if(!ruins.length) return 'nota '+nota+' · todas as artes em 300 DPI ou mais'; - const pior=ruins.reduce((p,a)=>dpiDe(a)1?' artes abaixo':' arte abaixo')+ - ' de 300 DPI · a menor é "'+pior.f.name+'" com '+ - Math.round(dpiDe(pior))+' DPI em '+pior.cm.toFixed(1).replace('.',',')+' cm'; - } - return nota>=90 ? 'nota '+nota+' · resolução ótima em toda a folha' - : 'nota '+nota+' · só a resolução pede atenção, o resto corrigimos'; -} function previa(){ const T=window.dtfTimings; if(T && T.montageStart!=null && T.montageEnd==null) T.montageEnd=performance.now(); diff --git a/web/site-quality.js b/web/site-quality.js index fbf7b3d..7486723 100644 --- a/web/site-quality.js +++ b/web/site-quality.js @@ -258,7 +258,7 @@ function ressalvaResolucao(){ // e não existe aceite que destrave. if(recusadas.length){ $('cienteTxt').innerHTML= - '

A média da folha ficou abaixo de '+DPI_RECUSA+' DPI. Não imprimimos assim: '+ + '

'+(recusadas.length>1?recusadas.length+' artes ficaram':'Uma arte ficou')+' abaixo de '+DPI_RECUSA+' DPI. Não imprimimos assim: '+ 'sai serrilhado demais. Envie em resolução maior ou reduza a largura.

'+ '
'+recusadas.map(b=>'
'+escapeHTML(b.nome)+': '+ (b.quantas diff --git a/web/site-upload.js b/web/site-upload.js index e2b6b18..b6207c7 100644 --- a/web/site-upload.js +++ b/web/site-upload.js @@ -187,7 +187,7 @@ async function sel(fs){ // On their way at once; a JPG is refused at the order anyway. fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f)); if(ehFolha()){ - const novas=fs.map(f=>({f, med:null, rep:1, m:0, corte:null, semAnalise:null, analiseInicio:Date.now()})); + const novas=fs.map(f=>({f, med:null, rep:copiasDoNome(f.name), m:0, corte:null, semAnalise:null, analiseInicio:Date.now()})); folhas=folhas.concat(novas); // soma, não substitui pintaFolha(); novas.forEach(x=>{ @@ -282,7 +282,7 @@ async function sel(fs){ }); return; } - const novos=fs.map(f=>({f,px:0,py:0,cm:0,q:1,prop:1,giro:0,esp:false,analiseInicio:Date.now()})); + const novos=fs.map(f=>({f,px:0,py:0,cm:0,q:copiasDoNome(f.name),prop:1,giro:0,esp:false,analiseInicio:Date.now()})); artes=novos.concat(artes); // a mais recente fica no topo da fila recemChegada=novos[0]; pintaArtes(); diff --git a/web/site-v2.css b/web/site-v2.css index 8c62d58..73bbe80 100644 --- a/web/site-v2.css +++ b/web/site-v2.css @@ -348,6 +348,8 @@ section+section{border-top:0} .provaOp{display:flex;gap:10px;align-items:flex-start;cursor:pointer;font-size:15px;line-height:1.5;color:var(--fraco)} .provaOp input{margin-top:3px;width:17px;height:17px;flex:none;accent-color:var(--laranja)} .provaOp b{display:block;color:var(--preto);font-weight:700} +.provaOp:has(input:disabled){cursor:default;opacity:.55} +.provaMin{margin:8px 0 0 27px;font-size:14px;color:var(--fraco)} .cp input,.cepL input{height:46px;border-radius:var(--raio2)} .cp input:focus,.cepL input:focus{border-color:var(--laranja2);box-shadow:0 0 0 3px rgba(255,168,26,.18)} .opE{border-radius:12px}