fix: show the real freight status on the Kanban
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 2m16s
Build and deploy / Secret scan and release gate (push) Successful in 18s
Build and deploy / Publish images (push) Failing after 1m25s

The Integrations tab always said freight was not configured. It now reads
the server's adapter and, with Jadlog on, shows the package weight rule and
the production days the Site prices with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-09-29 10:57:34 -03:00
parent 2215da8d5e
commit 6f5d183365
2 changed files with 16 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ from ..printjobs import queue as queue_print_files
from .. import quote_review
from .. import tiny
from ..runtime import (BACK, BOARD_FINISHED_LIMIT, BOARD_QUOTE_LIMIT, ENVIRONMENT, STATES, TRANSITIONS, payment,
enqueue, quote_view, storage)
enqueue, freight, quote_view, storage)
from ..scanning import require_clean
router = APIRouter()
@@ -59,6 +59,14 @@ def operator_logout(request: Request, response: Response):
audit('operator_logout')
return {'ok': True}
def freight_status():
"""What delivery the Site offers, and the package rule it prices with."""
if freight.name != 'jadlog':
return {'provider': freight.name}
return {'provider': 'jadlog', 'base_kg': str(freight.base_kg), 'per_metre_kg': str(freight.per_metre_kg),
'production_days': freight.production_days}
@router.get('/api/operator/board')
def board(user=Depends(operator)):
with db.connect() as c:
@@ -91,7 +99,7 @@ def board(user=Depends(operator)):
WHERE (outcome LIKE 'refused%' OR outcome LIKE 'attention%') AND resolved_at IS NULL''').fetchone()['n']
return {'states': STATES, 'transitions': TRANSITIONS, 'back': BACK,
'orders': orders, 'payment_issues_total': issues_total, 'tiny': tiny_status(), 'operator': user,
'providers': {'payment': payment.name}, 'environment': ENVIRONMENT,
'providers': {'payment': payment.name, 'freight': freight_status()}, 'environment': ENVIRONMENT,
'finished_shown': len(finished), 'finished_total': finished_total,
'quotes': [quote_view(c, q) for q in pending + approved],
'pending_total': pending_total, 'approved_total': approved_total}