mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 11:31:07 -05:00
feat: complete monorepo structure with frontend and shared resources
- Add complete backend/ directory with full Django application - Add frontend/ directory with Vite + TypeScript setup ready for Next.js - Add comprehensive shared/ directory with: - Complete documentation and memory-bank archives - Media files and avatars (letters, park/ride images) - Deployment scripts and automation tools - Shared types and utilities - Add architecture/ directory with migration guides - Configure pnpm workspace for monorepo development - Update .gitignore to exclude .django_tailwind_cli/ build artifacts - Preserve all historical documentation in shared/docs/memory-bank/ - Set up proper structure for full-stack development with shared resources
This commit is contained in:
223
backend/apps/parks/admin.py
Normal file
223
backend/apps/parks/admin.py
Normal file
@@ -0,0 +1,223 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.gis.admin import GISModelAdmin
|
||||
from .models import Park, ParkArea, ParkLocation, Company, CompanyHeadquarters
|
||||
|
||||
|
||||
class ParkLocationInline(admin.StackedInline):
|
||||
"""Inline admin for ParkLocation"""
|
||||
|
||||
model = ParkLocation
|
||||
extra = 0
|
||||
fields = (
|
||||
("city", "state", "country"),
|
||||
"street_address",
|
||||
"postal_code",
|
||||
"point",
|
||||
("highway_exit", "best_arrival_time"),
|
||||
"parking_notes",
|
||||
"seasonal_notes",
|
||||
("osm_id", "osm_type"),
|
||||
)
|
||||
|
||||
|
||||
class ParkLocationAdmin(GISModelAdmin):
|
||||
"""Admin for standalone ParkLocation management"""
|
||||
|
||||
list_display = (
|
||||
"park",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"latitude",
|
||||
"longitude",
|
||||
)
|
||||
list_filter = ("country", "state")
|
||||
search_fields = (
|
||||
"park__name",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"street_address",
|
||||
)
|
||||
readonly_fields = ("latitude", "longitude", "coordinates")
|
||||
fieldsets = (
|
||||
("Park", {"fields": ("park",)}),
|
||||
(
|
||||
"Address",
|
||||
{
|
||||
"fields": (
|
||||
"street_address",
|
||||
"city",
|
||||
"state",
|
||||
"country",
|
||||
"postal_code",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Geographic Coordinates",
|
||||
{
|
||||
"fields": ("point", "latitude", "longitude", "coordinates"),
|
||||
"description": "Set coordinates by clicking on the map or entering latitude/longitude",
|
||||
},
|
||||
),
|
||||
(
|
||||
"Travel Information",
|
||||
{
|
||||
"fields": (
|
||||
"highway_exit",
|
||||
"best_arrival_time",
|
||||
"parking_notes",
|
||||
"seasonal_notes",
|
||||
),
|
||||
"classes": ("collapse",),
|
||||
},
|
||||
),
|
||||
(
|
||||
"OpenStreetMap Integration",
|
||||
{"fields": ("osm_id", "osm_type"), "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 ParkAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"name",
|
||||
"formatted_location",
|
||||
"status",
|
||||
"operator",
|
||||
"property_owner",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
)
|
||||
list_filter = ("status", "location__country", "location__state")
|
||||
search_fields = (
|
||||
"name",
|
||||
"description",
|
||||
"location__city",
|
||||
"location__state",
|
||||
"location__country",
|
||||
)
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
prepopulated_fields = {"slug": ("name",)}
|
||||
inlines = [ParkLocationInline]
|
||||
|
||||
def formatted_location(self, obj):
|
||||
"""Display formatted location string"""
|
||||
return obj.formatted_location
|
||||
|
||||
formatted_location.short_description = "Location"
|
||||
|
||||
|
||||
class ParkAreaAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "park", "created_at", "updated_at")
|
||||
list_filter = ("park",)
|
||||
search_fields = ("name", "description", "park__name")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
prepopulated_fields = {"slug": ("name",)}
|
||||
|
||||
|
||||
class CompanyHeadquartersInline(admin.StackedInline):
|
||||
"""Inline admin for CompanyHeadquarters"""
|
||||
|
||||
model = CompanyHeadquarters
|
||||
extra = 0
|
||||
fields = (
|
||||
("city", "state_province", "country"),
|
||||
"street_address",
|
||||
"postal_code",
|
||||
"mailing_address",
|
||||
)
|
||||
|
||||
|
||||
class CompanyHeadquartersAdmin(admin.ModelAdmin):
|
||||
"""Admin for standalone CompanyHeadquarters management"""
|
||||
|
||||
list_display = (
|
||||
"company",
|
||||
"location_display",
|
||||
"city",
|
||||
"country",
|
||||
"created_at",
|
||||
)
|
||||
list_filter = ("country", "state_province")
|
||||
search_fields = (
|
||||
"company__name",
|
||||
"city",
|
||||
"state_province",
|
||||
"country",
|
||||
"street_address",
|
||||
)
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
fieldsets = (
|
||||
("Company", {"fields": ("company",)}),
|
||||
(
|
||||
"Address",
|
||||
{
|
||||
"fields": (
|
||||
"street_address",
|
||||
"city",
|
||||
"state_province",
|
||||
"country",
|
||||
"postal_code",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Additional Information",
|
||||
{"fields": ("mailing_address",), "classes": ("collapse",)},
|
||||
),
|
||||
(
|
||||
"Metadata",
|
||||
{"fields": ("created_at", "updated_at"), "classes": ("collapse",)},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class CompanyAdmin(admin.ModelAdmin):
|
||||
"""Enhanced Company admin with headquarters inline"""
|
||||
|
||||
list_display = (
|
||||
"name",
|
||||
"roles_display",
|
||||
"headquarters_location",
|
||||
"website",
|
||||
"founded_year",
|
||||
)
|
||||
list_filter = ("roles",)
|
||||
search_fields = ("name", "description")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
prepopulated_fields = {"slug": ("name",)}
|
||||
inlines = [CompanyHeadquartersInline]
|
||||
|
||||
def roles_display(self, obj):
|
||||
"""Display roles as a formatted string"""
|
||||
return ", ".join(obj.roles) if obj.roles else "No roles"
|
||||
|
||||
roles_display.short_description = "Roles"
|
||||
|
||||
def headquarters_location(self, obj):
|
||||
"""Display headquarters location if available"""
|
||||
if hasattr(obj, "headquarters"):
|
||||
return obj.headquarters.location_display
|
||||
return "No headquarters"
|
||||
|
||||
headquarters_location.short_description = "Headquarters"
|
||||
|
||||
|
||||
# Register the models with their admin classes
|
||||
admin.site.register(Park, ParkAdmin)
|
||||
admin.site.register(ParkArea, ParkAreaAdmin)
|
||||
admin.site.register(ParkLocation, ParkLocationAdmin)
|
||||
admin.site.register(Company, CompanyAdmin)
|
||||
admin.site.register(CompanyHeadquarters, CompanyHeadquartersAdmin)
|
||||
Reference in New Issue
Block a user