diff --git a/app/artwork.py b/app/artwork.py index 281088f..932cf6c 100644 --- a/app/artwork.py +++ b/app/artwork.py @@ -77,19 +77,28 @@ def submit_files(c, order, body, identity, kind, actor): kept = {ref.upload_id for ref in body.files if (ref.upload_id, ref.item_index) in current} if kept and len(kept) == len(body.files): raise HTTPException(409, 'Estes já são os arquivos finais. Envie o arquivo novo.') + revived = set() for ref in body.files: if ref.upload_id in kept: continue corrected = correction_owner(c, order, ref, kind) - upload = upload_row(c, ref.upload_id, corrected or generated_owner(c, order, ref, kind) or identity, lock=True) + generated = None if corrected else generated_owner(c, order, ref, kind) + upload = upload_row(c, ref.upload_id, corrected or generated or identity, lock=True) if not upload['complete']: raise HTTPException(409, 'Espere o envio de todos os arquivos terminar.') require_clean(upload) if kind == 'final': require_final_png(storage, upload) - # Attached once, except a correction approved as its own final. - if c.execute('SELECT id FROM dtf_local.order_files WHERE upload_id=%s'+(" AND kind<>'correction'" if corrected else ''), - (ref.upload_id,)).fetchone(): + # Attached once, except a correction approved as its own final, and a + # generated file or a correction that was this item's final and + # stopped counting (a step back, Correção): it is turned back on + # (Sentry DTF-WEB-10). + rows = c.execute('SELECT order_id,item_index,kind FROM dtf_local.order_files WHERE upload_id=%s' + + (" AND kind<>'correction'" if corrected else ''), (ref.upload_id,)).fetchall() + if rows and (corrected or generated) and all( + r['order_id'] == order['id'] and r['kind'] == 'final' and r['item_index'] == ref.item_index for r in rows): + revived.add(ref.upload_id) + elif rows: raise HTTPException(409, 'Este arquivo já está no pedido. Envie uma nova versão.') # A new customer correction supersedes every final prepared from earlier # artwork, including finals uploaded while this order was in correction. @@ -98,7 +107,7 @@ def submit_files(c, order, body, identity, kind, actor): else: c.execute('UPDATE dtf_local.order_files SET active=false WHERE order_id=%s AND kind=%s', (order['id'],kind)) for ref in body.files: - if ref.upload_id in kept: + if ref.upload_id in kept or ref.upload_id in revived: c.execute("UPDATE dtf_local.order_files SET active=true WHERE order_id=%s AND upload_id=%s AND kind='final'", (order['id'], ref.upload_id)) continue diff --git a/tests/print_file_test.py b/tests/print_file_test.py index 667abba..83506ff 100644 --- a/tests/print_file_test.py +++ b/tests/print_file_test.py @@ -221,6 +221,27 @@ def run(): assert str(remade['upload_id']) != str(made['upload_id']), (made, remade) print('PASS: a ready file is generated again from Arte conferida, back in Arte recebida to approve') + # The generated file approved, sent to Correção (its final stops counting) + # and back: the same file is approved again, not refused as already in + # the order (Sentry DTF-WEB-10). + redo, redo_row = wait_print(client, paid_order(client, loose_item(upload_bytes(client, artwork(), name='LOCAL-REDO.png')))['id'], 'ready') + finals = [{'item_index': 0, 'upload_id': str(redo_row['upload_id'])}] + v = client.call('/operator/orders/' + redo['id'] + '/final-files', + {'version': redo['version'], 'files': finals, 'note': 'ok'}, operator=True)['version'] + def version_of(oid): + with db.connect() as c: + return c.execute('SELECT version FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()['version'] + client.call('/operator/orders/' + redo['id'] + '/move', {'state': 'cor', 'version': v, 'reason': 'Teste'}, operator=True) + client.call('/operator/orders/' + redo['id'] + '/move', {'state': 'rec', 'version': version_of(redo['id']), + 'reason': 'Teste'}, operator=True) + client.call('/operator/orders/' + redo['id'] + '/final-files', + {'version': version_of(redo['id']), 'files': finals, 'note': 'de novo'}, operator=True) + with db.connect() as c: + rows = c.execute('''SELECT active FROM dtf_local.order_files WHERE order_id=%s AND kind='final' ''', + (redo['id'],)).fetchall() + assert [r['active'] for r in rows] == [True], rows + print('PASS: a generated final that stopped counting is approved again') + # Item 10: printing, the file goes once into its machine's hot folder for # its class; Flexi taking it is reported; leaving Imprimindo withdraws # what Flexi did not take. diff --git a/web/kanban-users.js b/web/kanban-users.js index 921de43..171b9c6 100644 --- a/web/kanban-users.js +++ b/web/kanban-users.js @@ -659,6 +659,12 @@ async function pullTo(order, machineId){ } } const machine=(board.machines||[]).find(row=>row.id===target); + // A lane drop, or a machine chosen before, may be one that does not print + // this product (by its first item, as app/machines.py product_family): said + // here, as the chooser filters, and the card stays put (Sentry DTF-WEB-12). + if(machine&&!(machine.products||[]).includes(/^uv/.test(order.snapshot.items[0]?.mode||'')?'uv':'textil')){ + say('A '+machine.name+' não imprime este produto.');return; + } const alert=(machine?.alerts||[]).find(row=>row.blocking); if(alert&&!await machineAlertDialog(order,target,alert))return; try{