"""Django admin registration for ECP Auth models."""

from django.contrib import admin

from ecp_auth.models import UserCertificate


@admin.register(UserCertificate)
class UserCertificateAdmin(admin.ModelAdmin):
    """Admin interface for managing user certificates.

    Attributes:
        list_display: Fields shown in the list view.
        list_filter: Fields available for filtering.
        search_fields: Fields available for searching.
        readonly_fields: Fields that cannot be edited.
    """

    list_display: tuple[str, ...] = (
        "user",
        "common_name",
        "organization",
        "fingerprint_sha256",
        "is_active",
        "not_valid_after",
        "created_at",
    )

    list_filter: tuple[str, ...] = (
        "is_active",
        "organization",
        "created_at",
    )

    search_fields: tuple[str, ...] = (
        "user__username",
        "common_name",
        "organization",
        "fingerprint_sha256",
        "subject_dn",
    )

    readonly_fields: tuple[str, ...] = (
        "fingerprint_sha256",
        "subject_dn",
        "issuer_dn",
        "serial_number",
        "certificate_pem",
        "created_at",
        "updated_at",
    )

    list_per_page: int = 25
