from django.contrib import admin

# Register your models here.
from . models import Papers, OpenAIDiagnose

from django.urls import reverse
from django.utils.html import format_html

@admin.register(Papers)
class PaperAdmin(admin.ModelAdmin):
    list_display = ('user', 'uuid', 'status', 'created_at', 'updated_at')

@admin.register(OpenAIDiagnose)
class OpenAIDiagnoseAdmin(admin.ModelAdmin):
    list_display = ('user', 'uuid', 'status', 'diagnose_type', 'created_at', 'updated_at', 'custom_link')

    def custom_link(self, obj):
        # 为每个用户添加自定义链接
        url = reverse('dia_report', args=[obj.pk])  # 生成链接
        return format_html('<a href="{}">查看</a>', url)  # 创建 HTML 链接

    custom_link.short_description = '详细信息'  # 设置列标题