feat: Implement MFA authentication, add ride statistics model, and update various services, APIs, and tests across the application.

This commit is contained in:
pacnpal
2025-12-28 17:32:53 -05:00
parent aa56c46c27
commit c95f99ca10
452 changed files with 7948 additions and 6073 deletions

View File

@@ -3,11 +3,12 @@ Parks-specific location services with OpenStreetMap integration.
Handles geocoding, reverse geocoding, and location search for parks.
"""
import logging
from typing import Any
import requests
from typing import List, Dict, Any, Optional
from django.core.cache import cache
from django.db import transaction
import logging
from ..models import ParkLocation
@@ -23,7 +24,7 @@ class ParkLocationService:
USER_AGENT = "ThrillWiki/1.0 (https://thrillwiki.com)"
@classmethod
def search_locations(cls, query: str, limit: int = 10) -> Dict[str, Any]:
def search_locations(cls, query: str, limit: int = 10) -> dict[str, Any]:
"""
Search for locations using OpenStreetMap Nominatim API.
Optimized for finding theme parks and amusement parks.
@@ -98,7 +99,7 @@ class ParkLocationService:
}
@classmethod
def reverse_geocode(cls, latitude: float, longitude: float) -> Dict[str, Any]:
def reverse_geocode(cls, latitude: float, longitude: float) -> dict[str, Any]:
"""
Reverse geocode coordinates to get location information using OSM.
@@ -159,7 +160,7 @@ class ParkLocationService:
return {"error": "Reverse geocoding service temporarily unavailable"}
@classmethod
def geocode_address(cls, address: str) -> Dict[str, Any]:
def geocode_address(cls, address: str) -> dict[str, Any]:
"""
Geocode an address to get coordinates using OSM.
@@ -185,8 +186,8 @@ class ParkLocationService:
cls,
*,
park,
latitude: Optional[float] = None,
longitude: Optional[float] = None,
latitude: float | None = None,
longitude: float | None = None,
street_address: str = "",
city: str = "",
state: str = "",
@@ -195,7 +196,7 @@ class ParkLocationService:
highway_exit: str = "",
parking_notes: str = "",
seasonal_notes: str = "",
osm_id: Optional[int] = None,
osm_id: int | None = None,
osm_type: str = "",
) -> ParkLocation:
"""
@@ -279,7 +280,7 @@ class ParkLocationService:
@classmethod
def find_nearby_parks(
cls, latitude: float, longitude: float, radius_km: float = 50
) -> List[ParkLocation]:
) -> list[ParkLocation]:
"""
Find parks near given coordinates using PostGIS.
@@ -349,8 +350,8 @@ class ParkLocationService:
@classmethod
def _transform_osm_result(
cls, osm_item: Dict[str, Any]
) -> Optional[Dict[str, Any]]:
cls, osm_item: dict[str, Any]
) -> dict[str, Any] | None:
"""Transform OSM search result to our standard format."""
try:
address = osm_item.get("address", {})
@@ -432,8 +433,8 @@ class ParkLocationService:
@classmethod
def _transform_osm_reverse_result(
cls, osm_result: Dict[str, Any]
) -> Dict[str, Any]:
cls, osm_result: dict[str, Any]
) -> dict[str, Any]:
"""Transform OSM reverse geocoding result to our standard format."""
address = osm_result.get("address", {})