diff --git a/app/api/operator/orders.py b/app/api/operator/orders.py index 25a9e4d..2baade0 100644 --- a/app/api/operator/orders.py +++ b/app/api/operator/orders.py @@ -593,8 +593,9 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))): """Generate the print files again although they are ready, for the part size of now (PRINT_PART_CM): a 15 m part is more than the FlexiPRINT opens (order #36, 2026-11-17). The finals that were the generated files - stop counting, and an order in Arte conferida steps back to Arte - recebida, where the new files are approved again.""" + stop counting, and an order in Arte conferida or Imprimindo goes back to + Arte recebida, where the new files are approved again; from Imprimindo + what Flexi has not taken leaves the hot folder (app/hotfolder.py).""" with db.connect() as c: row = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (uid,)).fetchone() if not row: @@ -602,8 +603,8 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))): if row['cancelled_at']: raise HTTPException(409, 'Pedido cancelado.') proof.require_unlocked(c, row) - if row['state'] not in ('rec', 'tra'): - raise HTTPException(409, 'Volte o pedido para Arte conferida antes de gerar o arquivo de novo.') + if row['state'] not in ('rec', 'tra', 'imp'): + raise HTTPException(409, 'O arquivo é gerado de novo até Imprimindo.') if c.execute("SELECT 1 FROM dtf_local.order_files WHERE order_id=%s AND kind='correction' LIMIT 1", (uid,)).fetchone(): raise HTTPException(409, 'O cliente mandou uma correção: o arquivo final é preparado à mão.') @@ -614,9 +615,11 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))): (uid,)) # The new version tells the board and the folders the files changed. c.execute("UPDATE dtf_local.orders SET state='rec', version=version+1, updated_at=now() WHERE id=%s", (uid,)) - if row['state'] == 'tra': + if row['state'] == 'imp': + hotfolder.stop(c, uid) + if row['state'] != 'rec': c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason,back) - VALUES(%s,'tra','rec',%s,'Arquivo gerado de novo',true)''', (uid, user)) + VALUES(%s,%s,'rec',%s,'Arquivo gerado de novo',true)''', (uid, row['state'], user)) requeue_print_files(c, uid, len(row['snapshot']['items'])) audit('print_file_regenerated', order=str(uid), operator=user) return {'ok': True} diff --git a/tests/print_file_test.py b/tests/print_file_test.py index bd05ce1..81e66a0 100644 --- a/tests/print_file_test.py +++ b/tests/print_file_test.py @@ -170,10 +170,8 @@ def run(): print('PASS: generated file approved as final without re-uploading; order queued for printing') # A ready file generated again for the part size of now (order #36, - # 2026-11-17): refused while printing; from Arte conferida the generated - # final goes, the order steps back to Arte recebida and the file is made - # once more. - client.call('/operator/orders/' + oid + '/print-files/again', {}, operator=True, expected=409) + # 2026-11-17): from Arte conferida or Imprimindo the generated final goes, + # the order is back in Arte recebida and the file is made once more. again_upload = upload_bytes(client, artwork(), name='LOCAL-AGAIN.png') again, made = wait_print(client, paid_order(client, loose_item(again_upload))['id'], 'ready') v = client.call('/operator/orders/' + again['id'] + '/final-files', diff --git a/web/kanban-order.js b/web/kanban-order.js index 25bec13..afa2359 100644 --- a/web/kanban-order.js +++ b/web/kanban-order.js @@ -299,12 +299,14 @@ function nextBox(order){ } // A ready file generated again, for the part size of now: a 15 m part is // more than the FlexiPRINT opens (order #36, 2026-11-17). The approved - // generated final goes, so the order is back in Arte recebida. - if((st==='rec'||st==='tra')&&!order.proof_parent&&!fixed&&may('produce')&& + // generated final goes, so the order is back in Arte recebida; from + // Imprimindo its file also leaves the machine's hot folder. + if((st==='rec'||st==='tra'||st==='imp')&&!order.proof_parent&&!fixed&&may('produce')&& (order.print_files||[]).some(r=>r.status==='ready')) more.push(button('Gerar de novo',async()=>{ if(!await ask('Gerar o arquivo de novo?','O sistema gera o arquivo do pedido de novo, com o tamanho de parte de agora. '+ - 'O arquivo final aprovado sai: o pedido fica em Arte recebida e o arquivo novo precisa ser aprovado.', + 'O arquivo final aprovado sai: o pedido volta para Arte recebida'+(st==='imp'?', sai da hot folder da máquina,':'')+ + ' e o arquivo novo precisa ser aprovado.', 'Gerar de novo',{host:$('drawer')}))return; await api('/orders/'+order.id+'/print-files/again',{});await load(); say('Gerando o arquivo do #'+order.number+' de novo. Aprove quando ficar pronto.');