feat: two cards at most in Imprimindo per machine, one printing and one ripping (Dropstar's third round, item 11)
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 4m14s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m5s
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 4m14s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m5s
A third pull onto the same machine is refused with "máquina5 já tem 2 em Imprimindo", and so is changing a printing order to a full machine. On the board, the first order to enter Imprimindo on its machine is labelled Imprimindo and the next Ripando; the column shows each machine's count, as "máquina5 · 2/2". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -140,7 +140,7 @@ def board(request: Request, user=Depends(operator)):
|
||||
'mail': mail.status(c)},
|
||||
'environment': ENVIRONMENT, 'site_origin': PUBLIC_ORIGIN,
|
||||
'finished_shown': len(finished), 'finished_total': finished_total,
|
||||
'machines': machines.rows(c),
|
||||
'machines': machines.rows(c), 'printing_cap': machines.PRINTING_CAP,
|
||||
'quotes': quotes, 'thumbnails': thumbnails(c, orders, quotes),
|
||||
'names': company_names(c, orders, quotes),
|
||||
'pending_total': pending_total, 'approved_total': approved_total}
|
||||
@@ -189,12 +189,15 @@ TREATED = """f.kind='final'
|
||||
|
||||
def assign_machines(c, orders):
|
||||
"""Each order's machine as stored (app/machines.py gives it): chosen by
|
||||
someone, or automatic. None while no machine prints its product."""
|
||||
someone, or automatic. None while no machine prints its product. In
|
||||
Imprimindo, also which of its machine's two places it holds."""
|
||||
names = {str(m['id']): m['name'] for m in c.execute('SELECT id,name FROM dtf_local.machines').fetchall()}
|
||||
slots = machines.printing_slots(c)
|
||||
for order in orders:
|
||||
key = str(order.get('machine_id') or '')
|
||||
order['machine'] = ({'id': key, 'name': names[key], 'chosen': bool(order.get('machine_chosen'))}
|
||||
if key in names else None)
|
||||
order['printing'] = slots.get(order['id'])
|
||||
return orders
|
||||
|
||||
|
||||
@@ -634,11 +637,16 @@ def choose_machine(uid: UUID, body: MachineChoice, user=Depends(can('print'))):
|
||||
with db.connect() as c:
|
||||
if body.machine_id and not c.execute('SELECT 1 FROM dtf_local.machines WHERE id=%s', (body.machine_id,)).fetchone():
|
||||
raise HTTPException(404, 'Máquina não encontrada.')
|
||||
row = c.execute('UPDATE dtf_local.orders SET machine_id=%s, machine_chosen=%s WHERE id=%s RETURNING number',
|
||||
(body.machine_id, body.machine_id is not None, uid)).fetchone()
|
||||
row = c.execute('''UPDATE dtf_local.orders SET machine_id=%s, machine_chosen=%s WHERE id=%s
|
||||
RETURNING number, state, cancelled_at''', (body.machine_id, body.machine_id is not None, uid)).fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, 'Pedido não encontrado.')
|
||||
machines.route(c)
|
||||
# Printing already: the machine it goes to must have a place in Imprimindo.
|
||||
if row['state'] == 'imp' and not row['cancelled_at']:
|
||||
now = c.execute('SELECT machine_id FROM dtf_local.orders WHERE id=%s', (uid,)).fetchone()
|
||||
if name := machines.full(c, now['machine_id'], uid):
|
||||
raise HTTPException(409, f'{name} já tem {machines.PRINTING_CAP} em Imprimindo.')
|
||||
audit('order_machine_chosen', order=row['number'], machine=str(body.machine_id or ''), operator=user)
|
||||
return {'ok': True}
|
||||
|
||||
@@ -755,6 +763,9 @@ def move(uid: UUID, body: Move, request: Request, user=Depends(operator)):
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id WHERE f.order_id=%s AND {FINAL_OK}''', (uid,)).fetchall()
|
||||
if {r['item_index'] for r in coverage} != set(range(len(row['snapshot']['items']))):
|
||||
raise HTTPException(409, 'Aprove os arquivos finais de todos os itens antes de mandar para Arte conferida.')
|
||||
# Two at most per machine in Imprimindo (app/machines.py).
|
||||
if body.state == 'imp' and (name := machines.full(c, row['machine_id'], uid)):
|
||||
raise HTTPException(409, f'{name} já tem {machines.PRINTING_CAP} em Imprimindo.')
|
||||
if body.state == 'fin' and proof.needs_proof(row['snapshot']) and not row['proof_ok_at']:
|
||||
raise HTTPException(409, 'Falta a prova: confira a prova impressa e marque Prova OK antes de finalizar.')
|
||||
if body.state == 'cor':
|
||||
|
||||
Reference in New Issue
Block a user