From 8ed520277d48bf8b3f3d29a7fc76bef505634a0c Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Fri, 26 Jul 2024 20:59:10 +0800 Subject: [PATCH] fix upload files --- ftp_orders/main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ftp_orders/main.py b/ftp_orders/main.py index 982e71c692..12ae43c450 100644 --- a/ftp_orders/main.py +++ b/ftp_orders/main.py @@ -424,6 +424,10 @@ def pull_result(self, file: str): pdf_base_64 = obx.OBX.obx_5.obx_5_5.value base64_bytes = pdf_base_64.encode('utf-8') data = ContentFile(base64.b64decode(base64_bytes)) + if IssledovaniyaFiles.objects.filter(issledovaniye=iss).exists(): + iss_files = IssledovaniyaFiles.objects.filter(issledovaniye=iss) + for iss_file in iss_files: + iss_file.delete() iss_file = IssledovaniyaFiles(issledovaniye=iss, uploaded_file=data) file_name_internal_code = internal_code.replace(".", "_") iss_file.uploaded_file.name = f"{tube_number}_{file_name_internal_code}.pdf"