"""
Notifications admin configuration.
"""

from django.contrib import admin

from .models import NotificationLog, NotificationPreference, Subscriber, SystemAnnouncement


@admin.register(Subscriber)
class SubscriberAdmin(admin.ModelAdmin):
    list_display = ["user", "novu_subscriber_id", "email", "created_at"]
    search_fields = ["user__username", "novu_subscriber_id", "email"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(NotificationPreference)
class NotificationPreferenceAdmin(admin.ModelAdmin):
    list_display = ["user", "is_opted_out", "updated_at"]
    list_filter = ["is_opted_out"]
    search_fields = ["user__username"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(NotificationLog)
class NotificationLogAdmin(admin.ModelAdmin):
    list_display = ["workflow_id", "user", "channel", "status", "created_at"]
    list_filter = ["status", "channel", "workflow_id"]
    search_fields = ["user__username", "workflow_id", "novu_transaction_id"]
    readonly_fields = ["created_at", "updated_at"]


@admin.register(SystemAnnouncement)
class SystemAnnouncementAdmin(admin.ModelAdmin):
    list_display = ["title", "severity", "is_active", "created_by", "created_at"]
    list_filter = ["severity", "is_active"]
    search_fields = ["title", "message"]
    readonly_fields = ["created_at"]
