feat: 新增pdf 删除

This commit is contained in:
zty 2024-07-08 18:36:13 +08:00
parent bbca1a5114
commit 619c2ea989
1 changed files with 5 additions and 4 deletions

View File

@ -372,11 +372,12 @@ class ParsePdfViewSet(RbacFilterSet, CreateUpdateCustomMixin, ModelViewSet):
if self.get_object().status == "执行中": if self.get_object().status == "执行中":
return Response({'message': '执行中的数据不能删除'}, status=status.HTTP_400_BAD_REQUEST) return Response({'message': '执行中的数据不能删除'}, status=status.HTTP_400_BAD_REQUEST)
# 删除文件 # 删除文件
file_path = os.path.join(settings.BASE_DIR, self.get_object().parse_excel) path = "/home/testsearchadmin/cma_search/server"
if os.path.exists(file_path): file_path = path + self.get_object().excel_path
if os.path.isfile(file_path):
os.remove(file_path) os.remove(file_path)
pdf_path = os.path.join(settings.BASE_DIR, self.get_object().pdf_path) pdf_path = path + self.get_object().pdf_path
if os.path.exists(pdf_path): if os.path.isfile(pdf_path):
os.remove(pdf_path) os.remove(pdf_path)
# 删除数据库记录 # 删除数据库记录