from django.contrib import admin

from .models import FeishuNotifyConfig, OwnerMapping, WordTemplateMapping


@admin.register(OwnerMapping)
class OwnerMappingAdmin(admin.ModelAdmin):
    list_display = (
        "owner_role",
        "owner_name",
        "department",
        "chapter_scope",
        "risk_scope",
        "feishu_user_id",
        "notify_enabled",
        "is_active",
    )
    list_filter = ("notify_enabled", "is_active", "department")
    search_fields = ("owner_role", "owner_name", "department", "chapter_scope", "risk_scope")


@admin.register(FeishuNotifyConfig)
class FeishuNotifyConfigAdmin(admin.ModelAdmin):
    list_display = ("config_name", "notify_reason", "channel", "status", "is_active")
    list_filter = ("notify_reason", "status", "is_active")
    search_fields = ("config_name", "channel", "message_template")


@admin.register(WordTemplateMapping)
class WordTemplateMappingAdmin(admin.ModelAdmin):
    list_display = (
        "template_name",
        "output_type",
        "version",
        "placeholder_count",
        "status",
        "is_active",
    )
    list_filter = ("output_type", "status", "is_active")
    search_fields = ("template_name", "version", "field_mapping_summary")
