fixing the home page

This commit is contained in:
pacnpal
2024-11-06 19:09:56 +00:00
parent ff52f182fc
commit d7a89d8725
8 changed files with 28 additions and 16 deletions

View File

@@ -6,22 +6,22 @@ from rides.models import Ride
from .models import Park
def update_park_ride_counts(park):
"""Update total_rides and total_roller_coasters for a park"""
"""Update ride_count and coaster_count for a park"""
operating_rides = Q(status='OPERATING')
# Count total operating rides
total_rides = park.rides.filter(operating_rides).count()
ride_count = park.rides.filter(operating_rides).count()
# Count total operating roller coasters
total_coasters = park.rides.filter(
coaster_count = park.rides.filter(
operating_rides,
category='RC'
).count()
# Update park counts
Park.objects.filter(id=park.id).update(
total_rides=total_rides,
total_roller_coasters=total_coasters
ride_count=ride_count,
coaster_count=coaster_count
)
@receiver(post_save, sender=Ride)