From a17f5fc08d7e11cd3d9481bd53b5b67a78582dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 3 Nov 2026 11:10:23 -0300 Subject: [PATCH] fix: only the designer side approves files; specks are not strokes - "The designer approves every file" (Dropstar's rule D-16): the Operador leaves "produce", so it no longer approves final files, picks the contraction, treats the art or marks the contact wait. It pulls and prints. The order panel says the Designer approves and shows the contraction read-only; the profiles table follows. - The stroke measure drops ink components under 30 px (at 300 DPI) before the distance, as Dropstar's method says (2026-10-30). Each strip keeps at least 30 rows of context, so a speck is always seen whole and a component cut by the strip is a stroke. One real order sheet went from C1 (2 px, specks) to C2 (5 px); Dropstar's four test sheets still give 2, 5, 20 and 4 px. The artwork browser test checks widths 2, 5 and 6, and a C3 sheet with 300 specks. Co-Authored-By: Claude Opus 5.5 --- app/core/auth.py | 11 ++++--- tests/artwork_browser_test.mjs | 10 +++++++ tests/users_test.py | 5 ++++ web/kanban.js | 12 +++++--- web/site-sheet.js | 54 +++++++++++++++++++++++++++++----- 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/app/core/auth.py b/app/core/auth.py index e3e937b..c108c79 100644 --- a/app/core/auth.py +++ b/app/core/auth.py @@ -114,8 +114,11 @@ def login_failed(email): """Count a failed sign-in (or registration attempt) against the account.""" rate_limit('auth-account', email, 1_000_000) -# What each Kanban profile may do. "view" is reading; "produce" moves cards and -# handles artwork; "print" is the print room's side of it (the machine, the +# What each Kanban profile may do. "view" is reading; "produce" handles the +# artwork: approving the final files, the contraction, "Tratar a arte", the +# contact wait. "The designer approves every file" (Dropstar's rule D-16), so +# the operator does not: they pull and print. "print" is the print room's side +# of it (the machine, the # queue's order, its files and folder); "manage" covers quotes, cancellations # and payments; "users" is the Usuários page; "integrations" is everything in # Integrações but the print room's folder (connecting Tiny, the checks, the @@ -125,7 +128,7 @@ def login_failed(email): ROLES = ('superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor', 'vendedor', 'financeiro') CAPABILITIES = { 'view': set(ROLES), - 'produce': {'superadmin', 'admin', 'gestao', 'designer', 'operador'}, + 'produce': {'superadmin', 'admin', 'gestao', 'designer'}, 'print': {'superadmin', 'admin', 'gestao', 'operador'}, 'manage': {'superadmin', 'admin', 'gestao'}, # Registering an order paid outside the system, from its Site quote (D-35). @@ -144,7 +147,7 @@ CAPABILITIES = { 'cancel': {'superadmin', 'admin', 'gestao', 'financeiro'}, # "Retirado" at the counter (Dropstar's third round, item 14): everyone # but the seller, who only views (D-30). It includes everyone who produces, - # so an operator upload (artwork.py) takes it for its parts. + # and the operator, so an operator upload (artwork.py) takes it for its parts. 'deliver': {'superadmin', 'admin', 'gestao', 'designer', 'operador', 'revisor'}, } diff --git a/tests/artwork_browser_test.mjs b/tests/artwork_browser_test.mjs index 354d269..3574486 100644 --- a/tests/artwork_browser_test.mjs +++ b/tests/artwork_browser_test.mjs @@ -159,6 +159,16 @@ try{ stale:/14,90|conforme a nota|desconto|escada|menor preço da tabela/i.test(document.body.textContent)};})()`), {file:['R$ 19,90','R$ 19,90','R$ 19,90','R$ 19,90'],avulsa:['R$ 21,90','R$ 21,90'], uvfile:['R$ 79,90','R$ 79,90'],uv:['R$ 89,90','R$ 89,90'],stale:false}); + // Item 9: the thinnest stroke at 300 DPI as Dropstar measures it, an odd + // width being 2d - 1, and ink specks under 30 px left out (2026-10-30). + assert.deepEqual(await evaluate(`(async()=>{ + const medir=async(...rects)=>{const c=document.createElement('canvas');c.width=900;c.height=700; + const g=c.getContext('2d');g.fillStyle='#000';for(const r of rects)g.fillRect(...r); + return analisarMapa(await mapaDaImagem(await createImageBitmap(c),900/300*2.54)).traco;}; + const linhas=w=>[[50,50,800,w],[50,400,800,40]]; + const ciscos=Array.from({length:300},(_,i)=>[60+(i%30)*25,200+Math.floor(i/30)*15,3,3]); + return [(await medir(...linhas(2))).px,(await medir(...linhas(5))).px,(await medir(...linhas(6))).px, + (await medir(...linhas(20))).classe,(await medir(...linhas(20),...ciscos)).classe];})()`),[2,5,6,'C3','C3']); await click('[data-modo="file"]'); // Opening a product paints on the next frame; on a busy runner the check // must wait for it rather than race it. diff --git a/tests/users_test.py b/tests/users_test.py index 1d7d973..8f738fe 100644 --- a/tests/users_test.py +++ b/tests/users_test.py @@ -153,6 +153,11 @@ def run(): assert (me['machine_question'], me['machine_answered'], me['machine']) == ('required', False, None), me assert {str(uv_o), str(textil_o)} <= {o['id'] for o in op.call('/operator/board')['orders']} assert sorted(me['moves']) == [['imp', 'rev'], ['imp', 'tra'], ['rev', 'imp'], ['tra', 'imp']] + # The designer approves every file (D-16): the operator neither approves + # a final nor picks the contraction. + assert me['can'] == ['deliver', 'print', 'view'], me + op.call(f'/operator/orders/{uv_o}/contraction', {'item_index': 0, 'value': 'C2'}, expected=403) + op.call(f'/operator/orders/{uv_o}/final-files', {'version': 0, 'note': '', 'files': []}, expected=403) op.call(f'/operator/orders/{uv_o}/move', {'state': 'tra', 'version': 0, 'reason': ''}, expected=403) with db.connect() as c: c.execute("UPDATE dtf_local.orders SET state='imp' WHERE id=%s", (uv_o,)) diff --git a/web/kanban.js b/web/kanban.js index 93ee5e7..57a9301 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -1471,10 +1471,14 @@ function nextBox(order){ :st==='rev'?'A folha impressa é conferida e liberada pelo Revisor.':'Daqui em diante, com a produção.'); if(st==='rec'||st==='cor'){ if(!finalDone(order)&&trans.includes('tra')){ - const lead=st==='rec'||fixed, a=approveParts(order,lead); if(st==='rec')title='Aprovar o arquivo final'; - if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);} - else more.push(a.approve,...a.extra); + // The designer approves every file (D-16); the others see it waiting. + if(!may('produce')){note('O Designer confere e aprova o arquivo final.');body.push(contractionList(order));} + else{ + const lead=st==='rec'||fixed, a=approveParts(order,lead); + if(lead){if(a.files)body.push(a.files);note(a.text);body.push(contractionList(order));main.push(a.approve,...a.extra);} + else more.push(a.approve,...a.extra); + } }else if(st==='rec'){ title='Mandar para a fila'; note('O arquivo final está aprovado. Na fila, o operador puxa para a máquina.'); @@ -2046,7 +2050,7 @@ function avatar(u,className='ava'){ } // "O que cada perfil faz": Y does it, V only looks; the server's rules (app/core/auth.py). const ROLE_COLUMNS=['admin','gestao','designer','operador','revisor','vendedor','financeiro']; -const ROLE_MATRIX=[['Aprovar o arquivo final','YYYYNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'], +const ROLE_MATRIX=[['Aprovar o arquivo final','YYYNNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'], ['Liberar para Finalizado','YNNNYNN'],['Voltar uma etapa, com motivo','YYYYYNN'],['Marcar retirado','YYYYYNN'], ['Cotações e Números','YYNNNVV'],['Pagamentos','YYNNNNV'],['Pedido pago fora do site','YYNNNNN'],['Cancelar pedido','YYNNNNY'], ['Abrir retrabalho','NYNNNNN'],['Autorizar retrabalho','YNNNNNN'],['Usuários e máquinas','YNNNNNN']]; diff --git a/web/site-sheet.js b/web/site-sheet.js index d67dda4..96666f3 100644 --- a/web/site-sheet.js +++ b/web/site-sheet.js @@ -70,12 +70,51 @@ function novoMapa(wPx,hPx,larguraCm){ // larguras, em pixels a 300 DPI: até 4 é C1, de 5 a 19 é C2, 20 ou mais é C3. // A folha passa em faixas, linha a linha: cada faixa guarda 20 linhas antes e // depois, o alcance da distância, e nada maior que uma faixa fica na memória. -const ALFA_TRACO=40, TRACO_D=20, TRACO_FAIXA=256; +const ALFA_TRACO=40, TRACO_D=20, TRACO_FAIXA=256, TRACO_CISCO=30; +// O contexto de cada faixa: as linhas acima e abaixo que ela lê sem medir. Um +// cisco (menos de 30 px de tinta a 300 DPI) tem menos linhas que isso, então +// a faixa sempre o vê inteiro; o que encosta na borda cortada é traço. function novoTraco(wPx,dpi){ - const linhas=TRACO_FAIXA+2*TRACO_D; - return {w:wPx,dpi,linhas,tinta:new Uint8Array(wPx*linhas),dist:new Uint16Array(wPx*linhas), + const cisco=Math.ceil(TRACO_CISCO*(dpi/300)**2), ctx=Math.min(120,Math.max(TRACO_D,cisco)); + const linhas=TRACO_FAIXA+2*ctx; + return {w:wPx,dpi,linhas,ctx,cisco,tinta:new Uint8Array(wPx*linhas),dist:new Uint16Array(wPx*linhas), + rot:new Int32Array(wPx*linhas),pai:new Int32Array((wPx*linhas>>1)+2),area:new Int32Array((wPx*linhas>>1)+2), n:0,inicio:0,hist:new Float64Array(2*TRACO_D+2),total:0,tintaPx:0,largosPx:0}; } +// Como a sala mede (Dropstar, 30/10/2026): componentes de tinta com menos de +// 30 px não são traço e saem antes da distância. Vizinhos nas oito direções. +function tiraCiscos(t,topo,fim){ + const {w,n,tinta,rot,pai,area,cisco}=t; + let prox=1; + const raiz=a=>{while(pai[a]!==a){pai[a]=pai[pai[a]];a=pai[a];}return a;}; + const une=(a,b)=>{a=raiz(a);b=raiz(b);if(a===b)return a;if(a0&&tinta[a], dir=y>0&&x0&&tinta[p-1]) r=rot[p-1]; + else if(y>0&&x>0&&tinta[a-1]) r=rot[a-1]; + if(dir) r=r?une(r,rot[a+1]):rot[a+1]; + } + if(!r){ r=prox++; pai[r]=r; area[r]=0; } + rot[p]=r; } } + if(prox===1) return; + // Cada rótulo aponta para um menor: em ordem, um passo só leva à raiz. + for(let r=1;rALFA_TRACO?1:0; @@ -84,8 +123,9 @@ function tracoLinha(t,alfa,inicio,de){ } // A distância na faixa, e as larguras das linhas que ela já mede inteiras. function tracoFaixa(t,fim){ - const {w,n,tinta,dist}=t, CAP=TRACO_D*10+10, topo=t.inicio===0; + const {w,n,tinta,dist,ctx}=t, CAP=TRACO_D*10+10, topo=t.inicio===0; if(!n) return; + tiraCiscos(t,topo,fim); for(let p=0;p(x<0||x>=w||y<0||y>=n)?0:dist[y*w+x]; // Item 16: tinta em áreas de 20 px ou mais (a 300 DPI) é a que fica a 10 px @@ -134,7 +174,7 @@ function tracoFaixa(t,fim){ } // As últimas linhas ficam como contexto da próxima faixa. if(!fim){ - const fica=2*TRACO_D; + const fica=2*ctx; tinta.copyWithin(0,(n-fica)*w,n*w); t.inicio+=n-fica; t.n=fica; } @@ -145,7 +185,7 @@ function tracoFaixa(t,fim){ function tracoFim(t){ if(t.lido!==undefined) return t.lido; tracoFaixa(t,true); - t.tinta=t.dist=null; // a faixa não serve mais + t.tinta=t.dist=t.rot=t.pai=t.area=null; // a faixa não serve mais if(!t.total) return t.lido=null; let soma=0, px=1; for(let i=1;i=t.total*0.01){ px=i; break; } }