feat: stroke class, residue per artwork, mixed strokes, sheets split by class
All checks were successful
Build and deploy / Validate source (push) Successful in 1m25s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 12s
Build and deploy / Publish images (push) Successful in 1m38s

Round 3, items 9, 4, 16 and 17 (Dropstar, 2026-10-30).

- 9: the Site measures the thinnest stroke of each sheet and loose artwork
  (alpha > 40, chamfer distance in strips, width at local maxima, 1st
  percentile, at 300 DPI) and sends stroke_px and C1/C2/C3 with the item.
  The Kanban shows the class prefilled in the approve step; Produção may
  change it (POST /orders/{id}/contraction, who and when recorded), and the
  manifest carries it.
- 4: the residue check runs on each loose artwork, accepted per artwork; the
  sheet inherits what was accepted.
- 16: fine lines and solid areas in one file. Loose art: a pop-up with
  [Subir separado] [Continuar assim]. Ready sheet: protect the fine lines
  (default), protect the solid areas (stroke_choice client_c3, starts at C3)
  or go back and send two sheets, which holds the order.
- 17: loose art of fine (C1, C2) and solid (C3) strokes goes on separate
  sheets, each its own order item (split group/part/of) with its own file
  and class. Each sheet rounds to 10 cm and the 1 m minimum is charged once
  per group, since the customer did not choose the split. Cart, payment
  summary, portal, receipt and mail show it as such.
- The board loads quote views in two queries instead of two per quote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-03 10:24:29 -03:00
parent 388408d4d6
commit 2615163fd3
23 changed files with 547 additions and 57 deletions

View File

@@ -11,16 +11,17 @@ from uuid import UUID
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
from fastapi.responses import RedirectResponse
from pydantic import Field
from psycopg.types.json import Jsonb
from ..core import db
from ..core.auth import (COOKIE_SECURE, DUMMY_PASSWORD_HASH, MOVERS, audit, can, client_ip, operator,
login_failed, may_move, may_reorder, password_matches, throttle)
from ..core.models import Move, OperatorLogin, Resolution, Review, StrictModel, UploadStart
from ..core.models import Contraction, Move, OperatorLogin, Resolution, Review, StrictModel, UploadStart
from ..printjobs import file_prefix, queue as queue_print_files
from .. import cnpj, machines, mail, payments, proof, quote_review, receipt
from .. import tiny
from ..runtime import (BACK, BOARD_FINISHED_LIMIT, BOARD_QUOTE_LIMIT, ENVIRONMENT, PUBLIC_ORIGIN, STATES,
TRANSITIONS, payment, enqueue, freight, operator_identity, quote_view, storage, upload_row)
TRANSITIONS, payment, enqueue, freight, operator_identity, quote_view, quote_views, storage, upload_row)
from .uploads import begin_upload
from ..scanning import require_clean
@@ -134,7 +135,7 @@ def board(user=Depends(operator)):
issues_total = c.execute('''SELECT count(*) AS n FROM dtf_local.payment_events
WHERE (outcome LIKE 'refused%' OR outcome LIKE 'attention%') AND resolved_at IS NULL''').fetchone()['n']
backup = backup_status(c)
quotes = [quote_view(c, q) for q in pending + approved]
quotes = quote_views(c, pending + approved)
return {'states': STATES, 'transitions': TRANSITIONS, 'back': BACK,
'orders': orders, 'payment_issues_total': issues_total, 'tiny': tiny_status(), 'operator': user,
'providers': {'payment': payment.name, 'freight': freight_status(), 'backup': backup,
@@ -403,7 +404,7 @@ def quote_page(kind: Literal['pending','approved'], before_created_at: datetime
total = c.execute(f'''SELECT count(*) AS n FROM dtf_local.quotes q
LEFT JOIN dtf_local.orders o ON o.quote_id=q.id
WHERE {where}''', params).fetchone()['n']
quotes = [quote_view(c,row) for row in rows[:limit]]
quotes = quote_views(c, rows[:limit])
return {'quotes': quotes, 'has_more': len(rows)>limit, 'total': total,
'thumbnails': thumbnails(c, quotes), 'names': company_names(c, quotes)}
@@ -433,7 +434,7 @@ def search(q: str = Query(min_length=2, max_length=100), user=Depends(operator))
WHERE o.id IS NULL AND {LIVE_QUOTE} AND {quote_match}
ORDER BY q.created_at DESC LIMIT 8''', quote_params).fetchall()
orders = with_print_files(c, orders)
quotes = [quote_view(c, row) for row in rows]
quotes = quote_views(c, rows)
return {'orders': orders, 'quotes': quotes, 'thumbnails': thumbnails(c, orders, quotes),
'names': company_names(c, orders, quotes)}
@@ -674,6 +675,31 @@ def choose_machine(uid: UUID, body: MachineChoice, request: Request, user=Depend
return {'ok': True}
@router.post('/api/operator/orders/{uid}/contraction')
def choose_contraction(uid: UUID, body: Contraction, user=Depends(can('produce'))):
"""The contraction class of an item (Dropstar, 2026-10-30): the browser's
measure comes prefilled, and whoever prepares the art may change it until
the order prints. Both stay: the measure in the snapshot, the choice here."""
with db.connect() as c:
row = c.execute('SELECT snapshot,state,cancelled_at,contraction FROM dtf_local.orders WHERE id=%s FOR UPDATE',
(uid,)).fetchone()
if not row:
raise HTTPException(404, 'Pedido não encontrado.')
if row['cancelled_at'] or row['state'] not in ('rec', 'tra', 'cor'):
raise HTTPException(409, 'A contração muda até o pedido ir para Imprimindo.')
if body.item_index >= len(row['snapshot']['items']):
raise HTTPException(422, 'Item não encontrado no pedido.')
chosen = dict(row['contraction'] or {})
key = str(body.item_index)
if body.value is None:
chosen.pop(key, None)
else:
chosen[key] = {'class': body.value, 'by': user, 'at': datetime.now(timezone.utc).isoformat()}
c.execute('UPDATE dtf_local.orders SET contraction=%s WHERE id=%s', (Jsonb(chosen), uid))
audit('order_contraction_chosen', order=str(uid), item=body.item_index, value=body.value or '', operator=user)
return {'ok': True, 'contraction': chosen}
class ContactWait(StrictModel):
waiting: bool
note: str = Field(default='', max_length=500)