From e7e3202714e9f929b9236966dd48fc8f45df22ee Mon Sep 17 00:00:00 2001 From: bruce Date: Thu, 4 Jun 2026 01:32:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=8C=89=E9=A3=8E=E9=99=A9=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audit/services.py | 1 + apps/audit/views.py | 9 +++++++++ templates/audit/log_list.html | 13 +++++++++++- tests/test_audit.py | 38 +++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/apps/audit/services.py b/apps/audit/services.py index 93b4ed4..fcabe6d 100644 --- a/apps/audit/services.py +++ b/apps/audit/services.py @@ -117,6 +117,7 @@ def build_history_rows(logs) -> list[dict]: or structured_output.get("risk_level") or "-", "notify_status": notification.message_status if notification else "-", + "notify_reason": notification.notify_reason if notification else "-", } ) return rows diff --git a/apps/audit/views.py b/apps/audit/views.py index 294ff1e..1f23da8 100644 --- a/apps/audit/views.py +++ b/apps/audit/views.py @@ -10,6 +10,7 @@ def log_list(request): 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() logs = AgentAuditLog.objects.all() if scenario_id: logs = logs.filter(scenario_id=scenario_id) @@ -27,6 +28,13 @@ def log_list(request): for log in logs if (log.batch_id, log.conversation_id) in matched_pairs ] + if risk_status: + logs = [ + log + for log in logs + if (log.structured_output or {}).get("highest_risk_level") == risk_status + or (log.structured_output or {}).get("risk_level") == risk_status + ] return render( request, "audit/log_list.html", @@ -35,6 +43,7 @@ def log_list(request): "selected_scenario_id": scenario_id, "keyword": keyword, "notify_status": notify_status, + "risk_status": risk_status, }, ) diff --git a/templates/audit/log_list.html b/templates/audit/log_list.html index ecdbda6..db3cdb2 100644 --- a/templates/audit/log_list.html +++ b/templates/audit/log_list.html @@ -21,6 +21,15 @@ +
+ + +