Skip to content

Fix exhibit TOC page numbering - #1092

Open
nonprofittechy wants to merge 2 commits into
mainfrom
884-toc-numbering-troubleshooting
Open

Fix exhibit TOC page numbering#1092
nonprofittechy wants to merge 2 commits into
mainfrom
884-toc-numbering-troubleshooting

Conversation

@nonprofittechy

Copy link
Copy Markdown
Member

Fixes #884.

Root cause

ALExhibitList._update_page_numbers() already includes every preceding exhibit cover in each exhibit's start_page. The TOC template then added loop.index, counting those covers a second time. That produced the reported increasing error: 3, 6, 9 instead of the physical content pages 3, 5, 7.

The no-cover expression also counted the default one-page TOC twice.

What changed

  • Add ALExhibit.toc_page_number() as the single, documented calculation for the first uploaded page.
  • Have the DOCX TOC template call that method for cover and no-cover output.
  • Add regression tests for:
    • one cover per exhibit
    • cover pages disabled
    • a multi-page TOC

Before and after

Both screenshots come from the same local reproduction: three separate one-page exhibits assembled with a one-page TOC and one cover per exhibit.

Before: incorrect cumulative offset After: physical start pages
Before fix: TOC lists pages 3, 6, and 9 After fix: TOC lists pages 3, 5, and 7

Local validation

Installed each build into the localhost docassemble server with:

~/venv/bin/dainstall --server localhost .

Generated PDFs at http://localhost and extracted their TOC text:

  • 3 one-page exhibits, covers enabled, 1-page TOC: 7-page PDF; starts 3, 5, 7
  • 3 one-page exhibits, covers disabled, 1-page TOC: 4-page PDF; starts 2, 3, 4
  • 28 one-page exhibits, covers enabled, 2-page TOC: 58-page PDF; starts 4, 6, …, 58

Additional checks:

  • black --check docassemble/AssemblyLine/al_document.py docassemble/AssemblyLine/test_al_document.py
  • changed-module mypy check
  • git diff --check
  • DOCX ZIP integrity check
  • uv build --out-dir /tmp/issue884-dist

The repository-wide mypy run still reports four unrelated existing errors in language.py, al_general.py, and sessions.py; the changed module passes independently.

@nonprofittechy
nonprofittechy marked this pull request as ready for review August 17, 2026 19:40
@nonprofittechy

Copy link
Copy Markdown
Member Author

@rajeswari1301 this is not urgent at all (a very old correctness issue for a lightly used feature), but review if you can some day this week?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exhibit upload tool - TOC page numbering error

1 participant