208 lines
6.2 KiB
Python
208 lines
6.2 KiB
Python
|
|
import os
|
||
|
|
import django
|
||
|
|
import random
|
||
|
|
from datetime import date, timedelta
|
||
|
|
|
||
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||
|
|
django.setup()
|
||
|
|
|
||
|
|
from django.contrib.auth.models import User
|
||
|
|
from api.models import SupplierProfile, Product, Order, ReturnRequest, Wallet, WalletTransaction
|
||
|
|
|
||
|
|
def seed():
|
||
|
|
print("Clearing existing database tables...")
|
||
|
|
Product.objects.all().delete()
|
||
|
|
Order.objects.all().delete()
|
||
|
|
ReturnRequest.objects.all().delete()
|
||
|
|
WalletTransaction.objects.all().delete()
|
||
|
|
Wallet.objects.all().delete()
|
||
|
|
SupplierProfile.objects.all().delete()
|
||
|
|
User.objects.filter(username='demo_seller').delete()
|
||
|
|
|
||
|
|
print("Creating demo seller user...")
|
||
|
|
user = User.objects.create_user(
|
||
|
|
username='demo_seller',
|
||
|
|
email='demo@example.com',
|
||
|
|
password='super_secure_pass_123'
|
||
|
|
)
|
||
|
|
user.save()
|
||
|
|
|
||
|
|
print("Creating supplier profile...")
|
||
|
|
profile = SupplierProfile.objects.create(
|
||
|
|
user=user,
|
||
|
|
phone='9876543210',
|
||
|
|
phone_verified=True,
|
||
|
|
email_verified=True,
|
||
|
|
gstin='29AAAAA1111A1Z1',
|
||
|
|
is_gstin_verified=True,
|
||
|
|
aadhar_file='aadhar_card.pdf',
|
||
|
|
pan_file='pan_card.pdf',
|
||
|
|
store_name='Teak Wood Craft Store',
|
||
|
|
business_bio='Premium teak wood hand carved decor and traditional textiles.',
|
||
|
|
street='123 Handloom Lane',
|
||
|
|
city='Textile Town',
|
||
|
|
state='Karnataka',
|
||
|
|
pincode='560001',
|
||
|
|
latitude=12.9716,
|
||
|
|
longitude=77.5946,
|
||
|
|
is_profile_complete=True
|
||
|
|
)
|
||
|
|
profile.save()
|
||
|
|
|
||
|
|
print("Creating initial product listings...")
|
||
|
|
products = [
|
||
|
|
{
|
||
|
|
'title': 'Handwoven Indigo Shawl',
|
||
|
|
'category': 'Apparel',
|
||
|
|
'price': 85.00,
|
||
|
|
'stock': 45,
|
||
|
|
'sku': 'SHAWL-IND-01',
|
||
|
|
'image': 'https://images.unsplash.com/photo-1544022613-e87ca75a784a?auto=format&fit=crop&q=80&w=100'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
'title': 'Terracotta Clay Pot Set',
|
||
|
|
'category': 'Home Decor',
|
||
|
|
'price': 42.00,
|
||
|
|
'stock': 24,
|
||
|
|
'sku': 'POT-TER-02',
|
||
|
|
'image': 'https://images.unsplash.com/photo-1612196808214-b8e1d6145a8c?auto=format&fit=crop&q=80&w=100'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
'title': 'Brass Elephant Figurine',
|
||
|
|
'category': 'Sculptures',
|
||
|
|
'price': 120.00,
|
||
|
|
'stock': 12,
|
||
|
|
'sku': 'FIG-ELE-03',
|
||
|
|
'image': 'https://images.unsplash.com/photo-1590736969955-71cc94801759?auto=format&fit=crop&q=80&w=100'
|
||
|
|
}
|
||
|
|
]
|
||
|
|
|
||
|
|
for p in products:
|
||
|
|
Product.objects.create(
|
||
|
|
supplier=user,
|
||
|
|
title=p['title'],
|
||
|
|
category=p['category'],
|
||
|
|
price=p['price'],
|
||
|
|
stock=p['stock'],
|
||
|
|
sku=p['sku'],
|
||
|
|
image=p['image']
|
||
|
|
)
|
||
|
|
|
||
|
|
print("Creating initial orders...")
|
||
|
|
orders = [
|
||
|
|
{
|
||
|
|
'order_id': 'ORD-8492',
|
||
|
|
'date': date.today() - timedelta(days=2),
|
||
|
|
'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_id': 'ORD-8488',
|
||
|
|
'date': date.today() - timedelta(days=3),
|
||
|
|
'item': 'Terracotta Clay Pot Set',
|
||
|
|
'quantity': 2,
|
||
|
|
'customer': 'David Miller',
|
||
|
|
'total': 84.00,
|
||
|
|
'status': 'Shipped',
|
||
|
|
'carrier': 'FedEx Ground',
|
||
|
|
'tracking': 'FDX-5829104',
|
||
|
|
'eta': 'Delivered'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
'order_id': 'ORD-8501',
|
||
|
|
'date': date.today() - timedelta(days=1),
|
||
|
|
'item': 'Brass Elephant Figurine',
|
||
|
|
'quantity': 1,
|
||
|
|
'customer': 'Bruce Wayne',
|
||
|
|
'total': 120.00,
|
||
|
|
'status': 'Pending Acceptance',
|
||
|
|
'carrier': 'Pending',
|
||
|
|
'tracking': 'Pending',
|
||
|
|
'eta': 'N/A'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
'order_id': 'ORD-8502',
|
||
|
|
'date': date.today(),
|
||
|
|
'item': 'Handwoven Indigo Shawl',
|
||
|
|
'quantity': 2,
|
||
|
|
'customer': 'Clark Kent',
|
||
|
|
'total': 170.00,
|
||
|
|
'status': 'Pending Acceptance',
|
||
|
|
'carrier': 'Pending',
|
||
|
|
'tracking': 'Pending',
|
||
|
|
'eta': 'N/A'
|
||
|
|
}
|
||
|
|
]
|
||
|
|
|
||
|
|
for o in orders:
|
||
|
|
Order.objects.create(
|
||
|
|
supplier=user,
|
||
|
|
order_id=o['order_id'],
|
||
|
|
date=o['date'],
|
||
|
|
item=o['item'],
|
||
|
|
quantity=o['quantity'],
|
||
|
|
customer=o['customer'],
|
||
|
|
total=o['total'],
|
||
|
|
status=o['status'],
|
||
|
|
carrier=o['carrier'],
|
||
|
|
tracking=o['tracking'],
|
||
|
|
eta=o['eta']
|
||
|
|
)
|
||
|
|
|
||
|
|
print("Creating customer returns...")
|
||
|
|
ReturnRequest.objects.create(
|
||
|
|
supplier=user,
|
||
|
|
return_id='RET-019',
|
||
|
|
order_id='ORD-8411',
|
||
|
|
customer='Lillian G.',
|
||
|
|
item='Handwoven Indigo Shawl',
|
||
|
|
reason='Slightly different shade than pictured',
|
||
|
|
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='RET-018',
|
||
|
|
order_id='ORD-8390',
|
||
|
|
customer='Robert H.',
|
||
|
|
item='Terracotta Clay Pot Set',
|
||
|
|
reason='Damaged in transit',
|
||
|
|
status='In Transit',
|
||
|
|
image='https://images.unsplash.com/photo-1612196808214-b8e1d6145a8c?auto=format&fit=crop&q=80&w=100',
|
||
|
|
returning_tracking='FDX-RET-2940'
|
||
|
|
)
|
||
|
|
|
||
|
|
print("Creating wallet and payout records...")
|
||
|
|
wallet = Wallet.objects.create(
|
||
|
|
supplier=user,
|
||
|
|
outstanding=850.00,
|
||
|
|
withdrawn=1250.00
|
||
|
|
)
|
||
|
|
|
||
|
|
WalletTransaction.objects.create(
|
||
|
|
wallet=wallet,
|
||
|
|
tx_id='TX-9031',
|
||
|
|
date=date.today() - timedelta(days=8),
|
||
|
|
amount=500.00,
|
||
|
|
status='Transferred'
|
||
|
|
)
|
||
|
|
WalletTransaction.objects.create(
|
||
|
|
wallet=wallet,
|
||
|
|
tx_id='TX-9022',
|
||
|
|
date=date.today() - timedelta(days=25),
|
||
|
|
amount=750.00,
|
||
|
|
status='Transferred'
|
||
|
|
)
|
||
|
|
|
||
|
|
print("Successfully seeded all dummy/mock data!")
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
seed()
|