from django.contrib import admin
from ..models import CustomLogEntry  # 导入自定义的代理模型


@admin.register(CustomLogEntry)
class LogEntryAdmin(admin.ModelAdmin):
    list_display = ['action_time', 'user', 'content_type', '__str__']
    readonly_fields = [
        'action_time', 'user', 'content_type', 'object_id', 'object_repr',
        'action_flag', 'change_message'
    ]

    # 设置该模型在Admin中的单数名称（可选，通常会继承模型的verbose_name）
    verbose_name = '操作审计'

    def has_add_permission(self, request):
        return False

    def has_change_permission(self, request, obj=None):
        return False

    def has_delete_permission(self, request, obj=None):
        return False
