fix(file-summary): 修复删除对话时受保护批次阻塞

This commit is contained in:
2026-06-09 08:22:45 +08:00
parent 2b5093040d
commit 18548eb78f
2 changed files with 47 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
from django.contrib.auth.decorators import login_required
from django.db import transaction
from django.db.models import Count, Q
import json
import logging
@@ -7,7 +8,14 @@ from pathlib import Path
from django.http import FileResponse, Http404, JsonResponse
from django.views.decorators.http import require_http_methods
from review_agent.models import ApplicationFormFillBatch, Conversation, ExportedSummaryFile, FileAttachment, Message
from review_agent.models import (
ApplicationFormFillBatch,
Conversation,
ExportedSummaryFile,
FileAttachment,
Message,
RegulatoryReviewBatch,
)
from review_agent.models import FileSummaryBatch, WorkflowEvent
from review_agent.notifications.presenter import serialize_notification_records
from .events import serialize_event
@@ -152,7 +160,10 @@ def conversation_list(request):
@login_required
def conversation_detail(request, conversation_id: int):
conversation = _conversation_for_user(request.user, conversation_id)
conversation.delete()
with transaction.atomic():
ApplicationFormFillBatch.objects.filter(conversation=conversation).delete()
RegulatoryReviewBatch.objects.filter(conversation=conversation).delete()
conversation.delete()
return JsonResponse({"ok": True, "conversation_id": conversation_id})