From d0ae884f696e47279abec142a11e83b2e9715e0e Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Tue, 30 Jul 2024 19:54:09 +0800 Subject: [PATCH] fix save pdf --- api/directions/views.py | 2 +- ftp_orders/main.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/directions/views.py b/api/directions/views.py index cb6c87f58d..864510f05a 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -4429,7 +4429,7 @@ def file_log(request): rows.append( { 'pk': row.pk, - 'author': row.who_add_files.get_fio(), + 'author': row.who_add_files.get_fio() if row.who_add_files else "-", 'createdAt': strfdatetime(row.created_at, "%d.%m.%Y %X"), 'file': row.uploaded_file.url if row.uploaded_file else None, 'fileName': os.path.basename(row.uploaded_file.name) if row.uploaded_file else None, diff --git a/ftp_orders/main.py b/ftp_orders/main.py index 34300b980e..c5ce85fc22 100644 --- a/ftp_orders/main.py +++ b/ftp_orders/main.py @@ -421,7 +421,7 @@ def pull_result(self, file: str): for obx in obxes: tmp_fractions = fractions.copy() - if (obx.OBX.obx_3.obx_3_1.value).lower == "pdf": + if (obx.OBX.obx_3.obx_3_1.value).lower() == "pdf": 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)) @@ -430,6 +430,7 @@ def pull_result(self, file: str): 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" iss_file.save() @@ -465,6 +466,7 @@ def pull_result(self, file: str): self.copy_file(file, iss.napravleniye.hospital.result_push_by_numbers) self.copy_file(file, FTP_PATH_TO_SAVE) self.delete_file(file) + return if is_confirm: iss.lab_comment = "" iss.time_confirmation = datetime.datetime.strptime(date_time_confirm, "%Y%m%d%H%M%S")