feat: Implement initial schema and add various API, service, and management command enhancements across the application.

This commit is contained in:
pacnpal
2026-01-01 15:13:01 -05:00
parent c95f99ca10
commit b243b17af7
413 changed files with 11164 additions and 17433 deletions

View File

@@ -245,9 +245,7 @@ class ParkLocationService:
return park_location
@classmethod
def update_park_location(
cls, park_location: ParkLocation, **updates
) -> ParkLocation:
def update_park_location(cls, park_location: ParkLocation, **updates) -> ParkLocation:
"""
Update park location with validation.
@@ -278,9 +276,7 @@ class ParkLocationService:
return park_location
@classmethod
def find_nearby_parks(
cls, latitude: float, longitude: float, radius_km: float = 50
) -> list[ParkLocation]:
def find_nearby_parks(cls, latitude: float, longitude: float, radius_km: float = 50) -> list[ParkLocation]:
"""
Find parks near given coordinates using PostGIS.
@@ -298,9 +294,7 @@ class ParkLocationService:
center_point = Point(longitude, latitude, srid=4326)
return list(
ParkLocation.objects.filter(
point__distance_lte=(center_point, Distance(km=radius_km))
)
ParkLocation.objects.filter(point__distance_lte=(center_point, Distance(km=radius_km)))
.select_related("park", "park__operator")
.order_by("point__distance")
)
@@ -349,9 +343,7 @@ class ParkLocationService:
return park_location
@classmethod
def _transform_osm_result(
cls, osm_item: dict[str, Any]
) -> dict[str, Any] | None:
def _transform_osm_result(cls, osm_item: dict[str, Any]) -> dict[str, Any] | None:
"""Transform OSM search result to our standard format."""
try:
address = osm_item.get("address", {})
@@ -369,12 +361,7 @@ class ParkLocationService:
or ""
)
state = (
address.get("state")
or address.get("province")
or address.get("region")
or ""
)
state = address.get("state") or address.get("province") or address.get("region") or ""
country = address.get("country", "")
postal_code = address.get("postcode", "")
@@ -432,9 +419,7 @@ class ParkLocationService:
return None
@classmethod
def _transform_osm_reverse_result(
cls, osm_result: dict[str, Any]
) -> dict[str, Any]:
def _transform_osm_reverse_result(cls, osm_result: dict[str, Any]) -> dict[str, Any]:
"""Transform OSM reverse geocoding result to our standard format."""
address = osm_result.get("address", {})
@@ -443,20 +428,9 @@ class ParkLocationService:
street_name = address.get("road", "")
street_address = f"{street_number} {street_name}".strip()
city = (
address.get("city")
or address.get("town")
or address.get("village")
or address.get("municipality")
or ""
)
city = address.get("city") or address.get("town") or address.get("village") or address.get("municipality") or ""
state = (
address.get("state")
or address.get("province")
or address.get("region")
or ""
)
state = address.get("state") or address.get("province") or address.get("region") or ""
country = address.get("country", "")
postal_code = address.get("postcode", "")