mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 11:31:07 -05:00
- Introduced Next.js integration guide for ThrillWiki API, detailing authentication, core domain APIs, data structures, and implementation patterns. - Documented the migration to Rich Choice Objects, highlighting changes for frontend developers and enhanced metadata availability. - Fixed the missing `get_by_slug` method in the Ride model, ensuring proper functionality of ride detail endpoints. - Created a test script to verify manufacturer syncing with ride models, ensuring data integrity across related models.
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Test script to verify manufacturer syncing with ride models.
|
|
"""
|
|
import os
|
|
import sys
|
|
import django
|
|
|
|
# Add the backend directory to the Python path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
|
|
|
|
# Set up Django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
|
|
django.setup()
|
|
|
|
from apps.rides.models import Ride, RideModel, Company
|
|
from apps.parks.models import Park
|
|
|
|
def test_manufacturer_sync():
|
|
"""Test that ride manufacturer syncs with ride model manufacturer."""
|
|
|
|
print("Testing manufacturer sync with ride models...")
|
|
|
|
# Get a ride that has a ride_model
|
|
ride = Ride.objects.select_related('ride_model', 'ride_model__manufacturer', 'manufacturer').first()
|
|
|
|
if not ride:
|
|
print("No rides found in database")
|
|
return
|
|
|
|
print(f"\nRide: {ride.name}")
|
|
print(f"Park: {ride.park.name}")
|
|
|
|
if ride.ride_model:
|
|
print(f"Ride Model: {ride.ride_model.name}")
|
|
print(f"Ride Model Manufacturer: {ride.ride_model.manufacturer.name if ride.ride_model.manufacturer else 'None'}")
|
|
else:
|
|
print("Ride Model: None")
|
|
|
|
print(f"Ride Manufacturer: {ride.manufacturer.name if ride.manufacturer else 'None'}")
|
|
|
|
# Check if they match
|
|
if ride.ride_model and ride.ride_model.manufacturer:
|
|
if ride.manufacturer == ride.ride_model.manufacturer:
|
|
print("✅ Manufacturer is correctly synced with ride model")
|
|
else:
|
|
print("❌ Manufacturer is NOT synced with ride model")
|
|
print("This should be fixed by the new save() method")
|
|
|
|
# Test the fix by saving the ride
|
|
print("\nTesting fix by re-saving the ride...")
|
|
ride.save()
|
|
ride.refresh_from_db()
|
|
|
|
print(f"After save - Ride Manufacturer: {ride.manufacturer.name if ride.manufacturer else 'None'}")
|
|
|
|
if ride.manufacturer == ride.ride_model.manufacturer:
|
|
print("✅ Fix successful! Manufacturer is now synced")
|
|
else:
|
|
print("❌ Fix failed - manufacturer still not synced")
|
|
else:
|
|
print("⚠️ Cannot test sync - ride model has no manufacturer")
|
|
|
|
if __name__ == "__main__":
|
|
test_manufacturer_sync()
|