feat: the proof card, machine pull and print file corrections (Dropstar, 05/11)

The proof card owns its final PNG, keeps its parent locked until the seller
answers, enters the queue first, and shares one machine with the parent.
The board no longer assigns a machine at payment; the puller records it.
A stalled print file times out with a card warning and a retry, finished
orders sort by completion, and finals are stored as PNG. The original
download carries the order number (items 0.1, 0.4 to 0.7 and 0.9).
This commit is contained in:
Cauê Faleiros
2026-11-06 10:41:20 -03:00
parent 0fc01315c7
commit d69e326125
20 changed files with 584 additions and 220 deletions

View File

@@ -36,15 +36,15 @@ CUSTOMER = {'cnpj': '11222333000181', 'zap': '11999999999', 'mail': 'print-test@
def artwork(kind='PNG'):
image = Image.new('RGBA', (600, 300), (0, 0, 0, 0))
for x in range(40, 560):
for y in range(40, 260):
image = Image.new('RGBA', (1600, 800), (0, 0, 0, 0))
for x in range(40, 1560):
for y in range(40, 760):
image.putpixel((x, y), (220, 30, 60, 255))
out = io.BytesIO()
if kind == 'PDF':
image.convert('RGB').save(out, 'PDF', resolution=72)
else:
image.save(out, kind)
image.save(out, kind, dpi=(300, 300))
return out.getvalue()
@@ -93,7 +93,7 @@ def run():
uid = upload_bytes(client, artwork(), name='LOCAL-PRINT-TEST.png')
order = paid_order(client, loose_item(uid))
order, row = wait_print(client, order['id'], 'ready')
assert row['detail']['placements'] == 2 and row['detail']['min_dpi'] == round(600 / (20 / 2.54))
assert row['detail']['placements'] == 2 and row['detail']['min_dpi'] == round(1600 / (20 / 2.54))
# A 300 DPI PNG on a transparent background (item 13): the layout's 10 cm
# and the 1,5 cm footer band, outside the billed length.
film = download_png(client, row['upload_id'])
@@ -142,7 +142,10 @@ def run():
version += 1
# Printing, the folders still get the file of an order they hold (to take
# it to Finalizado later), and no one else's.
client.call('/operator/orders/' + oid + '/move', {'state': 'imp', 'version': version}, operator=True)
machine = client.call('/operator/machines', {'name': 'Print test '+uuid4().hex[:6],
'products': ['textil']}, operator=True)['id']
client.call('/operator/orders/' + oid + '/move', {'state': 'imp', 'version': version,
'machine_id': machine}, operator=True)
version += 1
held = client.call('/operator/queue/folder', {'early': True, 'held': [oid]}, operator=True)
assert [(f['state'], f['upload_id']) for f in held['files'] if f['order'] == oid] == [('imp', str(row['upload_id']))], held
@@ -223,15 +226,17 @@ def run():
with db.connect() as c:
assert not c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key LIKE %s', (card['id'] + '%',)).fetchone()
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (card['id'],))
final = upload_bytes(client, b'LOCAL PROOF FINAL FIXTURE', order_id=parent['id'])
version = client.call('/operator/orders/' + parent['id'] + '/final-files',
{'version': parent['version'], 'files': [{'item_index': 0, 'upload_id': final}],
'note': 'Local proof test final'}, operator=True)['version']
version = client.call('/operator/orders/' + parent['id'] + '/move', {'state': 'tra', 'version': version},
operator=True)['version']
held = client.call('/operator/orders/' + parent['id'] + '/move', {'state': 'imp', 'version': version},
operator=True, expected=409)
final = str(uuid4())
held = client.call('/operator/orders/' + parent['id'] + '/final-files',
{'version': parent['version'], 'files': [{'item_index': 0, 'upload_id': final}],
'note': 'Local proof test final'}, operator=True, expected=409)
assert 'Aguardando prova' in held['detail'], held
for path, body in [('/move', {'state': 'tra', 'version': parent['version']}),
('/contraction', {'item_index': 0, 'value': 'C1'}),
('/machine', {'machine_id': None}),
('/queue', {'after': card['id']})]:
held = client.call('/operator/orders/' + parent['id'] + path, body, operator=True, expected=409)
assert 'Aguardando prova' in held['detail'], (path, held)
client.call('/operator/orders/' + card['id'] + '/move', {'state': 'fin', 'version': card['version']},
operator=True, expected=409)
# Reprovada needs its reason; the order goes back to Arte recebida.
@@ -245,6 +250,11 @@ def run():
assert mine['state'] == 'rec' and mine['proof_card']['proof_result'] == 'rejected', mine['proof_card']
assert mine['proof_card']['proof_reason'] == 'Cor do fundo errada'
assert not [o for o in board if o['id'] == card['id']], 'an answered proof card leaves the board'
# Rejection releases the parent for corrected artwork, until a new proof card is opened.
final = upload_bytes(client, artwork(), name='LOCAL-PROOF-FINAL.png', order_id=parent['id'])
version = client.call('/operator/orders/' + parent['id'] + '/final-files',
{'version': mine['version'], 'files': [{'item_index': 0, 'upload_id': final}],
'note': 'Local proof test final'}, operator=True)['version']
# A new card, and Prova OK lets the order into the queue.
again = client.call('/operator/orders/' + parent['id'] + '/proof-card', {}, operator=True)
client.call('/operator/orders/' + parent['id'] + '/proof-card', {}, operator=True, expected=409)
@@ -252,7 +262,7 @@ def run():
c.execute("UPDATE dtf_local.orders SET state='rev' WHERE id=%s", (again['id'],))
client.call('/operator/orders/' + again['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 mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok', mine
assert mine['proof_ok_at'] and mine['proof_card']['proof_result'] == 'ok' and mine['state'] == 'tra', mine
print('PASS: an order with a proof waits for its proof card, which is answered OK or rejected in Revisão')
# A customer cannot see or reuse another order's generated file.
@@ -313,7 +323,7 @@ def run():
finished = client.call('/operator/orders/finished?limit=1', operator=True)
if finished['orders']:
last = finished['orders'][-1]
client.call('/operator/orders/finished?before_created_at=' + last['created_at'].replace('+', '%2B')
client.call('/operator/orders/finished?before_finished_at=' + last['finished_at'].replace('+', '%2B')
+ '&before_id=' + last['id'], operator=True)
print('PASS: send log, payment history and finished orders page and filter')