mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 00:11:09 -05:00
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:
@@ -8,47 +8,45 @@ class RideLocation(models.Model):
|
||||
Lightweight location tracking for individual rides within parks.
|
||||
Optional coordinates with focus on practical navigation information.
|
||||
"""
|
||||
|
||||
# Relationships
|
||||
ride = models.OneToOneField(
|
||||
'rides.Ride',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='ride_location'
|
||||
"rides.Ride", on_delete=models.CASCADE, related_name="ride_location"
|
||||
)
|
||||
|
||||
|
||||
# Optional Spatial Data - keep it simple with single point
|
||||
point = gis_models.PointField(
|
||||
srid=4326,
|
||||
null=True,
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Geographic coordinates for ride location (longitude, latitude)"
|
||||
help_text="Geographic coordinates for ride location (longitude, latitude)",
|
||||
)
|
||||
|
||||
|
||||
# Park Area Information
|
||||
park_area = models.CharField(
|
||||
max_length=100,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Themed area or land within the park (e.g., 'Frontierland', 'Tomorrowland')"
|
||||
help_text=(
|
||||
"Themed area or land within the park (e.g., 'Frontierland', 'Tomorrowland')"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# General notes field to match database schema
|
||||
notes = models.TextField(
|
||||
blank=True,
|
||||
help_text="General location notes"
|
||||
)
|
||||
|
||||
notes = models.TextField(blank=True, help_text="General location notes")
|
||||
|
||||
# Navigation and Entrance Information
|
||||
entrance_notes = models.TextField(
|
||||
blank=True,
|
||||
help_text="Directions to ride entrance, queue location, or navigation tips"
|
||||
help_text="Directions to ride entrance, queue location, or navigation tips",
|
||||
)
|
||||
|
||||
|
||||
# Accessibility Information
|
||||
accessibility_notes = models.TextField(
|
||||
blank=True,
|
||||
help_text="Information about accessible entrances, wheelchair access, etc."
|
||||
help_text="Information about accessible entrances, wheelchair access, etc.",
|
||||
)
|
||||
|
||||
|
||||
# Metadata
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
@@ -102,11 +100,11 @@ class RideLocation(models.Model):
|
||||
"""
|
||||
if not self.point:
|
||||
return None
|
||||
|
||||
park_location = getattr(self.ride.park, 'location', None)
|
||||
|
||||
park_location = getattr(self.ride.park, "location", None)
|
||||
if not park_location or not park_location.point:
|
||||
return None
|
||||
|
||||
|
||||
# Use geodetic distance calculation which returns meters, convert to km
|
||||
distance_m = self.point.distance(park_location.point)
|
||||
return distance_m / 1000.0
|
||||
@@ -118,8 +116,9 @@ class RideLocation(models.Model):
|
||||
class Meta:
|
||||
verbose_name = "Ride Location"
|
||||
verbose_name_plural = "Ride Locations"
|
||||
ordering = ['ride__name']
|
||||
ordering = ["ride__name"]
|
||||
indexes = [
|
||||
models.Index(fields=['park_area']),
|
||||
# Spatial index will be created automatically for PostGIS PointField
|
||||
]
|
||||
models.Index(fields=["park_area"]),
|
||||
# Spatial index will be created automatically for PostGIS
|
||||
# PointField
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user