Add associated records links to person edit#1889
Conversation
Admins need to jump from a person's edit page to the records tied to that person, the same way the organization edit page already links out to its associated records. Surfaces the destinations that actually scope to the person: their event registrations (filtered index) and workshop logs (the per-person view). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| @@ -0,0 +1,5 @@ | |||
| <% return unless person.persisted? %> | |||
| <ul class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-6 gap-y-2"> | |||
| <li><%= index_button person.event_registrations, params: { registrant_id: person.id } %></li> | |||
There was a problem hiding this comment.
🤖 From Claude: Only these two records get cards because they have person-scoped destinations: registrations filter on registrant_id, and workshop_logs_person_path is the per-person view. Scholarships/grants/form-submissions have no person-filtered index, so a card would land on an unfiltered list — omitted intentionally.
Adds two more cards to the person edit "Associated records" section. Scholarships needed a recipient_id filter on its index (it only grouped by funder before) so the card lands on that person's awards rather than the full list; notifications reuse the existing email filter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| { grant: :donor }, | ||
| { recipient: [ { affiliations: { organization: :addresses } }, { event_registrations: :event } ] } | ||
| ) | ||
| if params[:recipient_id].present? |
There was a problem hiding this comment.
🤖 From Claude: The scholarships index previously only grouped by funder with no per-recipient view, so this adds a recipient_id filter (applied before grouping) so the person-edit card lands on just that person's awards.
There was a problem hiding this comment.
Pull request overview
Adds an “Associated records” section to the person edit form (mirroring the org edit UX) so admins can jump directly to a person’s related records, and introduces a recipient_id filter on the scholarships index to support that navigation.
Changes:
- Add
people/_associated_records.html.erband render it from the person form for persisted people. - Add
recipient_idfiltering to scholarships index + a “Filtered to … / Clear” banner. - Add request coverage for the new person edit links and the scholarships recipient filter.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/requests/scholarships_spec.rb | Adds request spec asserting scholarships index filters by recipient_id. |
| spec/requests/people_associated_records_spec.rb | New request spec asserting the associated-records links render on person edit. |
| app/views/scholarships/index.html.erb | Adds a recipient filter banner with a clear link when scoped. |
| app/views/people/_form.html.erb | Renders the new associated records block for persisted people. |
| app/views/people/_associated_records.html.erb | New partial rendering card links to registrations, workshop logs, scholarships, notifications. |
| app/helpers/application_helper.rb | Adds icons for the new index_button cards (scholarships/notifications). |
| app/controllers/scholarships_controller.rb | Implements recipient_id filtering and sets @recipient for the banner. |
| <li><%= index_button(person.user&.workshop_logs || WorkshopLog.none, path: workshop_logs_person_path(person)) %></li> | ||
| <li><%= index_button person.scholarships, params: { recipient_id: person.id } %></li> | ||
| <li><%= index_button notifications, params: { email: email } %></li> |
Rounds out the person edit "Associated records" section. Grants gained a polymorphic donor filter on its index so the card scopes to that person's donations. Form submissions had no index at all, so this adds a person-scoped index (admin-only) and list view — previously a person's submissions were only reachable one-off via an event registration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| class FormSubmissionsController < ApplicationController | ||
| def index | ||
| authorize! FormSubmission | ||
| submissions = FormSubmission.includes(:form, :event, :person) |
There was a problem hiding this comment.
🤖 From Claude: New admin-only index — form submissions had no list view before, so a person's submissions were only reachable one-off from an event registration. Not using authorized_scope because FormSubmissionPolicy has no relation scope and the action is already admin?-gated.
| .by_deadline | ||
| if params[:donor_id].present? && Grant::DONOR_TYPES.include?(params[:donor_type]) | ||
| grants = grants.where(donor_id: params[:donor_id], donor_type: params[:donor_type]) | ||
| @donor = grants.first&.donor |
There was a problem hiding this comment.
🤖 From Claude: Resolve the donor via grants.first&.donor (already eager-loaded) rather than params[:donor_type].constantize — Brakeman flags reflection on a param even behind the DONOR_TYPES whitelist.
🤖 PR, suggested 👤 review level: 🔬 Inspect — adds a new admin-only form-submissions index/route/policy plus filters on the scholarships and grants indexes
What is the goal of this PR and why is this important?
How did you approach the change?
people/_associated_records.html.erbpartial, rendered in the person form (persisted only), styled to match the org version.registrant_id)workshop_logs_person_pathviewrecipient_idfilter to the index (previously grouped by funder only) + "Filtered to " bannerdonor_id+donor_type) to the index + banneremailfilter, scoped to the person'spreferred_emailPersonPolicy#edit? == admin?), so no per-card auth guards are needed. The new form-submissions index isadmin?-gated in its policy.Anything else to add?