Show referenced records before deleting an admin account - #225
Merged
Merged
Conversation
Admins deleting an account had no visibility into what it authored or
last touched (news, static pages, app config, budget entries, finance
hearing settings, calendar events) before the FK link was silently
nulled out. Adds GET /api/admin/accounts/{id}/references, grouped by
record type with counts and manage-page links, and a confirmation
dialog that shows them before delete instead of a plain confirm().
Also fixes FinanceHearingConfig.updated_by, the one FK to admin.id
still NOT NULL with no ondelete rule (missed by #223's pass over the
rest of these).
Test Results642 tests +15 642 ✅ +15 59s ⏱️ +5s Results for commit b7eb56c. ± Comparison against base commit dd856b4. This pull request removes 1 and adds 16 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
calebyhan
force-pushed
the
fix/224-account-referenced-records
branch
from
September 8, 2026 19:40
19556f1 to
b7eb56c
Compare
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.
Summary
GET /api/admin/accounts/{id}/references, which groups linked records (news, static pages, app config, budget entries, finance hearing settings, calendar events) by type with counts, sample items, and manage-page links.window.confirm()delete flow with anAccountReferencesDialogthat shows those linked records before an admin confirms deletion, and clearly surfaces a retryable error state if the safety check itself fails (rather than silently treating a failed check as "safe to delete").FinanceHearingConfig.updated_by, the one FK toadmin.idthat was stillNOT NULLwith noondeleterule — it was missed by Admin/Staff roles rework #223's pass over the rest of these and would have thrown anIntegrityErroron delete.init_db.py's existing self-healing migration (sync_missing_columns/sync_foreign_key_actions) picks up the nullable +SET NULLchange automatically.Test plan
TestAccountReferences(11 cases covering 404, empty/each reference type, item-limit truncation, staff/unauthenticated access) and a delete test for theFinanceHearingConfigfix; full backend suite passes (634/639 — the 5 unrelated failures are a pre-existing macOS-only/dev/shmpytest config issue, not related to this change).tsc --noEmitclean, production build passes.