Refactor test utilities and enhance ASGI settings

- Cleaned up and standardized assertions in ApiTestMixin for API response validation.
- Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE.
- Removed unused imports and improved formatting in settings.py.
- Refactored URL patterns in urls.py for better readability and organization.
- Enhanced view functions in views.py for consistency and clarity.
- Added .flake8 configuration for linting and style enforcement.
- Introduced type stubs for django-environ to improve type checking with Pylance.
This commit is contained in:
pacnpal
2025-08-20 19:51:59 -04:00
parent 69c07d1381
commit 66ed4347a9
230 changed files with 15094 additions and 11578 deletions

View File

@@ -1,34 +1,29 @@
from django.core.management.base import BaseCommand
from django.db.models import Count, Q
from django.db.models import Q
from parks.models import Park
class Command(BaseCommand):
help = 'Update total_rides and total_roller_coasters counts for all parks'
help = "Update total_rides and total_roller_coasters counts for all parks"
def handle(self, *args, **options):
parks = Park.objects.all()
operating_rides = Q(status='OPERATING')
operating_rides = Q(status="OPERATING")
updated = 0
for park in parks:
# Count total operating rides
total_rides = park.rides.filter(operating_rides).count()
# Count total operating roller coasters
total_coasters = park.rides.filter(
operating_rides,
category='RC'
).count()
total_coasters = 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
total_rides=total_rides, total_roller_coasters=total_coasters
)
updated += 1
self.stdout.write(
self.style.SUCCESS(
f'Successfully updated counts for {updated} parks'
)
self.style.SUCCESS(f"Successfully updated counts for {updated} parks")
)