Store original uploaded filename (admin-only) for talks/posters/pubs (#1391)#1400
Merged
Merged
Conversation
…1391) Artifact.save() renames uploaded files to the standardized Author_TitleInTitleCase_VenueYear scheme, destroying the human-recognizable upload name (e.g. MyTalk_v3_final.pptx). Capture that name into two new admin-only fields and surface it read-only on the change form, as a provenance breadcrumb for confirming/debugging uploads. - Artifact (abstract base): add nullable, editable=False original_pdf_filename and original_raw_filename. Capture block at the top of save() snapshots the basename ONLY on a genuine new upload — the first save, or an edit where the file field is in the incoming update_fields (before the rename logic appends to it). It deliberately does not fire on the m2m authors_changed rename re-save or on metadata-only edits, so a standardized name never clobbers a stored original. - ArtifactAdmin: read-only "Originally uploaded as" display injected into the Files fieldset on the change form (inherited by Talk/Poster/Publication). - backfill_original_filenames management command: production has many bulk-imported rows whose files were never renamed (their on-disk name still IS the original). Recover those: if a file's basename != generate_filename() (and isn't a "-<timestamp>" uniquified variant of it), record the current basename as the original. Idempotent (fills nulls only); wired into docker-entrypoint.sh so it runs at container start before any admin edit can rename a legacy row and lose its original name. - Tests: capture-survives-rename, edit-replace, metadata-only-no-clobber, backfill recover/skip/idempotent/uniquified, admin display. No committed migration (matches repo convention): settings_test builds from models and prod/test run makemigrations website at container start. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jonfroehlich
added a commit
that referenced
this pull request
Jun 25, 2026
Triggers a fresh -test build that includes #1400 (the prior merge did not re-fire the deploy webhook) and preps the prod release. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1391.
What & why
Artifact.save()renames uploaded files to the standardizedAuthor_TitleInTitleCase_VenueYearscheme, destroying the one human-recognizable clue in the upload name (e.g.MyTalk_v3_final.pptx). This stores that original name in two new admin-only fields and surfaces it read-only on the change form as a provenance breadcrumb.Changes
Artifact(abstract base): add nullable,editable=Falseoriginal_pdf_filename/original_raw_filename. A capture block at the top ofsave()snapshots the basename only on a genuine new upload — the first save, or an edit where the file field is in the incomingupdate_fields(before the rename logic appends to it). It does not fire on the m2mauthors_changedrename re-save or on metadata-only edits, so a standardized name never clobbers a stored original.ArtifactAdmin: read-only "Originally uploaded as" row injected into the Files fieldset on the change form (inherited by Talk/Poster/Publication).backfill_original_filenamescommand (new): recovers originals for the many bulk-imported prod rows whose files were never renamed (their on-disk name still is the original). If a file's basename ≠generate_filename()and isn't a-<timestamp>uniquified variant of it, the current basename is recorded as the original. Idempotent (fills nulls only); wired intodocker-entrypoint.sh(step 4.7b).Why the backfill matters / ordering
Investigating the prod dump: the unrenamed files are genuine originals (title-derived names + Django's
_xxxxxxxcollision suffix) from rows that never went through an authoredsave(); the historical rename one-shots are commented out of the entrypoint. Latent risk: editing any legacy row in admin (even metadata) triggers the rename and destroys its original name — and the in-save()capture won't fire on a metadata edit. The backfill is the only thing that preserves these, so it runs at container start before admin traffic. Do not re-enable any rename one-shot until this has deployed and backfilled. (Re-standardizing those legacy files is a separate follow-up issue.)Migration
No committed migration (matches repo convention):
settings_testbuilds tables from models; prod/test runmakemigrations websiteat container start, generating the two additive nullable columns.Notes
🤖 Generated with Claude Code