@@ -429,16 +429,20 @@ def export_excel(self, with_valid=True):
429429 if with_valid :
430430 self .is_valid (raise_exception = True )
431431 document_list = QuerySet (Document ).filter (knowledge_id = self .data .get ('knowledge_id' ))
432- paragraph_list = native_search (QuerySet (Paragraph ).filter (knowledge_id = self .data .get ("knowledge_id" )),
433- get_file_content (
434- os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' ,
435- 'list_paragraph_document_name.sql' )))
432+ paragraph_list = native_search (
433+ QuerySet (Paragraph ).filter (knowledge_id = self .data .get ("knowledge_id" )),
434+ get_file_content (
435+ os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_paragraph_document_name.sql' )
436+ )
437+ )
436438 problem_mapping_list = native_search (
437- QuerySet (ProblemParagraphMapping ).filter (knowledge_id = self .data .get ("id" )), get_file_content (
438- os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_problem_mapping.sql' )),
439- with_table_name = True )
440- data_dict , document_dict = DocumentSerializers .Operate .merge_problem (paragraph_list , problem_mapping_list ,
441- document_list )
439+ QuerySet (ProblemParagraphMapping ).filter (knowledge_id = self .data .get ("knowledge_id" )),
440+ get_file_content (os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_problem_mapping.sql' )),
441+ with_table_name = True
442+ )
443+ data_dict , document_dict = DocumentSerializers .Operate .merge_problem (
444+ paragraph_list , problem_mapping_list , document_list
445+ )
442446 workbook = DocumentSerializers .Operate .get_workbook (data_dict , document_dict )
443447 response = HttpResponse (content_type = 'application/vnd.ms-excel' )
444448 response ['Content-Disposition' ] = 'attachment; filename="knowledge.xlsx"'
@@ -449,16 +453,20 @@ def export_zip(self, with_valid=True):
449453 if with_valid :
450454 self .is_valid (raise_exception = True )
451455 document_list = QuerySet (Document ).filter (knowledge_id = self .data .get ('knowledge_id' ))
452- paragraph_list = native_search (QuerySet (Paragraph ).filter (knowledge_id = self .data .get ("knowledge_id" )),
453- get_file_content (
454- os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' ,
455- 'list_paragraph_document_name.sql' )))
456+ paragraph_list = native_search (
457+ QuerySet (Paragraph ).filter (knowledge_id = self .data .get ("knowledge_id" )),
458+ get_file_content (
459+ os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_paragraph_document_name.sql' )
460+ )
461+ )
456462 problem_mapping_list = native_search (
457- QuerySet (ProblemParagraphMapping ).filter (knowledge_id = self .data .get ("id" )), get_file_content (
458- os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_problem_mapping.sql' )),
459- with_table_name = True )
460- data_dict , document_dict = DocumentSerializers .Operate .merge_problem (paragraph_list , problem_mapping_list ,
461- document_list )
463+ QuerySet (ProblemParagraphMapping ).filter (knowledge_id = self .data .get ("knowledge_id" )),
464+ get_file_content (os .path .join (PROJECT_DIR , "apps" , "knowledge" , 'sql' , 'list_problem_mapping.sql' )),
465+ with_table_name = True
466+ )
467+ data_dict , document_dict = DocumentSerializers .Operate .merge_problem (
468+ paragraph_list , problem_mapping_list , document_list
469+ )
462470 res = [parse_image (paragraph .get ('content' )) for paragraph in paragraph_list ]
463471
464472 workbook = DocumentSerializers .Operate .get_workbook (data_dict , document_dict )
0 commit comments