Files
thrillwiki_django_no_react/parks/management/commands/seed_initial_data.py
pacnpal 751cd86a31 Add operators and property owners functionality
- Implemented OperatorListView and OperatorDetailView for managing operators.
- Created corresponding templates for operator listing and detail views.
- Added PropertyOwnerListView and PropertyOwnerDetailView for managing property owners.
- Developed templates for property owner listing and detail views.
- Established relationships between parks and operators, and parks and property owners in the models.
- Created migrations to reflect the new relationships and fields in the database.
- Added admin interfaces for PropertyOwner management.
- Implemented tests for operators and property owners.
2025-07-04 14:49:36 -04:00

246 lines
12 KiB
Python

from django.core.management.base import BaseCommand
from django.utils import timezone
from operators.models import Operator
from parks.models import Park, ParkArea
from location.models import Location
from django.contrib.contenttypes.models import ContentType
class Command(BaseCommand):
help = 'Seeds initial park data with major theme parks worldwide'
def handle(self, *args, **options):
# Create major theme park companies
companies_data = [
{
'name': 'The Walt Disney Company',
'website': 'https://www.disney.com/',
'headquarters': 'Burbank, California',
'description': 'The world\'s largest entertainment company and theme park operator.'
},
{
'name': 'Universal Parks & Resorts',
'website': 'https://www.universalparks.com/',
'headquarters': 'Orlando, Florida',
'description': 'A division of Comcast NBCUniversal, operating major theme parks worldwide.'
},
{
'name': 'Six Flags Entertainment Corporation',
'website': 'https://www.sixflags.com/',
'headquarters': 'Arlington, Texas',
'description': 'The world\'s largest regional theme park company.'
},
{
'name': 'Cedar Fair Entertainment Company',
'website': 'https://www.cedarfair.com/',
'headquarters': 'Sandusky, Ohio',
'description': 'One of North America\'s largest operators of regional amusement parks.'
},
{
'name': 'Herschend Family Entertainment',
'website': 'https://www.hfecorp.com/',
'headquarters': 'Atlanta, Georgia',
'description': 'The largest family-owned themed attractions corporation in the United States.'
},
{
'name': 'SeaWorld Parks & Entertainment',
'website': 'https://www.seaworldentertainment.com/',
'headquarters': 'Orlando, Florida',
'description': 'Theme park and entertainment company focusing on nature-based themes.'
}
]
companies = {}
for company_data in companies_data:
operator, created = Operator.objects.get_or_create(
name=company_data['name'],
defaults=company_data
)
companies[operator.name] = operator
self.stdout.write(f'{"Created" if created else "Found"} company: {operator.name}')
# Create parks with their locations
parks_data = [
{
'name': 'Magic Kingdom',
'company': 'The Walt Disney Company',
'description': 'The first theme park at Walt Disney World Resort in Florida, opened in 1971.',
'opening_date': '1971-10-01',
'size_acres': 142,
'location': {
'street_address': '1180 Seven Seas Dr',
'city': 'Lake Buena Vista',
'state': 'Florida',
'country': 'United States',
'postal_code': '32830',
'latitude': 28.4177,
'longitude': -81.5812
},
'areas': [
{'name': 'Main Street, U.S.A.', 'description': 'Victorian-era themed entrance corridor'},
{'name': 'Adventureland', 'description': 'Exotic tropical places themed area'},
{'name': 'Frontierland', 'description': 'American Old West themed area'},
{'name': 'Liberty Square', 'description': 'Colonial America themed area'},
{'name': 'Fantasyland', 'description': 'Fairy tale themed area'},
{'name': 'Tomorrowland', 'description': 'Future themed area'}
]
},
{
'name': 'Universal Studios Florida',
'company': 'Universal Parks & Resorts',
'description': 'Movie and television-based theme park in Orlando, Florida.',
'opening_date': '1990-06-07',
'size_acres': 108,
'location': {
'street_address': '6000 Universal Blvd',
'city': 'Orlando',
'state': 'Florida',
'country': 'United States',
'postal_code': '32819',
'latitude': 28.4749,
'longitude': -81.4687
},
'areas': [
{'name': 'Production Central', 'description': 'Main entrance area with movie-themed attractions'},
{'name': 'New York', 'description': 'Themed after New York City streets'},
{'name': 'San Francisco', 'description': 'Themed after San Francisco\'s waterfront'},
{'name': 'The Wizarding World of Harry Potter - Diagon Alley', 'description': 'Themed after the Harry Potter series'},
{'name': 'Springfield', 'description': 'Themed after The Simpsons hometown'}
]
},
{
'name': 'Cedar Point',
'company': 'Cedar Fair Entertainment Company',
'description': 'Known as the "Roller Coaster Capital of the World".',
'opening_date': '1870-06-01',
'size_acres': 364,
'location': {
'street_address': '1 Cedar Point Dr',
'city': 'Sandusky',
'state': 'Ohio',
'country': 'United States',
'postal_code': '44870',
'latitude': 41.4822,
'longitude': -82.6835
},
'areas': [
{'name': 'Frontiertown', 'description': 'Western-themed area with multiple roller coasters'},
{'name': 'Millennium Island', 'description': 'Home to the Millennium Force roller coaster'},
{'name': 'Cedar Point Shores', 'description': 'Waterpark area'},
{'name': 'Top Thrill Dragster', 'description': 'Area surrounding the iconic launched coaster'}
]
},
{
'name': 'Silver Dollar City',
'company': 'Herschend Family Entertainment',
'description': 'An 1880s-themed park featuring over 40 rides and attractions.',
'opening_date': '1960-05-01',
'size_acres': 61,
'location': {
'street_address': '399 Silver Dollar City Parkway',
'city': 'Branson',
'state': 'Missouri',
'country': 'United States',
'postal_code': '65616',
'latitude': 36.668497,
'longitude': -93.339074
},
'areas': [
{'name': 'Grand Exposition', 'description': 'Home to many family rides and attractions'},
{'name': 'Wildfire', 'description': 'Named after the famous B&M coaster'},
{'name': 'Wilson\'s Farm', 'description': 'Farm-themed attractions and dining'},
{'name': 'Riverfront', 'description': 'Water-themed attractions area'},
{'name': 'The Valley', 'description': 'Home to Time Traveler and other major attractions'}
]
},
{
'name': 'Six Flags Magic Mountain',
'company': 'Six Flags Entertainment Corporation',
'description': 'Known for its world-record 19 roller coasters.',
'opening_date': '1971-05-29',
'size_acres': 262,
'location': {
'street_address': '26101 Magic Mountain Pkwy',
'city': 'Valencia',
'state': 'California',
'country': 'United States',
'postal_code': '91355',
'latitude': 34.4253,
'longitude': -118.5971
},
'areas': [
{'name': 'Six Flags Plaza', 'description': 'Main entrance area'},
{'name': 'DC Universe', 'description': 'DC Comics themed area'},
{'name': 'Screampunk District', 'description': 'Steampunk themed area'},
{'name': 'The Underground', 'description': 'Urban themed area'},
{'name': 'Goliath Territory', 'description': 'Area surrounding the Goliath hypercoaster'}
]
},
{
'name': 'SeaWorld Orlando',
'company': 'SeaWorld Parks & Entertainment',
'description': 'Marine zoological park combined with thrill rides and shows.',
'opening_date': '1973-12-15',
'size_acres': 200,
'location': {
'street_address': '7007 Sea World Dr',
'city': 'Orlando',
'state': 'Florida',
'country': 'United States',
'postal_code': '32821',
'latitude': 28.4115,
'longitude': -81.4617
},
'areas': [
{'name': 'Sea Harbor', 'description': 'Main entrance and shopping area'},
{'name': 'Shark Encounter', 'description': 'Shark exhibit and themed area'},
{'name': 'Antarctica: Empire of the Penguin', 'description': 'Penguin-themed area'},
{'name': 'Manta', 'description': 'Area themed around the Manta flying roller coaster'},
{'name': 'Sesame Street Land', 'description': 'Kid-friendly area based on Sesame Street'}
]
}
]
# Create parks and their areas
for park_data in parks_data:
company = companies[park_data['company']]
park, created = Park.objects.get_or_create(
name=park_data['name'],
defaults={
'description': park_data['description'],
'status': 'OPERATING',
'opening_date': park_data['opening_date'],
'size_acres': park_data['size_acres'],
'owner': company
}
)
self.stdout.write(f'{"Created" if created else "Found"} park: {park.name}')
# Create location for park
if created:
loc_data = park_data['location']
park_content_type = ContentType.objects.get_for_model(Park)
Location.objects.create(
content_type=park_content_type,
object_id=park.id,
street_address=loc_data['street_address'],
city=loc_data['city'],
state=loc_data['state'],
country=loc_data['country'],
postal_code=loc_data['postal_code'],
latitude=loc_data['latitude'],
longitude=loc_data['longitude']
)
# Create areas for park
for area_data in park_data['areas']:
area, created = ParkArea.objects.get_or_create(
name=area_data['name'],
park=park,
defaults={
'description': area_data['description']
}
)
self.stdout.write(f'{"Created" if created else "Found"} area: {area.name} in {park.name}')
self.stdout.write(self.style.SUCCESS('Successfully seeded initial park data'))