46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
from django.shortcuts import get_object_or_404, render
|
|
|
|
from .models import AgentAuditLog, NotificationRecord
|
|
from apps.chat.models import Conversation
|
|
from .services import (
|
|
build_detail_summary,
|
|
build_history_list_context,
|
|
normalize_conversation_node_results,
|
|
)
|
|
|
|
|
|
def log_list(request):
|
|
# 处理历史页支持按批次、产品和状态筛选。
|
|
context = build_history_list_context(
|
|
scenario_id=(request.GET.get("scenario_id") or "").strip(),
|
|
keyword=(request.GET.get("keyword") or "").strip(),
|
|
notify_status=(request.GET.get("notify_status") or "").strip(),
|
|
risk_status=(request.GET.get("risk_status") or "").strip(),
|
|
)
|
|
return render(request, "audit/log_list.html", context)
|
|
|
|
|
|
def log_detail(request, log_id: int):
|
|
# 详情页只负责按主键加载审计快照并渲染;
|
|
# 所有脱敏和字段映射都应在服务层完成。
|
|
audit_log = get_object_or_404(AgentAuditLog, pk=log_id)
|
|
notifications = NotificationRecord.objects.filter(
|
|
conversation_id=audit_log.conversation_id,
|
|
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,
|
|
"conversation_node_results": normalize_conversation_node_results(
|
|
conversation.node_results if conversation else []
|
|
),
|
|
"detail_summary": detail_summary,
|
|
},
|
|
)
|