from django.contrib import admin
from .models import AuditLog


@admin.register(AuditLog)
class AuditLogAdmin(admin.ModelAdmin):
    list_display = (
        "created_at",
        "actor",
        "action",
        "app_label",
        "model_name",
        "object_id",
    )
    list_filter = ("action", "app_label", "model_name", "created_at")
    search_fields = ("object_id", "object_repr", "actor__username")
    readonly_fields = (
        "created_at",
        "actor",
        "action",
        "app_label",
        "model_name",
        "object_id",
        "object_repr",
        "old_values",
        "new_values",
        "changes",
        "metadata",
    )

    def has_add_permission(self, request):
        return False

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