@@ -13,11 +13,21 @@ class Command(BaseCommand):
1313 def handle (self , * args , ** options ):
1414 # populate the database with venues
1515 venues = [
16- Venue .objects .get_or_create (name = "The O2 Arena" , address = "Peninsula Square, London SE10 0DX, United Kingdom" , capacity = 20000 ),
17- Venue .objects .get_or_create (name = "Arena of Nîmes" , address = "Boulevard des Arènes, 30000 Nîmes, France" , capacity = 17000 ),
18- Venue .objects .get_or_create (name = "Red Rocks Amphitheatre" , address = "18300 W Alameda, Morrison, CO, United States" , capacity = 9525 ),
19- Venue .objects .get_or_create (name = "Dalhalla Amphitheatre" , address = "Dalhalla, 790 90 Rättvik, Sweden" , capacity = 4000 ),
20- Venue .objects .get_or_create (name = "The Fillmore" , address = "1805 Geary Blvd, San Francisco, CA, United States" , capacity = 1250 ),
16+ Venue .objects .get_or_create (
17+ name = "The O2 Arena" , address = "Peninsula Square, London SE10 0DX, United Kingdom" , capacity = 960 ,
18+ ),
19+ Venue .objects .get_or_create (
20+ name = "Arena of Nîmes" , address = "Boulevard des Arènes, 30000 Nîmes, France" , capacity = 720 ,
21+ ),
22+ Venue .objects .get_or_create (
23+ name = "Red Rocks Amphitheatre" , address = "18300 W Alameda, Morrison, CO, United States" , capacity = 640 ,
24+ ),
25+ Venue .objects .get_or_create (
26+ name = "Dalhalla Amphitheatre" , address = "Dalhalla, 790 90 Rättvik, Sweden" , capacity = 800 ,
27+ ),
28+ Venue .objects .get_or_create (
29+ name = "The Fillmore" , address = "1805 Geary Blvd, San Francisco, CA, United States" , capacity = 620 ,
30+ ),
2131 ]
2232
2333 # populate the database with categories
@@ -26,7 +36,7 @@ def handle(self, *args, **options):
2636 ConcertCategory .objects .get_or_create (name = category )
2737
2838 # populate the database with concerts
29- concert_prefix = ["Underground" , "Midnight" , "Late Night" , "Secret" , "" , "" , "" , "" , "" , "" , "" , "" , "" , "" ]
39+ concert_prefix = ["Underground" , "Midnight" , "Late Night" , "Secret" , "" * 10 ]
3040 concert_suffix = ["Party" , "Rave" , "Concert" , "Gig" , "Revolution" , "Jam" , "Tour" ]
3141 for i in range (10 ):
3242 venue = random .choice (venues )[0 ]
@@ -35,23 +45,26 @@ def handle(self, *args, **options):
3545 name = f"{ random .choice (concert_prefix )} { category .name } { random .choice (concert_suffix )} " ,
3646 description = "" ,
3747 venue = venue ,
38- starts_at = datetime .now (pytz .utc ) + timedelta (days = random .randint (1 , 365 )),
39- price = random .randint (10 , 100 )
48+ starts_at = datetime .now (pytz .utc )
49+ + timedelta (days = random .randint (1 , 365 )),
50+ price = random .randint (10 , 100 ),
4051 )
4152 concert .categories .add (category )
4253 concert .save ()
4354
4455 # populate the database with ticket purchases
4556 names = ["James" , "John" , "Robert" , "Michael" , "William" , "David" , "Richard" , "Joseph" , "Thomas" , "Charles" ]
4657 surname = ["Smith" , "Jones" , "Taylor" , "Brown" , "Williams" , "Wilson" , "Johnson" , "Davies" , "Patel" , "Wright" ]
47- for i in range (200 ):
58+ for i in range (500 ):
4859 concert = Concert .objects .order_by ("?" ).first ()
4960 Ticket .objects .create (
5061 concert = concert ,
5162 customer_full_name = f"{ random .choice (names )} { random .choice (surname )} " ,
52- payment_method = random .choice (["CC" , "DC" , "ET" , "BC" ]),
63+ payment_method = random .choice (["CC" , "CC" , "CC" , "CC" , "DC" , " DC" , "ET" , "BC" ]),
5364 paid_at = datetime .now (pytz .utc ) - timedelta (days = random .randint (1 , 365 )),
54- is_active = random .choice ([True , False ])
65+ is_active = random .choice ([True , False ]),
5566 )
67+ concert .tickets_left -= 1
68+ concert .save ()
5669
57- self .stdout .write (self .style .SUCCESS ("Successfully populated the database." ))
70+ self .stdout .write (self .style .SUCCESS ("Successfully populated the database." ))
0 commit comments