Export and import: the files sent with an application and a sent document's \"sent to\" line are lost #469

Closed
opened 2026-10-01 10:46:55 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing the models' fields with what core/export.py writes and running an export-and-import round trip.

Checked again on 2026-10-01 against main at 0a5cad587: still present. The code is now at documents/models.py:638-644 (sent_to), documents/models.py:745-753 (went_with_an_application) and documents/rendering.py:563-565 (exported_on_its_own); core/export.py, core/importer.py and applications/models.py have not moved.

Two parts of the record of what was sent do not travel in the archive, although the export's docstring promises every record and the wiki promises every document you sent:

  • Application.sent_uploads ("Files you already had, as opposed to documents Postulo rendered", applications/models.py:411-417) is never written. The archive carries sent_link_ids for the sibling many-to-many (core/export.py:704, read back at core/importer.py:671-678) and nothing for the files.

  • RenderedDocument.sent_to (documents/models.py:610-616) is not in SENT_FIELDS (core/export.py:285-293). The model keeps it as text precisely so that a sent PDF can still be placed after its application is deleted.

  • Where: core/export.py:704 and :285-293 in build_document; core/importer.py:635 and :671-678 and :864-889 in load.

  • What happens: a round trip of an application with one sent upload came back with sent_uploads.count() == 0. A sent document whose application had been deleted, with sent_to "Research Engineer at Black Mesa", came back with sent_to == "", and went_with_an_application (documents/models.py:717-725) turned from true to false: the restored PDF now counts as a CV exported on its own (documents/rendering.py:589-591, exported_on_its_own) rather than one an employer received.

  • Why it matters: after moving or restoring an account, every application forgets which portfolio or transcript went with it, and every sent PDF whose application was tidied away loses the only words saying where it went and is filed as a draft export.

  • Fix: write "sent_upload_ids": [u.pk for u in application.sent_uploads.all()] (prefetched with the applications) and resolve it on import once the uploads exist, as pending_supersedes does. Add sent_to to SENT_FIELDS. Bump FORMAT_VERSION (now 25) and keep reading older archives, where both are absent.

Done when

  • The round trip in tests/test_export.py covers an application with a sent upload and a sent document with sent_to and no application, and asserts both come back unchanged.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, comparing the models' fields with what `core/export.py` writes and running an export-and-import round trip. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The code is now at `documents/models.py:638-644` (`sent_to`), `documents/models.py:745-753` (`went_with_an_application`) and `documents/rendering.py:563-565` (`exported_on_its_own`); `core/export.py`, `core/importer.py` and `applications/models.py` have not moved. Two parts of the record of what was sent do not travel in the archive, although the export's docstring promises every record and the wiki promises every document you sent: - `Application.sent_uploads` ("Files you already had, as opposed to documents Postulo rendered", `applications/models.py:411-417`) is never written. The archive carries `sent_link_ids` for the sibling many-to-many (`core/export.py:704`, read back at `core/importer.py:671-678`) and nothing for the files. - `RenderedDocument.sent_to` (`documents/models.py:610-616`) is not in `SENT_FIELDS` (`core/export.py:285-293`). The model keeps it as text precisely so that a sent PDF can still be placed after its application is deleted. - **Where:** `core/export.py:704` and `:285-293` in `build_document`; `core/importer.py:635` and `:671-678` and `:864-889` in `load`. - **What happens:** a round trip of an application with one sent upload came back with `sent_uploads.count() == 0`. A sent document whose application had been deleted, with `sent_to` "Research Engineer at Black Mesa", came back with `sent_to == ""`, and `went_with_an_application` (`documents/models.py:717-725`) turned from true to false: the restored PDF now counts as a CV exported on its own (`documents/rendering.py:589-591`, `exported_on_its_own`) rather than one an employer received. - **Why it matters:** after moving or restoring an account, every application forgets which portfolio or transcript went with it, and every sent PDF whose application was tidied away loses the only words saying where it went and is filed as a draft export. - **Fix:** write `"sent_upload_ids": [u.pk for u in application.sent_uploads.all()]` (prefetched with the applications) and resolve it on import once the uploads exist, as `pending_supersedes` does. Add `sent_to` to `SENT_FIELDS`. Bump `FORMAT_VERSION` (now 25) and keep reading older archives, where both are absent. ## Done when - The round trip in `tests/test_export.py` covers an application with a sent upload and a sent document with `sent_to` and no application, and asserts both come back unchanged.
tiagoagueda added this to the 0.5.0 milestone 2026-10-01 10:46:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#469
No description provided.