Add migrations for ParkPhoto and RidePhoto models with associated events

- Created ParkPhoto and ParkPhotoEvent models in the parks app, including fields for image, caption, alt text, and relationships to the Park model.
- Implemented triggers for insert and update operations on ParkPhoto to log changes in ParkPhotoEvent.
- Created RidePhoto and RidePhotoEvent models in the rides app, with similar structure and functionality as ParkPhoto.
- Added fields for photo type in RidePhoto and implemented corresponding triggers for logging changes.
- Established necessary indexes and unique constraints for both models to ensure data integrity and optimize queries.
This commit is contained in:
pacnpal
2025-08-26 14:40:46 -04:00
parent 831be6a2ee
commit e4e36c7899
133 changed files with 1321 additions and 1001 deletions

View File

@@ -106,9 +106,7 @@ class Command(BaseCommand):
)
self.created_companies[company.slug] = company
self.stdout.write(
f' {
"Created" if created else "Found"} park company: {
company.name}'
f" {'Created' if created else 'Found'} park company: {company.name}"
)
# Ride manufacturers and designers (using rides.models.Company)
@@ -201,9 +199,7 @@ class Command(BaseCommand):
)
self.created_companies[company.slug] = company
self.stdout.write(
f' {
"Created" if created else "Found"} ride company: {
company.name}'
f" {'Created' if created else 'Found'} ride company: {company.name}"
)
def create_parks(self):

View File

@@ -53,7 +53,7 @@ class Command(BaseCommand):
)
companies[operator.name] = operator
self.stdout.write(
f'{"Created" if created else "Found"} company: {operator.name}'
f"{'Created' if created else 'Found'} company: {operator.name}"
)
# Create parks with their locations
@@ -301,7 +301,7 @@ class Command(BaseCommand):
"owner": company,
},
)
self.stdout.write(f'{"Created" if created else "Found"} park: {park.name}')
self.stdout.write(f"{'Created' if created else 'Found'} park: {park.name}")
# Create location for park
if created:
@@ -328,7 +328,7 @@ class Command(BaseCommand):
defaults={"description": area_data["description"]},
)
self.stdout.write(
f'{"Created" if created else "Found"} area: {area.name} in {park.name}'
f"{'Created' if created else 'Found'} area: {area.name} in {park.name}"
)
self.stdout.write(self.style.SUCCESS("Successfully seeded initial park data"))

View File

@@ -121,8 +121,7 @@ class Command(BaseCommand):
except Exception as e:
self.logger.error(
f"Error during data cleanup: {
str(e)}",
f"Error during data cleanup: {str(e)}",
exc_info=True,
)
self.stdout.write(
@@ -205,7 +204,7 @@ class Command(BaseCommand):
if missing_tables:
self.stdout.write(
self.style.WARNING(
f'Missing tables for models: {", ".join(missing_tables)}'
f"Missing tables for models: {', '.join(missing_tables)}"
)
)
return False
@@ -353,13 +352,13 @@ class Command(BaseCommand):
)
self.park_companies[data["name"]] = company
self.stdout.write(
f' {
"Created" if created else "Found"} park company: {
company.name}'
f" {'Created' if created else 'Found'} park company: {
company.name
}"
)
except Exception as e:
self.logger.error(
f'Error creating park company {data["name"]}: {str(e)}'
f"Error creating park company {data['name']}: {str(e)}"
)
raise
@@ -378,13 +377,13 @@ class Command(BaseCommand):
)
self.ride_companies[data["name"]] = company
self.stdout.write(
f' {
"Created" if created else "Found"} ride company: {
company.name}'
f" {'Created' if created else 'Found'} ride company: {
company.name
}"
)
except Exception as e:
self.logger.error(
f'Error creating ride company {data["name"]}: {str(e)}'
f"Error creating ride company {data['name']}: {str(e)}"
)
raise
@@ -532,9 +531,7 @@ class Command(BaseCommand):
)
self.parks[park_data["name"]] = park
self.stdout.write(
f' {
"Created" if created else "Found"} park: {
park.name}'
f" {'Created' if created else 'Found'} park: {park.name}"
)
# Create location for park
@@ -556,15 +553,15 @@ class Command(BaseCommand):
park_location.save()
except Exception as e:
self.logger.error(
f'Error creating location for park {
park_data["name"]}: {
str(e)}'
f"Error creating location for park {
park_data['name']
}: {str(e)}"
)
raise
except Exception as e:
self.logger.error(
f'Error creating park {park_data["name"]}: {str(e)}'
f"Error creating park {park_data['name']}: {str(e)}"
)
raise
@@ -631,15 +628,13 @@ class Command(BaseCommand):
)
self.ride_models[model_data["name"]] = model
self.stdout.write(
f' {
"Created" if created else "Found"} ride model: {
model.name}'
f" {'Created' if created else 'Found'} ride model: {
model.name
}"
)
except Exception as e:
self.logger.error(
f'Error creating ride model {
model_data["name"]}: {
str(e)}'
f"Error creating ride model {model_data['name']}: {str(e)}"
)
raise
@@ -860,9 +855,7 @@ class Command(BaseCommand):
)
self.rides[ride_data["name"]] = ride
self.stdout.write(
f' {
"Created" if created else "Found"} ride: {
ride.name}'
f" {'Created' if created else 'Found'} ride: {ride.name}"
)
# Create roller coaster stats if provided
@@ -872,15 +865,15 @@ class Command(BaseCommand):
RollerCoasterStats.objects.create(ride=ride, **stats_data)
except Exception as e:
self.logger.error(
f'Error creating stats for ride {
ride_data["name"]}: {
str(e)}'
f"Error creating stats for ride {ride_data['name']}: {
str(e)
}"
)
raise
except Exception as e:
self.logger.error(
f'Error creating ride {ride_data["name"]}: {str(e)}'
f"Error creating ride {ride_data['name']}: {str(e)}"
)
raise
@@ -1013,16 +1006,13 @@ class Command(BaseCommand):
},
)
self.stdout.write(
f' {
"Created" if created else "Found"} area: {
area.name} in {
park.name}'
f" {'Created' if created else 'Found'} area: {
area.name
} in {park.name}"
)
except Exception as e:
self.logger.error(
f'Error creating areas for park {
area_group["park"]}: {
str(e)}'
f"Error creating areas for park {area_group['park']}: {str(e)}"
)
raise
@@ -1095,15 +1085,15 @@ class Command(BaseCommand):
},
)
self.stdout.write(
f' {
"Created" if created else "Found"} park review: {
review.title}'
f" {'Created' if created else 'Found'} park review: {
review.title
}"
)
except Exception as e:
self.logger.error(
f'Error creating park review for {
review_data["park"]}: {
str(e)}'
f"Error creating park review for {review_data['park']}: {
str(e)
}"
)
raise
@@ -1154,15 +1144,15 @@ class Command(BaseCommand):
},
)
self.stdout.write(
f' {
"Created" if created else "Found"} ride review: {
review.title}'
f" {'Created' if created else 'Found'} ride review: {
review.title
}"
)
except Exception as e:
self.logger.error(
f'Error creating ride review for {
review_data["ride"]}: {
str(e)}'
f"Error creating ride review for {review_data['ride']}: {
str(e)
}"
)
raise

View File

@@ -55,10 +55,7 @@ class Command(BaseCommand):
# Test Park model integration
self.stdout.write("\n🔍 Testing Park model integration:")
self.stdout.write(
f" Park formatted location: {
park.formatted_location}"
)
self.stdout.write(f" Park formatted location: {park.formatted_location}")
self.stdout.write(f" Park coordinates: {park.coordinates}")
# Create another location for distance testing
@@ -112,10 +109,7 @@ class Command(BaseCommand):
nearby_locations = ParkLocation.objects.filter(
point__distance_lte=(search_point, D(km=100))
)
self.stdout.write(
f" Found {
nearby_locations.count()} parks within 100km"
)
self.stdout.write(f" Found {nearby_locations.count()} parks within 100km")
for loc in nearby_locations:
self.stdout.write(f" - {loc.park.name} in {loc.city}, {loc.state}")
except Exception as e: