mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-02 01:47:04 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -98,9 +98,7 @@ def show_coaster_fields(request: HttpRequest) -> HttpResponse:
|
||||
return render(request, "rides/partials/coaster_fields.html")
|
||||
|
||||
|
||||
def ride_status_actions(
|
||||
request: HttpRequest, park_slug: str, ride_slug: str
|
||||
) -> HttpResponse:
|
||||
def ride_status_actions(request: HttpRequest, park_slug: str, ride_slug: str) -> HttpResponse:
|
||||
"""
|
||||
Return FSM status actions for ride moderators.
|
||||
|
||||
@@ -131,9 +129,7 @@ def ride_status_actions(
|
||||
)
|
||||
|
||||
|
||||
def ride_header_badge(
|
||||
request: HttpRequest, park_slug: str, ride_slug: str
|
||||
) -> HttpResponse:
|
||||
def ride_header_badge(request: HttpRequest, park_slug: str, ride_slug: str) -> HttpResponse:
|
||||
"""
|
||||
Return the header status badge partial for a ride.
|
||||
|
||||
@@ -205,9 +201,7 @@ class RideDetailView(HistoryMixin, DetailView):
|
||||
return context
|
||||
|
||||
|
||||
class RideCreateView(
|
||||
LoginRequiredMixin, ParkContextRequired, RideFormMixin, CreateView
|
||||
):
|
||||
class RideCreateView(LoginRequiredMixin, ParkContextRequired, RideFormMixin, CreateView):
|
||||
"""
|
||||
View for creating a new ride.
|
||||
|
||||
@@ -389,9 +383,7 @@ class RideListView(ListView):
|
||||
from apps.core.choices.registry import get_choices
|
||||
|
||||
choices = get_choices("categories", "rides")
|
||||
context["category_choices"] = [
|
||||
(choice.value, choice.label) for choice in choices
|
||||
]
|
||||
context["category_choices"] = [(choice.value, choice.label) for choice in choices]
|
||||
|
||||
# Add filter summary for display
|
||||
if filter_form.is_valid():
|
||||
@@ -512,10 +504,7 @@ def get_search_suggestions(request: HttpRequest) -> HttpResponse:
|
||||
if query:
|
||||
# Get common ride names
|
||||
matching_names = (
|
||||
Ride.objects.filter(name__icontains=query)
|
||||
.values("name")
|
||||
.annotate(count=Count("id"))
|
||||
.order_by("-count")[:3]
|
||||
Ride.objects.filter(name__icontains=query).values("name").annotate(count=Count("id")).order_by("-count")[:3]
|
||||
)
|
||||
|
||||
for match in matching_names:
|
||||
@@ -663,18 +652,14 @@ class RideRankingsView(ListView):
|
||||
from apps.core.choices.registry import get_choices
|
||||
|
||||
choices = get_choices("categories", "rides")
|
||||
context["category_choices"] = [
|
||||
(choice.value, choice.label) for choice in choices
|
||||
]
|
||||
context["category_choices"] = [(choice.value, choice.label) for choice in choices]
|
||||
context["selected_category"] = self.request.GET.get("category", "all")
|
||||
context["min_riders"] = self.request.GET.get("min_riders", "")
|
||||
|
||||
# Add statistics
|
||||
if self.object_list:
|
||||
context["total_ranked"] = RideRanking.objects.count()
|
||||
context["last_updated"] = (
|
||||
self.object_list[0].last_calculated if self.object_list else None
|
||||
)
|
||||
context["last_updated"] = self.object_list[0].last_calculated if self.object_list else None
|
||||
|
||||
return context
|
||||
|
||||
@@ -688,9 +673,9 @@ class RideRankingDetailView(DetailView):
|
||||
|
||||
def get_queryset(self):
|
||||
"""Get ride with ranking data."""
|
||||
return Ride.objects.select_related(
|
||||
"park", "manufacturer", "ranking"
|
||||
).prefetch_related("comparisons_as_a", "comparisons_as_b", "ranking_history")
|
||||
return Ride.objects.select_related("park", "manufacturer", "ranking").prefetch_related(
|
||||
"comparisons_as_a", "comparisons_as_b", "ranking_history"
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Add ranking details to context."""
|
||||
@@ -704,14 +689,10 @@ class RideRankingDetailView(DetailView):
|
||||
context.update(ranking_details)
|
||||
|
||||
# Get recent movement
|
||||
recent_snapshots = RankingSnapshot.objects.filter(
|
||||
ride=self.object
|
||||
).order_by("-snapshot_date")[:7]
|
||||
recent_snapshots = RankingSnapshot.objects.filter(ride=self.object).order_by("-snapshot_date")[:7]
|
||||
|
||||
if len(recent_snapshots) >= 2:
|
||||
context["rank_change"] = (
|
||||
recent_snapshots[0].rank - recent_snapshots[1].rank
|
||||
)
|
||||
context["rank_change"] = recent_snapshots[0].rank - recent_snapshots[1].rank
|
||||
context["previous_rank"] = recent_snapshots[1].rank
|
||||
else:
|
||||
context["not_ranked"] = True
|
||||
|
||||
Reference in New Issue
Block a user