mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 14:11:09 -05:00
okay fine
This commit is contained in:
@@ -4,15 +4,20 @@ from simple_history.admin import SimpleHistoryAdmin
|
||||
from .models import Park, ParkArea
|
||||
|
||||
class ParkAdmin(SimpleHistoryAdmin):
|
||||
list_display = ('name', 'location', 'status', 'owner', 'created_at', 'updated_at')
|
||||
list_filter = ('status', 'country', 'region', 'city')
|
||||
search_fields = ('name', 'location', 'description')
|
||||
list_display = ('name', 'formatted_location', 'status', 'owner', 'created_at', 'updated_at')
|
||||
list_filter = ('status',)
|
||||
search_fields = ('name', 'description', 'location__name', 'location__city', 'location__country')
|
||||
readonly_fields = ('created_at', 'updated_at')
|
||||
prepopulated_fields = {'slug': ('name',)}
|
||||
|
||||
def formatted_location(self, obj):
|
||||
"""Display formatted location string"""
|
||||
return obj.formatted_location
|
||||
formatted_location.short_description = 'Location'
|
||||
|
||||
def get_history_list_display(self, request):
|
||||
"""Customize the list display for history records"""
|
||||
return ('name', 'location', 'status', 'history_date', 'history_user')
|
||||
return ('name', 'formatted_location', 'status', 'history_date', 'history_user')
|
||||
|
||||
class ParkAreaAdmin(SimpleHistoryAdmin):
|
||||
list_display = ('name', 'park', 'created_at', 'updated_at')
|
||||
@@ -34,11 +39,16 @@ from simple_history.models import HistoricalRecords
|
||||
from .models import Park
|
||||
|
||||
class HistoricalParkAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'location', 'status', 'history_date', 'history_user', 'history_type')
|
||||
list_filter = ('status', 'country', 'region', 'city', 'history_type')
|
||||
search_fields = ('name', 'location', 'description')
|
||||
list_display = ('name', 'formatted_location', 'status', 'history_date', 'history_user', 'history_type')
|
||||
list_filter = ('status', 'history_type')
|
||||
search_fields = ('name', 'description')
|
||||
readonly_fields = ('history_date', 'history_type', 'history_id')
|
||||
|
||||
def formatted_location(self, obj):
|
||||
"""Display formatted location string"""
|
||||
return obj.instance.formatted_location
|
||||
formatted_location.short_description = 'Location'
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return False # Prevent adding new historical records directly
|
||||
|
||||
|
||||
Reference in New Issue
Block a user