feat: implement cart, checkout, payment, and order history API views
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 24s

This commit is contained in:
vickytechkey 2026-10-09 19:01:52 +05:30
parent 959157de60
commit 1bc152481f

View file

@ -856,13 +856,16 @@ class OrderTrackView(APIView):
tracking_history.append({'status': 'delivered', 'timestamp': placed_ts, 'location': 'Customer Address'})
display_status = 'Delivered'
rider_details = {'name': 'Rajesh Kumar', 'phone': '+919876543210'}
elif raw_status in ['cancelled', 'canceled']:
tracking_history.append({'status': 'cancelled', 'timestamp': placed_ts, 'location': 'Order Cancelled'})
display_status = 'Cancelled'
else:
display_status = 'Pending Acceptance'
live_data = {
'status': 'success',
'data': {
'awb_number': awb_number or 'Pending Dispatch',
'awb_number': awb_number or 'Cancelled',
'current_status': display_status,
'carrier': 'Shadowfax Express' if awb_number else 'Awaiting Dispatch',
'rider_details': rider_details,
@ -870,6 +873,15 @@ class OrderTrackView(APIView):
}
}
# Override current_status if raw_status is cancelled
if raw_status in ['cancelled', 'canceled'] and live_data and 'data' in live_data:
live_data['data']['current_status'] = 'Cancelled'
if not any(h.get('status') == 'cancelled' for h in live_data['data'].get('tracking_history', [])):
live_data['data']['tracking_history'] = [
{'status': 'new', 'timestamp': order.placed_at.strftime('%Y-%m-%dT%H:%M:%SZ') if (order and getattr(order, 'placed_at', None)) else '2026-10-09T10:00:00Z', 'location': 'Customer Store'},
{'status': 'cancelled', 'timestamp': order.placed_at.strftime('%Y-%m-%dT%H:%M:%SZ') if (order and getattr(order, 'placed_at', None)) else '2026-10-09T10:00:00Z', 'location': 'Order Cancelled'}
]
result = {
'order_id': order.id if order else order_id,
'awb_number': awb_number or (order.awb_number if order else None),