Allow zero canister or box count, but not both
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
10
slips/api.py
10
slips/api.py
@@ -114,10 +114,12 @@ def update_order(request, order_id: int, payload: OrderUpdateIn):
|
||||
if payload.canister_count is not None or payload.box_count is not None:
|
||||
if order.status != 'pending':
|
||||
return 400, {'detail': 'Only pending orders can change label counts'}
|
||||
if payload.canister_count is not None and payload.canister_count < 1:
|
||||
return 400, {'detail': 'canister_count must be >= 1'}
|
||||
if payload.box_count is not None and payload.box_count < 1:
|
||||
return 400, {'detail': 'box_count must be >= 1'}
|
||||
cc = payload.canister_count if payload.canister_count is not None else order.canister_count
|
||||
bc = payload.box_count if payload.box_count is not None else order.box_count
|
||||
if cc < 0 or bc < 0:
|
||||
return 400, {'detail': 'counts must be >= 0'}
|
||||
if cc == 0 and bc == 0:
|
||||
return 400, {'detail': 'canister_count and box_count cannot both be 0'}
|
||||
order.set_counts(payload.canister_count, payload.box_count)
|
||||
|
||||
if payload.status is not None:
|
||||
|
||||
Reference in New Issue
Block a user