mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-30 03:47:02 -05:00
feat: Implement MFA authentication, add ride statistics model, and update various services, APIs, and tests across the application.
This commit is contained in:
@@ -4,16 +4,18 @@ Provides interfaces for creating and managing multi-park road trips.
|
||||
"""
|
||||
|
||||
import json
|
||||
from typing import Dict, Any, List
|
||||
from typing import Any
|
||||
|
||||
from django.http import HttpRequest, HttpResponse, JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.http import JsonResponse, HttpRequest, HttpResponse
|
||||
from django.views.generic import TemplateView, View
|
||||
from django.urls import reverse
|
||||
from django.views.generic import TemplateView, View
|
||||
|
||||
from apps.core.services.data_structures import LocationType
|
||||
from apps.core.services.map_service import unified_map_service
|
||||
|
||||
from .models import Park
|
||||
from .services.roadtrip import RoadTripService
|
||||
from apps.core.services.map_service import unified_map_service
|
||||
from apps.core.services.data_structures import LocationType
|
||||
|
||||
JSON_DECODE_ERROR_MSG = "Invalid JSON data"
|
||||
PARKS_ALONG_ROUTE_HTML = "parks/partials/parks_along_route.html"
|
||||
@@ -26,7 +28,7 @@ class RoadTripViewMixin:
|
||||
super().__init__()
|
||||
self.roadtrip_service = RoadTripService()
|
||||
|
||||
def get_roadtrip_context(self) -> Dict[str, Any]:
|
||||
def get_roadtrip_context(self) -> dict[str, Any]:
|
||||
"""Get common context data for road trip views."""
|
||||
return {
|
||||
"roadtrip_api_urls": {
|
||||
@@ -72,7 +74,7 @@ class RoadTripPlannerView(RoadTripViewMixin, TemplateView):
|
||||
|
||||
return context
|
||||
|
||||
def _get_countries_with_parks(self) -> List[str]:
|
||||
def _get_countries_with_parks(self) -> list[str]:
|
||||
"""Get list of countries that have theme parks."""
|
||||
countries = (
|
||||
Park.objects.filter(status="OPERATING", location__country__isnull=False)
|
||||
@@ -177,7 +179,7 @@ class CreateTripView(RoadTripViewMixin, View):
|
||||
status=500,
|
||||
)
|
||||
|
||||
def _park_to_dict(self, park: Park) -> Dict[str, Any]:
|
||||
def _park_to_dict(self, park: Park) -> dict[str, Any]:
|
||||
"""Convert park instance to dictionary."""
|
||||
return {
|
||||
"id": park.id,
|
||||
@@ -190,7 +192,7 @@ class CreateTripView(RoadTripViewMixin, View):
|
||||
"url": reverse("parks:park_detail", kwargs={"slug": park.slug}),
|
||||
}
|
||||
|
||||
def _leg_to_dict(self, leg) -> Dict[str, Any]:
|
||||
def _leg_to_dict(self, leg) -> dict[str, Any]:
|
||||
"""Convert trip leg to dictionary."""
|
||||
return {
|
||||
"from_park": self._park_to_dict(leg.from_park),
|
||||
|
||||
Reference in New Issue
Block a user