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

@@ -5,11 +5,14 @@ This module provides media management functionality specific to rides.
"""
import logging
from typing import List, Optional, Dict, Any
from typing import Any
from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import UploadedFile
from django.db import transaction
from django.contrib.auth import get_user_model
from apps.core.services.media_service import MediaService
from ..models import Ride, RidePhoto
User = get_user_model()
@@ -83,8 +86,8 @@ class RideMediaService:
ride: Ride,
approved_only: bool = True,
primary_first: bool = True,
photo_type: Optional[str] = None,
) -> List[RidePhoto]:
photo_type: str | None = None,
) -> list[RidePhoto]:
"""
Get photos for a ride.
@@ -113,7 +116,7 @@ class RideMediaService:
return list(queryset)
@staticmethod
def get_primary_photo(ride: Ride) -> Optional[RidePhoto]:
def get_primary_photo(ride: Ride) -> RidePhoto | None:
"""
Get the primary photo for a ride.
@@ -129,7 +132,7 @@ class RideMediaService:
return None
@staticmethod
def get_photos_by_type(ride: Ride, photo_type: str) -> List[RidePhoto]:
def get_photos_by_type(ride: Ride, photo_type: str) -> list[RidePhoto]:
"""
Get photos of a specific type for a ride.
@@ -224,7 +227,7 @@ class RideMediaService:
return False
@staticmethod
def get_photo_stats(ride: Ride) -> Dict[str, Any]:
def get_photo_stats(ride: Ride) -> dict[str, Any]:
"""
Get photo statistics for a ride.
@@ -251,7 +254,7 @@ class RideMediaService:
}
@staticmethod
def bulk_approve_photos(photos: List[RidePhoto], approved_by: User) -> int:
def bulk_approve_photos(photos: list[RidePhoto], approved_by: User) -> int:
"""
Bulk approve multiple photos.
@@ -275,7 +278,7 @@ class RideMediaService:
return approved_count
@staticmethod
def get_construction_timeline(ride: Ride) -> List[RidePhoto]:
def get_construction_timeline(ride: Ride) -> list[RidePhoto]:
"""
Get construction photos ordered chronologically.
@@ -292,7 +295,7 @@ class RideMediaService:
)
@staticmethod
def get_onride_photos(ride: Ride) -> List[RidePhoto]:
def get_onride_photos(ride: Ride) -> list[RidePhoto]:
"""
Get on-ride photos for a ride.