Skip to content

Commit 7f96e60

Browse files
committed
chore: update export_zip to include knowledge name in filename
--bug=1061385 --user=刘瑞斌 【知识库】导出的知识库名字都为archive https://www.tapd.cn/62980211/s/1768251
1 parent 56e11d9 commit 7f96e60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apps/knowledge/serializers/knowledge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ def export_excel(self, with_valid=True):
453453
def export_zip(self, with_valid=True):
454454
if with_valid:
455455
self.is_valid(raise_exception=True)
456+
knowledge = QuerySet(Knowledge).filter(id=self.data.get("knowledge_id")).first()
456457
document_list = QuerySet(Document).filter(knowledge_id=self.data.get('knowledge_id'))
457458
paragraph_list = native_search(
458459
QuerySet(Paragraph).filter(knowledge_id=self.data.get("knowledge_id")),
@@ -472,7 +473,7 @@ def export_zip(self, with_valid=True):
472473

473474
workbook = DocumentSerializers.Operate.get_workbook(data_dict, document_dict)
474475
response = HttpResponse(content_type='application/zip')
475-
response['Content-Disposition'] = 'attachment; filename="archive.zip"'
476+
response['Content-Disposition'] = f'attachment; filename="{knowledge.name}.zip"'
476477
zip_buffer = io.BytesIO()
477478
with TemporaryDirectory() as tempdir:
478479
knowledge_file = os.path.join(tempdir, 'knowledge.xlsx')

0 commit comments

Comments
 (0)