Report filed with Download: the PDF declares no language and is always left to right #568
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#568
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, by comparing how the report's draft and its filed copy are rendered, and pressing Download in the test client for profiles in Arabic, Hebrew and French.Related to #340.
Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now atapplications/views.py:1208(the draft rendered with the request); the errand and the template are where they were.Pressing Download files the report through the
report_pdferrand, which rendersreport_print.htmlwithrender_to_stringand no request. The template's root element readsLANGUAGE_CODEandLANGUAGE_BIDI, which come from the i18n context processor, and context processors run only for a request. So every filed report starts<html lang="" dir="ltr">, with or without a worker. WeasyPrint takes the PDF's language and its line direction from that element. The draft thatGETserves is rendered withrender(request, …)and is right, so the copy filed under Sent documents differs from the one the person previewed.applications/slow.py:32-38(render_a_report) and the comment above the call, which says "the print template asks for nothing a request carries";templates/applications/report_print.html:20; compareapplications/views.py:1168, which renders the draft with the request.margin-inline-*rules land on the wrong side, and it declares no language. In every other language the filed report carries no document language either. Tried withprofile.languageset toar,heandfr-fr: the active language inside the errand was correct each time, and the root element was<html lang="" dir="ltr">each time.report_print.html:16-18promises a report "written in Arabic or Hebrew lays out from the other edge", and the filed copy does not.document_language(translation.get_language()) anddocument_direction(core.languages.direction(...)) in the context, from both the errand and the view. Havereport_print.htmlread those rather thanLANGUAGE_CODE/LANGUAGE_BIDI, asbase_letter.html:7does. Correct the comment inslow.py.Done when
tests/test_reports.py: a report filed through thereport_pdferrand for a Hebrew profile starts<html lang="he" dir="rtl">, and one for a French profile starts<html lang="fr-fr" dir="ltr">. The existing tests at:555-575render the template without a request and never look at either attribute.