|
5 | 5 | import random |
6 | 6 | from companies.models import Company |
7 | 7 | from vehicles.models import Vehicle |
8 | | -from trips.models import Stop, Trip, TripStop |
| 8 | +from trips.models import Trip, TripStop |
| 9 | +from orders.models import Stop, Order |
9 | 10 | from positions.models import Position |
10 | 11 | from accounts.models import AuthToken, UserProfile |
11 | 12 |
|
@@ -226,6 +227,99 @@ def handle(self, *args, **options): |
226 | 227 |
|
227 | 228 | self.stdout.write(f'Created {len(stops)} test stops') |
228 | 229 |
|
| 230 | + # Create test orders |
| 231 | + self.stdout.write('Creating test orders...') |
| 232 | + loading_stops = [s for s in stops if s.stop_type == 'loading'] |
| 233 | + unloading_stops = [s for s in stops if s.stop_type == 'unloading'] |
| 234 | + |
| 235 | + orders_data = [ |
| 236 | + { |
| 237 | + 'customer_name': 'ACME Manufacturing', |
| 238 | + 'customer_company': 'ACME Corp', |
| 239 | + 'customer_email': 'logistics@acme.com', |
| 240 | + 'customer_phone': '+33-1-42-00-1234', |
| 241 | + 'pickup_stop': loading_stops[0], # Rungis |
| 242 | + 'delivery_stop': unloading_stops[0], # Carrefour Paris |
| 243 | + 'goods_description': 'Fresh produce and dairy products', |
| 244 | + 'goods_weight': 2500.0, |
| 245 | + 'goods_volume': 15.0, |
| 246 | + 'goods_type': 'refrigerated', |
| 247 | + 'special_instructions': 'Keep temperature at 2-4°C throughout transport' |
| 248 | + }, |
| 249 | + { |
| 250 | + 'customer_name': 'TechCorp Europe', |
| 251 | + 'customer_company': 'TechCorp Ltd', |
| 252 | + 'customer_email': 'supply@techcorp.eu', |
| 253 | + 'customer_phone': '+33-1-45-67-8900', |
| 254 | + 'pickup_stop': loading_stops[4], # Toulouse Aerospace |
| 255 | + 'delivery_stop': unloading_stops[7], # Frankfurt |
| 256 | + 'goods_description': 'Aerospace electronic components', |
| 257 | + 'goods_weight': 850.0, |
| 258 | + 'goods_volume': 5.2, |
| 259 | + 'goods_type': 'fragile', |
| 260 | + 'special_instructions': 'Handle with extreme care - sensitive electronics' |
| 261 | + }, |
| 262 | + { |
| 263 | + 'customer_name': 'EuroConstruction', |
| 264 | + 'customer_company': 'EuroConstruction SA', |
| 265 | + 'customer_email': 'orders@euroconstruct.fr', |
| 266 | + 'customer_phone': '+33-4-78-90-1234', |
| 267 | + 'pickup_stop': loading_stops[8], # Saint-Gobain Melun |
| 268 | + 'delivery_stop': unloading_stops[4], # Brussels |
| 269 | + 'goods_description': 'Construction materials and tools', |
| 270 | + 'goods_weight': 4200.0, |
| 271 | + 'goods_volume': 28.0, |
| 272 | + 'goods_type': 'standard', |
| 273 | + 'special_instructions': 'Delivery to construction site - crane available' |
| 274 | + }, |
| 275 | + { |
| 276 | + 'customer_name': 'PharmaLogistics', |
| 277 | + 'customer_company': 'PharmaDistrib', |
| 278 | + 'customer_email': 'urgent@pharmadistrib.com', |
| 279 | + 'customer_phone': '+33-1-56-78-9012', |
| 280 | + 'pickup_stop': loading_stops[9], # Sanofi |
| 281 | + 'delivery_stop': unloading_stops[8], # Milan |
| 282 | + 'goods_description': 'Pharmaceutical supplies and medications', |
| 283 | + 'goods_weight': 320.0, |
| 284 | + 'goods_volume': 2.8, |
| 285 | + 'goods_type': 'hazmat', |
| 286 | + 'special_instructions': 'Requires temperature monitoring and hazmat certification' |
| 287 | + }, |
| 288 | + { |
| 289 | + 'customer_name': 'Luxury Retail Chain', |
| 290 | + 'customer_company': 'EliteStores International', |
| 291 | + 'customer_email': 'procurement@elitestores.com', |
| 292 | + 'customer_phone': '+33-1-44-55-6677', |
| 293 | + 'pickup_stop': loading_stops[10], # LVMH Logistics |
| 294 | + 'delivery_stop': unloading_stops[10], # Zurich |
| 295 | + 'goods_description': 'Luxury fashion and accessories', |
| 296 | + 'goods_weight': 180.0, |
| 297 | + 'goods_volume': 8.5, |
| 298 | + 'goods_type': 'fragile', |
| 299 | + 'special_instructions': 'High-value goods - requires secure transport and signature on delivery' |
| 300 | + } |
| 301 | + ] |
| 302 | + |
| 303 | + orders = [] |
| 304 | + for o_data in orders_data: |
| 305 | + order = Order.objects.create( |
| 306 | + customer_name=o_data['customer_name'], |
| 307 | + customer_company=o_data['customer_company'], |
| 308 | + customer_email=o_data['customer_email'], |
| 309 | + customer_phone=o_data['customer_phone'], |
| 310 | + pickup_stop=o_data['pickup_stop'], |
| 311 | + delivery_stop=o_data['delivery_stop'], |
| 312 | + goods_description=o_data['goods_description'], |
| 313 | + goods_weight=o_data['goods_weight'], |
| 314 | + goods_volume=o_data['goods_volume'], |
| 315 | + goods_type=o_data['goods_type'], |
| 316 | + special_instructions=o_data['special_instructions'], |
| 317 | + status='pending' |
| 318 | + ) |
| 319 | + orders.append(order) |
| 320 | + |
| 321 | + self.stdout.write(f'Created {len(orders)} test orders') |
| 322 | + |
229 | 323 | # Create test trips |
230 | 324 | self.stdout.write('Creating test trips...') |
231 | 325 | today = timezone.now().date() |
@@ -398,12 +492,12 @@ def handle(self, *args, **options): |
398 | 492 | self.stdout.write(f'Auth Token: {token.key}') |
399 | 493 | self.stdout.write(f'Companies: {Company.objects.count()}') |
400 | 494 | self.stdout.write(f'Vehicles: {Vehicle.objects.count()}') |
401 | | - self.stdout.write(f'Stops: {Stop.objects.count()}') |
| 495 | + self.stdout.write(f'Orders: {Order.objects.count()}') |
402 | 496 | self.stdout.write(f'Trips: {Trip.objects.count()}') |
403 | 497 | self.stdout.write(f'Positions: {Position.objects.count()}') |
404 | 498 | self.stdout.write('\nTest data includes:') |
405 | 499 | self.stdout.write('• Dashmove company with 20 heavy trucks (18-40 tons capacity)') |
406 | | - self.stdout.write('• 62 European stops (ports, warehouses, factories) across France and neighboring countries') |
| 500 | + self.stdout.write('• 5 sample orders with customer details, pickup/delivery locations, and goods information') |
407 | 501 | self.stdout.write('• 10 sample trips with different statuses') |
408 | 502 | self.stdout.write('• 48 hours of position data for 10 vehicles across European routes') |
409 | 503 | self.stdout.write('• Realistic heavy truck logistics operations') |
|
0 commit comments