mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:51:09 -05:00
refactor: Rename launch_type to propulsion_system across the codebase
This commit is contained in:
@@ -878,7 +878,7 @@ class Command(BaseCommand):
|
||||
track_material=random.choice(['STEEL', 'WOOD', 'HYBRID']),
|
||||
roller_coaster_type=random.choice(['SITDOWN', 'INVERTED', 'WING', 'DIVE', 'FLYING']),
|
||||
max_drop_height_ft=Decimal(str(random.randint(80, 300))),
|
||||
launch_type=random.choice(['CHAIN', 'LSM', 'HYDRAULIC']),
|
||||
propulsion_system=random.choice(['CHAIN', 'LSM', 'HYDRAULIC']),
|
||||
train_style=random.choice(['Traditional', 'Floorless', 'Wing', 'Flying']),
|
||||
trains_count=random.randint(2, 4),
|
||||
cars_per_train=random.randint(6, 8),
|
||||
@@ -939,7 +939,7 @@ class Command(BaseCommand):
|
||||
track_material=random.choice(['STEEL', 'WOOD', 'HYBRID']),
|
||||
roller_coaster_type=random.choice(['SITDOWN', 'INVERTED', 'FAMILY', 'WILD_MOUSE']),
|
||||
max_drop_height_ft=Decimal(str(random.randint(40, 250))),
|
||||
launch_type=random.choice(['CHAIN', 'LSM', 'GRAVITY']),
|
||||
propulsion_system=random.choice(['CHAIN', 'LSM', 'GRAVITY']),
|
||||
train_style=random.choice(['Traditional', 'Family', 'Compact']),
|
||||
trains_count=random.randint(1, 3),
|
||||
cars_per_train=random.randint(4, 8),
|
||||
|
||||
@@ -22,7 +22,7 @@ from drf_spectacular.types import OpenApiTypes
|
||||
from rest_framework import status
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.permissions import IsAuthenticated, AllowAny
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
@@ -109,9 +109,16 @@ class ParkPhotoViewSet(ModelViewSet):
|
||||
Includes advanced features like bulk approval and statistics.
|
||||
"""
|
||||
|
||||
permission_classes = [IsAuthenticated]
|
||||
lookup_field = "id"
|
||||
|
||||
def get_permissions(self):
|
||||
"""Set permissions based on action."""
|
||||
if self.action in ['list', 'retrieve', 'stats']:
|
||||
permission_classes = [AllowAny]
|
||||
else:
|
||||
permission_classes = [IsAuthenticated]
|
||||
return [permission() for permission in permission_classes]
|
||||
|
||||
def get_queryset(self): # type: ignore[override]
|
||||
"""Get photos for the current park with optimized queries."""
|
||||
queryset = ParkPhoto.objects.select_related(
|
||||
|
||||
@@ -304,7 +304,7 @@ class HybridRideSerializer(serializers.ModelSerializer):
|
||||
coaster_track_material = serializers.SerializerMethodField()
|
||||
coaster_roller_coaster_type = serializers.SerializerMethodField()
|
||||
coaster_max_drop_height_ft = serializers.SerializerMethodField()
|
||||
coaster_launch_type = serializers.SerializerMethodField()
|
||||
coaster_propulsion_system = serializers.SerializerMethodField()
|
||||
coaster_train_style = serializers.SerializerMethodField()
|
||||
coaster_trains_count = serializers.SerializerMethodField()
|
||||
coaster_cars_per_train = serializers.SerializerMethodField()
|
||||
@@ -439,11 +439,11 @@ class HybridRideSerializer(serializers.ModelSerializer):
|
||||
return None
|
||||
|
||||
@extend_schema_field(serializers.CharField(allow_null=True))
|
||||
def get_coaster_launch_type(self, obj):
|
||||
"""Get roller coaster launch type."""
|
||||
def get_coaster_propulsion_system(self, obj):
|
||||
"""Get roller coaster propulsion system."""
|
||||
try:
|
||||
if hasattr(obj, 'coaster_stats') and obj.coaster_stats:
|
||||
return obj.coaster_stats.launch_type
|
||||
return obj.coaster_stats.propulsion_system
|
||||
return None
|
||||
except AttributeError:
|
||||
return None
|
||||
@@ -561,7 +561,7 @@ class HybridRideSerializer(serializers.ModelSerializer):
|
||||
"coaster_track_material",
|
||||
"coaster_roller_coaster_type",
|
||||
"coaster_max_drop_height_ft",
|
||||
"coaster_launch_type",
|
||||
"coaster_propulsion_system",
|
||||
"coaster_train_style",
|
||||
"coaster_trains_count",
|
||||
"coaster_cars_per_train",
|
||||
|
||||
@@ -173,10 +173,10 @@ class RideListCreateAPIView(APIView):
|
||||
description="Filter roller coasters by track material (STEEL, WOOD, HYBRID)",
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="launch_type",
|
||||
name="propulsion_system",
|
||||
location=OpenApiParameter.QUERY,
|
||||
type=OpenApiTypes.STR,
|
||||
description="Filter roller coasters by launch type (CHAIN, LSM, HYDRAULIC, etc.)",
|
||||
description="Filter roller coasters by propulsion system (CHAIN, LSM, HYDRAULIC, etc.)",
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="min_rating",
|
||||
@@ -507,9 +507,9 @@ class RideListCreateAPIView(APIView):
|
||||
if track_material:
|
||||
qs = qs.filter(coaster_stats__track_material=track_material)
|
||||
|
||||
launch_type = params.get("launch_type")
|
||||
if launch_type:
|
||||
qs = qs.filter(coaster_stats__launch_type=launch_type)
|
||||
propulsion_system = params.get("propulsion_system")
|
||||
if propulsion_system:
|
||||
qs = qs.filter(coaster_stats__propulsion_system=propulsion_system)
|
||||
|
||||
# Height filters
|
||||
min_height_ft = params.get("min_height_ft")
|
||||
@@ -762,7 +762,7 @@ class FilterOptionsAPIView(APIView):
|
||||
post_closing_statuses = get_choices('post_closing_statuses', 'rides')
|
||||
track_materials = get_choices('track_materials', 'rides')
|
||||
coaster_types = get_choices('coaster_types', 'rides')
|
||||
launch_systems = get_choices('launch_systems', 'rides')
|
||||
propulsion_systems = get_choices('propulsion_systems', 'rides')
|
||||
target_markets = get_choices('target_markets', 'rides')
|
||||
|
||||
# Convert Rich Choice Objects to frontend format with metadata
|
||||
@@ -831,7 +831,7 @@ class FilterOptionsAPIView(APIView):
|
||||
for choice in coaster_types
|
||||
]
|
||||
|
||||
launch_systems_data = [
|
||||
propulsion_systems_data = [
|
||||
{
|
||||
"value": choice.value,
|
||||
"label": choice.label,
|
||||
@@ -841,7 +841,7 @@ class FilterOptionsAPIView(APIView):
|
||||
"css_class": choice.metadata.get('css_class'),
|
||||
"sort_order": choice.metadata.get('sort_order', 0)
|
||||
}
|
||||
for choice in launch_systems
|
||||
for choice in propulsion_systems
|
||||
]
|
||||
|
||||
target_markets_data = [
|
||||
@@ -894,7 +894,7 @@ class FilterOptionsAPIView(APIView):
|
||||
{"value": "WING", "label": "Wing", "description": "Seats extend beyond track sides", "color": "indigo", "icon": "wing", "css_class": "bg-indigo-100 text-indigo-800", "sort_order": 5},
|
||||
{"value": "DIVE", "label": "Dive", "description": "Features steep vertical drops", "color": "red", "icon": "dive", "css_class": "bg-red-100 text-red-800", "sort_order": 6},
|
||||
]
|
||||
launch_systems_data = [
|
||||
propulsion_systems_data = [
|
||||
{"value": "CHAIN", "label": "Chain Lift", "description": "Traditional chain lift hill", "color": "gray", "icon": "chain", "css_class": "bg-gray-100 text-gray-800", "sort_order": 1},
|
||||
{"value": "LSM", "label": "LSM Launch", "description": "Linear synchronous motor launch", "color": "blue", "icon": "lightning", "css_class": "bg-blue-100 text-blue-800", "sort_order": 2},
|
||||
{"value": "HYDRAULIC", "label": "Hydraulic Launch", "description": "High-pressure hydraulic launch", "color": "red", "icon": "hydraulic", "css_class": "bg-red-100 text-red-800", "sort_order": 3},
|
||||
@@ -934,7 +934,7 @@ class FilterOptionsAPIView(APIView):
|
||||
{"value": "WOOD", "label": "Wood"},
|
||||
{"value": "HYBRID", "label": "Hybrid"},
|
||||
],
|
||||
"launch_types": [
|
||||
"propulsion_systems": [
|
||||
{"value": "CHAIN", "label": "Chain Lift"},
|
||||
{"value": "LSM", "label": "LSM Launch"},
|
||||
{"value": "HYDRAULIC", "label": "Hydraulic Launch"},
|
||||
@@ -1019,7 +1019,7 @@ class FilterOptionsAPIView(APIView):
|
||||
post_closing_statuses = get_choices('post_closing_statuses', 'rides')
|
||||
track_materials = get_choices('track_materials', 'rides')
|
||||
coaster_types = get_choices('coaster_types', 'rides')
|
||||
launch_systems = get_choices('launch_systems', 'rides')
|
||||
propulsion_systems = get_choices('propulsion_systems', 'rides')
|
||||
target_markets = get_choices('target_markets', 'rides')
|
||||
|
||||
# Convert Rich Choice Objects to frontend format with metadata
|
||||
@@ -1088,7 +1088,7 @@ class FilterOptionsAPIView(APIView):
|
||||
for choice in coaster_types
|
||||
]
|
||||
|
||||
launch_systems_data = [
|
||||
propulsion_systems_data = [
|
||||
{
|
||||
"value": choice.value,
|
||||
"label": choice.label,
|
||||
@@ -1098,7 +1098,7 @@ class FilterOptionsAPIView(APIView):
|
||||
"css_class": choice.metadata.get('css_class'),
|
||||
"sort_order": choice.metadata.get('sort_order', 0)
|
||||
}
|
||||
for choice in launch_systems
|
||||
for choice in propulsion_systems
|
||||
]
|
||||
|
||||
target_markets_data = [
|
||||
@@ -1274,7 +1274,7 @@ class FilterOptionsAPIView(APIView):
|
||||
"post_closing_statuses": post_closing_statuses_data,
|
||||
"roller_coaster_types": coaster_types_data,
|
||||
"track_materials": track_materials_data,
|
||||
"launch_types": launch_systems_data,
|
||||
"propulsion_systems": propulsion_systems_data,
|
||||
"ride_model_target_markets": target_markets_data,
|
||||
"parks": parks,
|
||||
"park_areas": park_areas,
|
||||
@@ -1499,7 +1499,7 @@ class RideImageSettingsAPIView(APIView):
|
||||
OpenApiParameter("capacity_max", OpenApiTypes.INT, description="Maximum hourly capacity"),
|
||||
OpenApiParameter("roller_coaster_type", OpenApiTypes.STR, description="Filter by roller coaster type (comma-separated for multiple)"),
|
||||
OpenApiParameter("track_material", OpenApiTypes.STR, description="Filter by track material (comma-separated for multiple)"),
|
||||
OpenApiParameter("launch_type", OpenApiTypes.STR, description="Filter by launch type (comma-separated for multiple)"),
|
||||
OpenApiParameter("propulsion_system", OpenApiTypes.STR, description="Filter by propulsion system (comma-separated for multiple)"),
|
||||
OpenApiParameter("height_ft_min", OpenApiTypes.NUMBER, description="Minimum roller coaster height in feet"),
|
||||
OpenApiParameter("height_ft_max", OpenApiTypes.NUMBER, description="Maximum roller coaster height in feet"),
|
||||
OpenApiParameter("speed_mph_min", OpenApiTypes.NUMBER, description="Minimum roller coaster speed in mph"),
|
||||
@@ -1610,7 +1610,7 @@ class HybridRideAPIView(APIView):
|
||||
filters = {}
|
||||
|
||||
# Handle comma-separated list parameters
|
||||
list_params = ['category', 'status', 'manufacturer', 'designer', 'ride_model', 'roller_coaster_type', 'track_material', 'launch_type']
|
||||
list_params = ['category', 'status', 'manufacturer', 'designer', 'ride_model', 'roller_coaster_type', 'track_material', 'propulsion_system']
|
||||
for param in list_params:
|
||||
value = query_params.get(param)
|
||||
if value:
|
||||
@@ -1692,7 +1692,7 @@ class HybridRideAPIView(APIView):
|
||||
"statuses": {"type": "array", "items": {"type": "string"}},
|
||||
"roller_coaster_types": {"type": "array", "items": {"type": "string"}},
|
||||
"track_materials": {"type": "array", "items": {"type": "string"}},
|
||||
"launch_types": {"type": "array", "items": {"type": "string"}},
|
||||
"propulsion_systems": {"type": "array", "items": {"type": "string"}},
|
||||
"parks": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -697,7 +697,7 @@ class RideFilterInputSerializer(serializers.Serializer):
|
||||
"ride_time_seconds": 150,
|
||||
"track_material": "HYBRID",
|
||||
"roller_coaster_type": "SITDOWN",
|
||||
"launch_type": "CHAIN",
|
||||
"propulsion_system": "CHAIN",
|
||||
},
|
||||
)
|
||||
]
|
||||
@@ -729,8 +729,8 @@ class RollerCoasterStatsOutputSerializer(serializers.Serializer):
|
||||
max_drop_height_ft = serializers.DecimalField(
|
||||
max_digits=6, decimal_places=2, allow_null=True
|
||||
)
|
||||
launch_type = RichChoiceFieldSerializer(
|
||||
choice_group="launch_systems",
|
||||
propulsion_system = RichChoiceFieldSerializer(
|
||||
choice_group="propulsion_systems",
|
||||
domain="rides"
|
||||
)
|
||||
train_style = serializers.CharField()
|
||||
@@ -775,8 +775,8 @@ class RollerCoasterStatsCreateInputSerializer(serializers.Serializer):
|
||||
max_drop_height_ft = serializers.DecimalField(
|
||||
max_digits=6, decimal_places=2, required=False, allow_null=True
|
||||
)
|
||||
launch_type = serializers.ChoiceField(
|
||||
choices=ModelChoices.get_launch_choices(), default="CHAIN"
|
||||
propulsion_system = serializers.ChoiceField(
|
||||
choices=ModelChoices.get_propulsion_system_choices(), default="CHAIN"
|
||||
)
|
||||
train_style = serializers.CharField(max_length=255, allow_blank=True, default="")
|
||||
trains_count = serializers.IntegerField(required=False, allow_null=True)
|
||||
@@ -808,8 +808,8 @@ class RollerCoasterStatsUpdateInputSerializer(serializers.Serializer):
|
||||
max_drop_height_ft = serializers.DecimalField(
|
||||
max_digits=6, decimal_places=2, required=False, allow_null=True
|
||||
)
|
||||
launch_type = serializers.ChoiceField(
|
||||
choices=ModelChoices.get_launch_choices(), required=False
|
||||
propulsion_system = serializers.ChoiceField(
|
||||
choices=ModelChoices.get_propulsion_system_choices(), required=False
|
||||
)
|
||||
train_style = serializers.CharField(
|
||||
max_length=255, allow_blank=True, required=False
|
||||
|
||||
@@ -381,9 +381,16 @@ class ModelChoices:
|
||||
|
||||
@staticmethod
|
||||
def get_launch_choices():
|
||||
"""Get launch system choices from Rich Choice registry."""
|
||||
"""Get launch system choices from Rich Choice registry (legacy method)."""
|
||||
from apps.core.choices.registry import get_choices
|
||||
choices = get_choices("launch_systems", "rides")
|
||||
choices = get_choices("propulsion_systems", "rides")
|
||||
return [(choice.value, choice.label) for choice in choices]
|
||||
|
||||
@staticmethod
|
||||
def get_propulsion_system_choices():
|
||||
"""Get propulsion system choices from Rich Choice registry."""
|
||||
from apps.core.choices.registry import get_choices
|
||||
choices = get_choices("propulsion_systems", "rides")
|
||||
return [(choice.value, choice.label) for choice in choices]
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user