Skip to content

Commit 3885dc1

Browse files
authored
[Comp-787-3] IR docx formatting space after table (#705)
1 parent c27215f commit 3885dc1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compliance-api/src/compliance_api/services/inspection_record/inspection_record_doc_generator.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def _add_requirement_details_table(doc, req):
413413

414414
# Requirement header and details
415415
source_details = req.get('requirement_source_details', [])
416+
last_description_is_table = False
416417
if source_details:
417418
row = req_table.add_row()
418419
cell = row.cells[0].merge(row.cells[1])
@@ -422,7 +423,7 @@ def _add_requirement_details_table(doc, req):
422423
para.paragraph_format.space_before = Inches(0.04)
423424
para.paragraph_format.space_after = Inches(0.08)
424425

425-
last_description_is_table = False
426+
ends_with_table = False
426427
for idx, source in enumerate(source_details):
427428
# Add requirement header for first source
428429
if idx == 0:
@@ -452,9 +453,11 @@ def _add_requirement_details_table(doc, req):
452453
source["requirement_source_description"],
453454
clear_first=False,
454455
)
456+
ends_with_table = source.get("requirement_source_description", '').strip().endswith('</table>')
455457

456458
# Add req source images
457459
for img in source.get('requirement_source_images', []):
460+
ends_with_table = False
458461
image_url = img.get('image_url')
459462
if image_url:
460463
try:
@@ -487,10 +490,12 @@ def _add_requirement_details_table(doc, req):
487490
# Check if first document has appendix
488491
documents = doc_group.get('documents', [])
489492
if documents and documents[0].get('appendix_no'):
493+
ends_with_table = False
490494
run = para.add_run(f" (Appendix {documents[0].get('appendix_no')})")
491495
para.add_run('\n')
492496

493497
for document in documents:
498+
ends_with_table = False
494499
# Add section info
495500
if document.get('section_number') or document.get('section_title'):
496501
section_para = cell.add_paragraph()
@@ -504,13 +509,15 @@ def _add_requirement_details_table(doc, req):
504509

505510
# Add description
506511
if document.get('description'):
512+
ends_with_table = document.get("description", '').strip().endswith('</table>')
507513
_add_html_to_container(
508514
cell,
509515
document.get('description'),
510516
clear_first=False,
511517
)
512518
# Add document images
513519
for img in document.get('document_images', []):
520+
ends_with_table = False
514521
image_url = img.get('image_url')
515522
if image_url:
516523
try:
@@ -535,8 +542,7 @@ def _add_requirement_details_table(doc, req):
535542
para = cell.add_paragraph()
536543
para = cell.add_paragraph() # New paragraph for next source
537544

538-
# Check if last document description ends with a table
539-
ends_with_table = source.get("requirement_source_description", '').strip().endswith('</table>')
545+
# Check if last description ends with a table
540546
if idx == len(source_details) - 1 and ends_with_table:
541547
last_description_is_table = True
542548

@@ -651,7 +657,7 @@ def generate_inspection_report_docx(preview_data):
651657
logo_para.alignment = WD_ALIGN_PARAGRAPH.LEFT
652658
logo_para.paragraph_format.space_before = Pt(0)
653659
logo_para.paragraph_format.space_after = Pt(0)
654-
logo_para.paragraph_format.left_indent = Inches(-0.15)
660+
logo_para.paragraph_format.left_indent = Inches(-0.10)
655661

656662
logo_run = logo_para.add_run()
657663
logo_path = Path(__file__).parent / "assets" / "EAO_Logo.png"

0 commit comments

Comments
 (0)