COORDINATE: Add OrganizationType base-data model backing org and registration forms#1886
Open
maebeale wants to merge 3 commits into
Open
COORDINATE: Add OrganizationType base-data model backing org and registration forms#1886maebeale wants to merge 3 commits into
maebeale wants to merge 3 commits into
Conversation
maebeale
commented
Jun 23, 2026
|
|
||
| organization.where.not(agency_type: [ nil, "" ]).find_each do |org| | ||
| match = org_type.where("LOWER(name) = LOWER(?)", org.agency_type).first | ||
| org.update_columns(organization_type_id: match.id) if match |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: Backfill uses lightweight anonymous AR classes (not the real models) so the migration stays stable if OrganizationType/Organization change later, and update_columns to skip validations/callbacks during the data move. Mapping is case-insensitive against the seeded type names.
maebeale
commented
Jun 23, 2026
|
|
||
| # Published names for the forms, falling back to the canonical defaults when | ||
| # nothing is seeded yet. | ||
| def self.published_names |
Collaborator
Author
There was a problem hiding this comment.
🤖 From Claude: Fallback to DEFAULT_NAMES keeps the org + registration forms populated when no types are published yet — notably fresh test DBs that do not load seeds, so the existing form-builder spec stays green without seeding.
16ad678 to
2dbeb8b
Compare
1bcd8ec to
0a853fb
Compare
b9d2721 to
05fa647
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
config/routes.rb:208
- should-fix: This new resource adds a full RESTful route, but there’s no corresponding routing spec (other base-data resources like sectors and organization_statuses have one), so route regressions won’t be caught.
get :download
end
resources :sectors do
Comment on lines
+108
to
115
| <%= f.association :organization_type, | ||
| label: "Organization Type", | ||
| as: :select, | ||
| collection: OrganizationType.published.ordered, | ||
| include_blank: true, | ||
| required: true, | ||
| collection: [ | ||
| "501c3/nonprofit", | ||
| "For-profit", | ||
| "Government agency", | ||
| "Other (please specify below)" | ||
| ], | ||
| selected: f.object.agency_type, | ||
| input_html: { | ||
| value: f.object.agency_type, | ||
| class: "rounded-md border-gray-300 shadow-sm focus:ring-blue-500 focus:border-blue-500" | ||
| } %> |
Comment on lines
+108
to
112
| <%= f.association :organization_type, | ||
| label: "Organization Type", | ||
| as: :select, | ||
| collection: OrganizationType.published.ordered, | ||
| include_blank: true, | ||
| required: true, |
Comment on lines
407
to
+409
| position = add_field(form, position, "Organization Type", :single_select_radio, | ||
| key: "agency_type", group: "person_contact_info", required: false, | ||
| options: [ | ||
| "501c3/nonprofit", "For-profit", "Government agency", | ||
| "Other (please specify below)" | ||
| ]) | ||
| options: OrganizationType.published_names) |
Comment on lines
+5
to
+8
| create_table :organization_types do |t| | ||
| t.string :name | ||
| t.text :description | ||
| t.boolean :published, default: false, null: false |
Comment on lines
191
to
193
| resources :organization_statuses | ||
| resources :organization_types | ||
| resources :affiliations, only: :destroy |
Replace the hardcoded "Organization Type" classification list (duplicated across the organization profile form and the public registration form builder) with an admin-managed, Publishable OrganizationType model under "Base data". Organizations now belong_to :organization_type, and the profile form, index, and show read from the association. Existing agency_type strings are backfilled onto the matching types so no data is lost; the canonical four are seeded as published. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the "(please specify below)" parenthetical from the option label. The migration backfill aliases the legacy string onto the renamed record so existing organizations keep their classification. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keep it schema-only (add the nullable reference). The canonical types are still seeded via db/seeds.rb; existing organizations are left unclassified rather than mapped from their legacy agency_type strings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
05fa647 to
7dc8076
Compare
maebeale
added a commit
that referenced
this pull request
Jul 4, 2026
When linking/creating an org from a registrant's submission on the org-linking page, optionally apply the org info the registrant typed, gated by a per-form "populate" toggle (zero JS): - Create-and-link (new org) and suggested matches default the toggle on (very likely the registrant's org); the manual search box defaults off (often an unrelated established org). - When applying: website and organization type overwrite the org's values (each logged to Ahoy update.organization); the address is additive — added as a new primary, or a same-street record refreshed instead of duplicated; demoted addresses stay active. - Create-and-link with the toggle off creates the org bare; an existing same-name org is only linked unless the toggle is on. Organization type is set via the OrganizationType association (PR #1886): the submitted type name is resolved to an OrganizationType record (case-insensitive). Website stored as typed (#1765). Phone is not populated (no org phone field). Also fixes a latent bug: PublicRegistration passed nil street/zip to NOT NULL address columns, 500-ing when a registrant filled a city but no zip; coerce to "". Co-Authored-By: Claude Opus 4.8 <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.
🤖 PR, suggested 👤 review level: 📖 Read — new Publishable base-data model with a schema-only migration (no data transform); contained logic, low blast radius
What is the goal of this PR and why is this important?
The "Organization Type" classification list was hardcoded and duplicated in two places (the organization profile form and the public registration form builder). This makes it an admin-managed,
PublishableOrganizationTypemodel under Base data, so the list can change without a deploy.How did you approach the change?
OrganizationTypemodel (Publishable, name + published + description), mirroring theSectorbase-data pattern: controller, policy, decorator, factory, full CRUD views, route, admin "Base data" card.Organization belongs_to :organization_type(optional). Profile form, index ("Designations" cell), and show page now read from the association.OrganizationType.published_names, falling back to the canonical defaults when none are seeded (keeps test DBs without seeds working).db/seeds.rb; the catch-all is plain "Other".agency_type_other(the free-text "Other" specify field) is retained.Anything else to add?
organization_type_idreference) — no data backfill. Existing organizations are left unclassified rather than mapped from their legacyagency_typestrings.agency_type(string) column is left in place rather than dropped; the form no longer writes it.