from django.contrib import admin from review_agent.models import ( FeishuAccessTokenCache, FeishuQuestionLog, FeishuUserMapping, WorkflowNotificationRecord, ) @admin.register(FeishuUserMapping) class FeishuUserMappingAdmin(admin.ModelAdmin): list_display = ( "system_user", "feishu_display_name", "feishu_open_id", "feishu_user_id", "feishu_mobile", "is_active", "updated_at", ) list_filter = ("is_active",) search_fields = ( "system_user__username", "feishu_display_name", "feishu_open_id", "feishu_user_id", "feishu_mobile", ) readonly_fields = ("created_at", "updated_at") @admin.register(FeishuAccessTokenCache) class FeishuAccessTokenCacheAdmin(admin.ModelAdmin): list_display = ("app_id_hash", "expires_at", "updated_at", "has_error") search_fields = ("app_id_hash", "error_message") readonly_fields = ("created_at", "updated_at") @admin.display(boolean=True, description="有错误") def has_error(self, obj: FeishuAccessTokenCache) -> bool: return bool(obj.error_message) @admin.register(WorkflowNotificationRecord) class WorkflowNotificationRecordAdmin(admin.ModelAdmin): list_display = ( "workflow_type", "workflow_batch_no", "workflow_status", "channel", "send_status", "target", "sent_at", "created_at", ) list_filter = ("workflow_type", "channel", "send_status", "workflow_status") search_fields = ("workflow_batch_no", "dedupe_key", "target", "error_message") readonly_fields = ("created_at", "updated_at") @admin.register(FeishuQuestionLog) class FeishuQuestionLogAdmin(admin.ModelAdmin): list_display = ( "system_user", "source_type", "intent", "permission_result", "status", "processed_at", "created_at", ) list_filter = ("source_type", "intent", "permission_result", "status") search_fields = ("system_user__username", "question_text", "answer_summary", "message_id") readonly_fields = ("created_at",)