mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-22 09:31:08 -05:00
chore: fix pghistory migration deps and improve htmx utilities
- Update pghistory dependency from 0007 to 0006 in account migrations - Add docstrings and remove unused imports in htmx_forms.py - Add DJANGO_SETTINGS_MODULE bash commands to Claude settings - Add state transition definitions for ride statuses
This commit is contained in:
@@ -3,6 +3,7 @@ from django.contrib.admin import AdminSite
|
||||
from django.utils.html import format_html
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django_fsm_log.models import StateLog
|
||||
from .models import EditSubmission, PhotoSubmission
|
||||
|
||||
|
||||
@@ -163,9 +164,72 @@ class HistoryEventAdmin(admin.ModelAdmin):
|
||||
get_context.short_description = "Context"
|
||||
|
||||
|
||||
class StateLogAdmin(admin.ModelAdmin):
|
||||
"""Admin interface for FSM transition logs."""
|
||||
|
||||
list_display = [
|
||||
'id',
|
||||
'timestamp',
|
||||
'get_model_name',
|
||||
'get_object_link',
|
||||
'state',
|
||||
'transition',
|
||||
'get_user_link',
|
||||
]
|
||||
list_filter = [
|
||||
'content_type',
|
||||
'state',
|
||||
'transition',
|
||||
'timestamp',
|
||||
]
|
||||
search_fields = [
|
||||
'state',
|
||||
'transition',
|
||||
'description',
|
||||
'by__username',
|
||||
]
|
||||
readonly_fields = [
|
||||
'timestamp',
|
||||
'content_type',
|
||||
'object_id',
|
||||
'state',
|
||||
'transition',
|
||||
'by',
|
||||
'description',
|
||||
]
|
||||
date_hierarchy = 'timestamp'
|
||||
ordering = ['-timestamp']
|
||||
|
||||
def get_model_name(self, obj):
|
||||
"""Get the model name from content type."""
|
||||
return obj.content_type.model
|
||||
get_model_name.short_description = 'Model'
|
||||
|
||||
def get_object_link(self, obj):
|
||||
"""Create link to the actual object."""
|
||||
if obj.content_object:
|
||||
# Try to get absolute URL if available
|
||||
if hasattr(obj.content_object, 'get_absolute_url'):
|
||||
url = obj.content_object.get_absolute_url()
|
||||
else:
|
||||
url = '#'
|
||||
return format_html('<a href="{}">{}</a>', url, str(obj.content_object))
|
||||
return f"ID: {obj.object_id}"
|
||||
get_object_link.short_description = 'Object'
|
||||
|
||||
def get_user_link(self, obj):
|
||||
"""Create link to the user who performed the transition."""
|
||||
if obj.by:
|
||||
url = reverse('admin:accounts_user_change', args=[obj.by.id])
|
||||
return format_html('<a href="{}">{}</a>', url, obj.by.username)
|
||||
return '-'
|
||||
get_user_link.short_description = 'User'
|
||||
|
||||
|
||||
# Register with moderation site only
|
||||
moderation_site.register(EditSubmission, EditSubmissionAdmin)
|
||||
moderation_site.register(PhotoSubmission, PhotoSubmissionAdmin)
|
||||
moderation_site.register(StateLog, StateLogAdmin)
|
||||
|
||||
# We will register concrete event models as they are created during migrations
|
||||
# Example: moderation_site.register(DesignerEvent, HistoryEventAdmin)
|
||||
|
||||
Reference in New Issue
Block a user