from django.contrib import admin

from .models import ExportedDocument, UploadedDocument


@admin.register(UploadedDocument)
class UploadedDocumentAdmin(admin.ModelAdmin):
    """管理上传文档及其入库状态，便于后台排查问题。"""
    list_display = ("id", "original_name", "scenario_id", "file_type", "status", "created_at")
    list_filter = ("status", "scenario_id", "file_type")
    search_fields = ("original_name", "scenario_id")


@admin.register(ExportedDocument)
class ExportedDocumentAdmin(admin.ModelAdmin):
    """管理导出记录，便于按批次、会话和产品回看导出产物。"""
    list_display = (
        "id",
        "file_name",
        "batch",
        "conversation_id",
        "product_name",
        "export_mode",
        "created_at",
    )
    list_filter = ("export_mode", "output_type", "template_name")
    search_fields = ("file_name", "batch__batch_id", "conversation_id", "product_name")
