mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 13:31:08 -05:00
- Cleaned up and standardized assertions in ApiTestMixin for API response validation. - Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE. - Removed unused imports and improved formatting in settings.py. - Refactored URL patterns in urls.py for better readability and organization. - Enhanced view functions in views.py for consistency and clarity. - Added .flake8 configuration for linting and style enforcement. - Introduced type stubs for django-environ to improve type checking with Pylance.
97 lines
2.5 KiB
Python
97 lines
2.5 KiB
Python
from django.contrib import admin
|
|
from django.contrib.gis.admin import GISModelAdmin
|
|
from .models.company import Company
|
|
from .models.rides import Ride
|
|
from .models.location import RideLocation
|
|
|
|
|
|
class ManufacturerAdmin(admin.ModelAdmin):
|
|
list_display = ("name", "headquarters", "website", "rides_count")
|
|
search_fields = ("name",)
|
|
|
|
def get_queryset(self, request):
|
|
return super().get_queryset(request).filter(roles__contains=["MANUFACTURER"])
|
|
|
|
|
|
class DesignerAdmin(admin.ModelAdmin):
|
|
list_display = ("name", "headquarters", "website")
|
|
search_fields = ("name",)
|
|
|
|
def get_queryset(self, request):
|
|
return super().get_queryset(request).filter(roles__contains=["DESIGNER"])
|
|
|
|
|
|
class RideLocationInline(admin.StackedInline):
|
|
"""Inline admin for RideLocation"""
|
|
|
|
model = RideLocation
|
|
extra = 0
|
|
fields = (
|
|
"park_area",
|
|
"point",
|
|
"entrance_notes",
|
|
"accessibility_notes",
|
|
)
|
|
|
|
|
|
class RideLocationAdmin(GISModelAdmin):
|
|
"""Admin for standalone RideLocation management"""
|
|
|
|
list_display = ("ride", "park_area", "has_coordinates", "created_at")
|
|
list_filter = ("park_area", "created_at")
|
|
search_fields = ("ride__name", "park_area", "entrance_notes")
|
|
readonly_fields = (
|
|
"latitude",
|
|
"longitude",
|
|
"coordinates",
|
|
"created_at",
|
|
"updated_at",
|
|
)
|
|
fieldsets = (
|
|
("Ride", {"fields": ("ride",)}),
|
|
(
|
|
"Location Information",
|
|
{
|
|
"fields": (
|
|
"park_area",
|
|
"point",
|
|
"latitude",
|
|
"longitude",
|
|
"coordinates",
|
|
),
|
|
"description": "Optional coordinates - not all rides need precise location tracking",
|
|
},
|
|
),
|
|
(
|
|
"Navigation Notes",
|
|
{
|
|
"fields": ("entrance_notes", "accessibility_notes"),
|
|
},
|
|
),
|
|
(
|
|
"Metadata",
|
|
{"fields": ("created_at", "updated_at"), "classes": ("collapse",)},
|
|
),
|
|
)
|
|
|
|
def latitude(self, obj):
|
|
return obj.latitude
|
|
|
|
latitude.short_description = "Latitude"
|
|
|
|
def longitude(self, obj):
|
|
return obj.longitude
|
|
|
|
longitude.short_description = "Longitude"
|
|
|
|
|
|
class RideAdmin(admin.ModelAdmin):
|
|
"""Enhanced Ride admin with location inline"""
|
|
|
|
inlines = [RideLocationInline]
|
|
|
|
|
|
admin.site.register(Company)
|
|
admin.site.register(Ride, RideAdmin)
|
|
admin.site.register(RideLocation, RideLocationAdmin)
|