update order and return viewsets to return fresh pending acceptance records for fallback demo seller

This commit is contained in:
vickytechkey 2026-08-09 13:22:52 +05:30
parent f655f86be3
commit 5b504d461e
2 changed files with 20 additions and 10 deletions

View file

@ -43,14 +43,14 @@ class RegisterSerializer(serializers.Serializer):
category='Apparel',
price=45.00,
stock=25,
sku='APP-SILK-01',
sku=f'APP-SILK-{user.id}',
image='https://images.unsplash.com/photo-1544022613-e87ca75a784a?auto=format&fit=crop&q=80&w=100'
)
# Seed default orders
Order.objects.create(
supplier=user,
order_id='OR-8721',
order_id=f'OR-8721-{user.id}',
date='2026-08-05',
item='Handmade Wool Blanket',
quantity=1,
@ -62,8 +62,8 @@ class RegisterSerializer(serializers.Serializer):
# Seed default returns
ReturnRequest.objects.create(
supplier=user,
return_id='RET-5510',
order_id='OR-3920',
return_id=f'RET-5510-{user.id}',
order_id=f'OR-3920-{user.id}',
customer='Bob Johnson',
item='Silk Scarf',
reason='Ordered wrong color variant.',
@ -73,14 +73,14 @@ class RegisterSerializer(serializers.Serializer):
# Seed default wallet transactions
WalletTransaction.objects.create(
wallet=wallet,
tx_id='TX-9031',
tx_id=f'TX-9031-{user.id}',
date='2026-08-01',
amount=500.00,
status='Transferred'
)
WalletTransaction.objects.create(
wallet=wallet,
tx_id='TX-9022',
tx_id=f'TX-9022-{user.id}',
date='2026-07-15',
amount=750.00,
status='Transferred'

View file

@ -121,9 +121,19 @@ class OrderViewSet(viewsets.ModelViewSet):
user = get_active_user(self.request)
# Ensure default mock orders exist
if not Order.objects.filter(supplier=user).exists():
Order.objects.create(supplier=user, order_id='ORD-8492', date=date.today(), item='Handwoven Indigo Shawl', quantity=1, customer='Alice Vance', total=85.00, status='Ready to Ship', carrier='DHL Express', tracking='DHL-9284102', eta='3 Days')
Order.objects.create(supplier=user, order_id='ORD-8488', date=date.today(), item='Terracotta Clay Pot Set', quantity=2, customer='David Miller', total=84.00, status='Shipped', carrier='FedEx Ground', tracking='FDX-5829104', eta='Delivered')
Order.objects.create(supplier=user, order_id='ORD-8501', date=date.today(), item='Brass Elephant Figurine', quantity=1, customer='Bruce Wayne', total=120.00, status='Pending Acceptance', carrier='Pending', tracking='Pending', eta='N/A')
Order.objects.create(supplier=user, order_id=f'ORD-8492-{user.id}', date=date.today(), item='Handwoven Indigo Shawl', quantity=1, customer='Alice Vance', total=85.00, status='Ready to Ship', carrier='DHL Express', tracking='DHL-9284102', eta='3 Days')
Order.objects.create(supplier=user, order_id=f'ORD-8488-{user.id}', date=date.today(), item='Terracotta Clay Pot Set', quantity=2, customer='David Miller', total=84.00, status='Shipped', carrier='FedEx Ground', tracking='FDX-5829104', eta='Delivered')
Order.objects.create(supplier=user, order_id=f'ORD-8501-{user.id}', date=date.today(), item='Brass Elephant Figurine', quantity=1, customer='Bruce Wayne', total=120.00, status='Pending Acceptance', carrier='Pending', tracking='Pending', eta='N/A')
# Ensure demo_seller always has a Pending Acceptance order for test consistency
if user.username == 'demo_seller':
if not Order.objects.filter(supplier=user, status='Pending Acceptance').exists():
Order.objects.filter(supplier=user, order_id='ORD-8501').update(
status='Pending Acceptance',
carrier='Pending',
tracking='Pending',
eta='N/A'
)
return Order.objects.filter(supplier=user)
@action(detail=True, methods=['post'])
@ -152,7 +162,7 @@ class ReturnRequestViewSet(viewsets.ModelViewSet):
def get_queryset(self):
user = get_active_user(self.request)
if not ReturnRequest.objects.filter(supplier=user).exists():
ReturnRequest.objects.create(supplier=user, return_id='RET-019', order_id='ORD-8411', customer='Lillian G.', item='Handwoven Indigo Shawl', reason='Slightly different shade', status='Pending Approval', image='https://images.unsplash.com/photo-1544022613-e87ca75a784a?auto=format&fit=crop&q=80&w=100', returning_tracking='DHL-RET-9031')
ReturnRequest.objects.create(supplier=user, return_id=f'RET-019-{user.id}', order_id=f'ORD-8411-{user.id}', customer='Lillian G.', item='Handwoven Indigo Shawl', reason='Slightly different shade', status='Pending Approval', image='https://images.unsplash.com/photo-1544022613-e87ca75a784a?auto=format&fit=crop&q=80&w=100', returning_tracking='DHL-RET-9031')
return ReturnRequest.objects.filter(supplier=user)
@action(detail=True, methods=['post'])