From 1a725a3a16d41794953ff2c8c3889b70925dd20f Mon Sep 17 00:00:00 2001 From: maebeale Date: Tue, 23 Jun 2026 07:49:06 -0400 Subject: [PATCH 1/2] Add associated records links to person edit 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 --- app/views/people/_associated_records.html.erb | 5 ++++ app/views/people/_form.html.erb | 12 ++++++++++ .../people_associated_records_spec.rb | 23 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 app/views/people/_associated_records.html.erb create mode 100644 spec/requests/people_associated_records_spec.rb diff --git a/app/views/people/_associated_records.html.erb b/app/views/people/_associated_records.html.erb new file mode 100644 index 000000000..bbf9e0f2c --- /dev/null +++ b/app/views/people/_associated_records.html.erb @@ -0,0 +1,5 @@ +<% return unless person.persisted? %> + diff --git a/app/views/people/_form.html.erb b/app/views/people/_form.html.erb index 4ea491e6c..845493f40 100644 --- a/app/views/people/_form.html.erb +++ b/app/views/people/_form.html.erb @@ -479,6 +479,18 @@ + <% if f.object.persisted? %> + <% person = f.object.respond_to?(:object) ? f.object.object : f.object %> +
+
+ Associated records +
+
+ <%= render "associated_records", person: person %> +
+
+ <% end %> + <% if f.object.persisted? %> <% if allowed_to?(:manage?, Comment) %> diff --git a/spec/requests/people_associated_records_spec.rb b/spec/requests/people_associated_records_spec.rb new file mode 100644 index 000000000..02102eeee --- /dev/null +++ b/spec/requests/people_associated_records_spec.rb @@ -0,0 +1,23 @@ +require "rails_helper" + +RSpec.describe "Person edit associated records", type: :request do + let(:admin) { create(:user, :admin) } + + before { sign_in admin } + + describe "GET /people/:id/edit" do + it "links to the person's filtered event registrations and workshop logs" do + person = create(:person) + user = create(:user, person: person) + create(:event_registration, registrant: person) + create(:workshop_log, created_by: user) + + get edit_person_path(person) + + expect(response).to have_http_status(:ok) + expect(response.body).to include("Associated records") + expect(response.body).to include(event_registrations_path(registrant_id: person.id)) + expect(response.body).to include(workshop_logs_person_path(person)) + end + end +end From 49856954414288092e91593bd3d511846b736033 Mon Sep 17 00:00:00 2001 From: maebeale Date: Tue, 23 Jun 2026 07:58:07 -0400 Subject: [PATCH 2/2] Link person edit to their scholarships and notifications 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 --- app/controllers/scholarships_controller.rb | 4 ++++ app/helpers/application_helper.rb | 4 +++- app/views/people/_associated_records.html.erb | 4 ++++ app/views/scholarships/index.html.erb | 6 ++++++ spec/requests/people_associated_records_spec.rb | 9 ++++++--- spec/requests/scholarships_spec.rb | 13 +++++++++++++ 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/controllers/scholarships_controller.rb b/app/controllers/scholarships_controller.rb index 2ffae041a..8424563c0 100644 --- a/app/controllers/scholarships_controller.rb +++ b/app/controllers/scholarships_controller.rb @@ -13,6 +13,10 @@ def index { grant: :donor }, { recipient: [ { affiliations: { organization: :addresses } }, { event_registrations: :event } ] } ) + if params[:recipient_id].present? + scholarships = scholarships.where(recipient_id: params[:recipient_id]) + @recipient = Person.find_by(id: params[:recipient_id]) + end @funder_groups = ScholarshipsGrouping.new(scholarships).funder_groups @scholarships_count = scholarships.size end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5d8424287..afae537cb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -256,7 +256,9 @@ def form_field_option_source(field) people: "fa-user", organizations: "fa-building", workshops: "fa-chalkboard-user", - resources: "fa-book" + resources: "fa-book", + scholarships: "fa-graduation-cap", + notifications: "fa-bell" }.freeze # Themed card-style link to a filtered index. The collection drives the diff --git a/app/views/people/_associated_records.html.erb b/app/views/people/_associated_records.html.erb index bbf9e0f2c..cc5e56fa6 100644 --- a/app/views/people/_associated_records.html.erb +++ b/app/views/people/_associated_records.html.erb @@ -1,5 +1,9 @@ <% return unless person.persisted? %> +<% email = person.preferred_email %> +<% notifications = email.present? ? Notification.email(email) : Notification.none %>
  • <%= index_button person.event_registrations, params: { registrant_id: person.id } %>
  • <%= index_button(person.user&.workshop_logs || WorkshopLog.none, path: workshop_logs_person_path(person)) %>
  • +
  • <%= index_button person.scholarships, params: { recipient_id: person.id } %>
  • +
  • <%= index_button notifications, params: { email: email } %>
diff --git a/app/views/scholarships/index.html.erb b/app/views/scholarships/index.html.erb index e6d0b703a..b6c3bbdde 100644 --- a/app/views/scholarships/index.html.erb +++ b/app/views/scholarships/index.html.erb @@ -24,6 +24,12 @@ + <% if @recipient %> +
+ Filtered to <%= @recipient.name %> + <%= link_to "Clear", scholarships_path, class: "text-blue-600 hover:underline" %> +
+ <% end %> <% if @funder_groups.any? %>
<%= render partial: "funder_group", collection: @funder_groups, as: :funder_group %> diff --git a/spec/requests/people_associated_records_spec.rb b/spec/requests/people_associated_records_spec.rb index 02102eeee..8803168fe 100644 --- a/spec/requests/people_associated_records_spec.rb +++ b/spec/requests/people_associated_records_spec.rb @@ -6,11 +6,12 @@ before { sign_in admin } describe "GET /people/:id/edit" do - it "links to the person's filtered event registrations and workshop logs" do + it "links to the person's filtered registrations, workshop logs, scholarships, and notifications" do person = create(:person) - user = create(:user, person: person) create(:event_registration, registrant: person) - create(:workshop_log, created_by: user) + create(:workshop_log, created_by: person.user) + create(:scholarship, recipient: person) + create(:notification, recipient_email: person.preferred_email) get edit_person_path(person) @@ -18,6 +19,8 @@ expect(response.body).to include("Associated records") expect(response.body).to include(event_registrations_path(registrant_id: person.id)) expect(response.body).to include(workshop_logs_person_path(person)) + expect(response.body).to include(scholarships_path(recipient_id: person.id)) + expect(response.body).to include(notifications_path(email: person.preferred_email)) end end end diff --git a/spec/requests/scholarships_spec.rb b/spec/requests/scholarships_spec.rb index 2bf600d32..d7dbbd21d 100644 --- a/spec/requests/scholarships_spec.rb +++ b/spec/requests/scholarships_spec.rb @@ -322,6 +322,19 @@ expect(response.body).to include(grant_path(grant, from_scholarships: true)) end + + it "filters to a single recipient when recipient_id is given" do + recipient = create(:person, first_name: "Carmen", last_name: "Gomez") + other = create(:person, first_name: "Jane", last_name: "Doe") + create(:scholarship, recipient: recipient) + create(:scholarship, recipient: other) + + get scholarships_path(recipient_id: recipient.id) + + expect(response.body).to include("Filtered to") + expect(response.body).to include("Carmen Gomez") + expect(response.body).not_to include("Jane Doe") + end end end