feat: 增强处理历史详情导出与通知回执展示
This commit is contained in:
@@ -142,3 +142,25 @@ def build_history_rows(logs) -> list[dict]:
|
||||
}
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def build_detail_summary(log: AgentAuditLog, conversation, notifications) -> dict:
|
||||
"""
|
||||
组装处理历史详情页的导出摘要与通知回执信息。
|
||||
|
||||
详情页模板只负责展示,字段拼装与优先级判断统一放在服务层。
|
||||
"""
|
||||
structured_output = log.structured_output or {}
|
||||
export_node = None
|
||||
if conversation and conversation.node_results:
|
||||
export_node = next(
|
||||
(node for node in conversation.node_results if node.get("label") == "Word 回填导出"),
|
||||
None,
|
||||
)
|
||||
latest_notification = notifications.first() if hasattr(notifications, "first") else None
|
||||
return {
|
||||
"export_status": structured_output.get("export_status") or (export_node or {}).get("status", "-"),
|
||||
"download_url": structured_output.get("download_url", ""),
|
||||
"blocked_items": structured_output.get("blocked_items") or [],
|
||||
"notification_receipt": latest_notification.receipt if latest_notification else {},
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, render
|
||||
|
||||
from .models import AgentAuditLog, NotificationRecord
|
||||
from apps.chat.models import Conversation
|
||||
from .services import build_history_rows
|
||||
from .services import build_detail_summary, build_history_rows
|
||||
|
||||
|
||||
def log_list(request):
|
||||
@@ -57,8 +57,14 @@ def log_detail(request, log_id: int):
|
||||
batch_id=audit_log.batch_id,
|
||||
)
|
||||
conversation = Conversation.objects.filter(conversation_id=audit_log.conversation_id).first()
|
||||
detail_summary = build_detail_summary(audit_log, conversation, notifications)
|
||||
return render(
|
||||
request,
|
||||
"audit/log_detail.html",
|
||||
{"log": audit_log, "notifications": notifications, "conversation": conversation},
|
||||
{
|
||||
"log": audit_log,
|
||||
"notifications": notifications,
|
||||
"conversation": conversation,
|
||||
"detail_summary": detail_summary,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user