feat(regulatory-info-package): 增加材料包数据模型

This commit is contained in:
2026-06-10 19:49:25 +08:00
parent a060c23ba7
commit f0286264e2
3 changed files with 592 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ from review_agent.models import (
ExportedSummaryFile,
FileAttachment,
Message,
RegulatoryInfoPackageBatch,
RegulatoryReviewBatch,
)
from review_agent.models import FileSummaryBatch, WorkflowEvent
@@ -304,14 +305,20 @@ def export_download(request, export_id: int):
extra={"export_id": exported.pk, "storage_path": exported.storage_path},
)
return JsonResponse({"error": "文件不存在。"}, status=404)
suffix = Path(exported.file_name).suffix.lower()
content_types = {
ExportedSummaryFile.ExportType.MARKDOWN: "text/markdown; charset=utf-8",
ExportedSummaryFile.ExportType.EXCEL: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
ExportedSummaryFile.ExportType.JSON: "application/json; charset=utf-8",
ExportedSummaryFile.ExportType.WORD: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
ExportedSummaryFile.ExportType.PDF: "application/pdf",
ExportedSummaryFile.ExportType.ZIP: "application/zip",
}
content_type = content_types.get(exported.export_type, "application/octet-stream")
if exported.export_type == ExportedSummaryFile.ExportType.WORD and suffix == ".doc":
content_type = "application/msword"
elif exported.export_type == ExportedSummaryFile.ExportType.WORD and suffix == ".docx":
content_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
logger.info(
"Export download started",
extra={
@@ -342,6 +349,17 @@ def _export_for_user(user, export_id: int) -> ExportedSummaryFile | None:
is_deleted=False,
).exists()
return exported if allowed else None
if exported.workflow_type == "regulatory_info_package":
if not exported.workflow_batch_id:
return None
allowed = RegulatoryInfoPackageBatch.objects.filter(
pk=exported.workflow_batch_id,
conversation__user=user,
is_deleted=False,
).exists()
return exported if allowed else None
if exported.batch_id is None:
return None
if exported.batch.user_id != user.pk:
return None
return exported