feat: 增强处理历史导出记录摘要展示
This commit is contained in:
@@ -151,6 +151,7 @@ def build_detail_summary(log: AgentAuditLog, conversation, notifications) -> dic
|
||||
详情页模板只负责展示,字段拼装与优先级判断统一放在服务层。
|
||||
"""
|
||||
structured_output = log.structured_output or {}
|
||||
output_file = structured_output.get("output_file") or {}
|
||||
export_node = None
|
||||
if conversation and conversation.node_results:
|
||||
export_node = next(
|
||||
@@ -161,6 +162,13 @@ def build_detail_summary(log: AgentAuditLog, conversation, notifications) -> dic
|
||||
return {
|
||||
"export_status": structured_output.get("export_status") or (export_node or {}).get("status", "-"),
|
||||
"download_url": structured_output.get("download_url", ""),
|
||||
"output_file_name": output_file.get("file_name", ""),
|
||||
"output_file_relative_path": output_file.get("relative_path", ""),
|
||||
"export_mode": output_file.get("export_mode", ""),
|
||||
"template_name": structured_output.get("template_name", ""),
|
||||
"template_version": structured_output.get("template_version", ""),
|
||||
"draft_export_status": structured_output.get("draft_export_status", ""),
|
||||
"formal_export_status": structured_output.get("formal_export_status", ""),
|
||||
"blocked_items": structured_output.get("blocked_items") or [],
|
||||
"notification_receipt": latest_notification.receipt if latest_notification else {},
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@
|
||||
<h2 class="section-title">导出状态摘要</h2>
|
||||
<ul class="detail-list">
|
||||
<li class="detail-item"><strong>导出状态</strong><div>{{ detail_summary.export_status|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>输出文件名</strong><div>{{ detail_summary.output_file_name|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>导出模式</strong><div>{{ detail_summary.export_mode|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>模板名称</strong><div>{{ detail_summary.template_name|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>模板版本</strong><div>{{ detail_summary.template_version|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>草稿导出状态</strong><div>{{ detail_summary.draft_export_status|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>正式导出状态</strong><div>{{ detail_summary.formal_export_status|default:"-" }}</div></li>
|
||||
<li class="detail-item"><strong>下载地址</strong><div>{{ detail_summary.download_url|default:"-" }}</div></li>
|
||||
<li class="detail-item">
|
||||
<strong>阻断项</strong>
|
||||
|
||||
@@ -451,3 +451,51 @@ def test_audit_detail_page_shows_export_summary_and_notification_receipt(client,
|
||||
assert "风险项未清零" in content
|
||||
assert "通知回执" in content
|
||||
assert "msg-9" in content
|
||||
|
||||
|
||||
def test_audit_detail_page_shows_export_file_name_and_mode(client, db):
|
||||
Conversation.objects.create(
|
||||
conversation_id="conv-003",
|
||||
title="产品C",
|
||||
product_name="产品C",
|
||||
batch_id="SUB-20260604-003",
|
||||
task_status="success",
|
||||
node_results=[
|
||||
{"label": "Word 回填导出", "status": "待复核"},
|
||||
{"label": "飞书通知", "status": "已完成"},
|
||||
],
|
||||
)
|
||||
log = create_audit_log(
|
||||
"document_review",
|
||||
"Word 回填导出",
|
||||
"导出任务",
|
||||
AgentResult(
|
||||
answer="已生成导出草稿",
|
||||
status="success",
|
||||
structured_output={
|
||||
"export_status": "draft_only",
|
||||
"template_name": "注册证导出模板",
|
||||
"template_version": "V1.0",
|
||||
"download_url": "/media/exports/20260604/SUB-20260604-003-draft.docx",
|
||||
"output_file": {
|
||||
"file_name": "SUB-20260604-003-draft.docx",
|
||||
"relative_path": "exports/20260604/SUB-20260604-003-draft.docx",
|
||||
"export_mode": "draft",
|
||||
},
|
||||
},
|
||||
),
|
||||
batch_id="SUB-20260604-003",
|
||||
conversation_id="conv-003",
|
||||
product_name="产品C",
|
||||
)
|
||||
|
||||
response = client.get(reverse("audit:detail", args=[log.id]))
|
||||
|
||||
content = response.content.decode("utf-8")
|
||||
assert response.status_code == 200
|
||||
assert "输出文件名" in content
|
||||
assert "SUB-20260604-003-draft.docx" in content
|
||||
assert "导出模式" in content
|
||||
assert "draft" in content
|
||||
assert "模板版本" in content
|
||||
assert "V1.0" in content
|
||||
|
||||
Reference in New Issue
Block a user