first commit

This commit is contained in:
pacnpal
2024-10-28 17:09:57 -04:00
commit 2e1b4d7af7
9993 changed files with 1182741 additions and 0 deletions

34
core/admin.py Normal file
View File

@@ -0,0 +1,34 @@
from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
from django.utils.html import format_html
from .models import SlugHistory
@admin.register(SlugHistory)
class SlugHistoryAdmin(admin.ModelAdmin):
list_display = ['content_object_link', 'old_slug', 'created_at']
list_filter = ['content_type', 'created_at']
search_fields = ['old_slug', 'object_id']
readonly_fields = ['content_type', 'object_id', 'old_slug', 'created_at']
date_hierarchy = 'created_at'
ordering = ['-created_at']
def content_object_link(self, obj):
"""Create a link to the related object's admin page"""
try:
url = obj.content_object.get_absolute_url()
return format_html(
'<a href="{}">{}</a>',
url,
str(obj.content_object)
)
except (AttributeError, ValueError):
return str(obj.content_object)
content_object_link.short_description = 'Object'
def has_add_permission(self, request):
"""Disable manual creation of slug history records"""
return False
def has_change_permission(self, request, obj=None):
"""Disable editing of slug history records"""
return False