-
-
Notifications
You must be signed in to change notification settings - Fork 512
#6563 improve case contact workflow for supervisor and admin #6679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f43ffed
8c6442a
4178a8f
7066812
9201608
fd1d775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ class CaseContactsController < ApplicationController | |
| before_action :set_case_contact, only: %i[edit destroy] | ||
| before_action :set_contact_types, only: %i[new edit create] | ||
| before_action :require_organization! | ||
| after_action :verify_authorized, except: %i[leave] | ||
| before_action :set_volunteer, only: %i[impersonate_and_edit] | ||
| after_action :verify_authorized, except: %i[leave impersonate_and_edit] | ||
|
|
||
| def index | ||
| load_case_contacts | ||
|
|
@@ -61,6 +62,12 @@ def leave | |
| redirect_back_to_referer(fallback_location: case_contacts_path) | ||
| end | ||
|
|
||
| def impersonate_and_edit | ||
| impersonate_user(@volunteer) | ||
|
|
||
| redirect_to casa_case_path(params[:casa_case_id]) | ||
| end | ||
|
Comment on lines
+65
to
+69
|
||
|
|
||
| private | ||
|
|
||
| def update_or_create_additional_expense(all_ae_params, cc) | ||
|
|
@@ -98,4 +105,8 @@ def build_draft_case_ids(params, casa_cases) | |
|
|
||
| [] | ||
| end | ||
|
|
||
| def set_volunteer | ||
| @volunteer = Volunteer.find(params[:creator_id]) | ||
| end | ||
|
Comment on lines
+109
to
+111
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,8 +38,14 @@ | |
| <% if Pundit.policy(current_user, contact).update? %> | ||
| <%= render "case_contacts/followup", contact: contact, followup: contact.requested_followup %> | ||
| <div class="mr-2"> | ||
| <%= link_to edit_case_contact_path(contact), class: "text-danger", data: { turbo: false } do %> | ||
| <i class="lni lni-pencil-alt"></i> Edit | ||
| <% if (current_user.casa_admin? || current_user.supervisor?) && contact.creator&.volunteer? && contact.creator != current_user %> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anywhere in the back end that we verify its only a CASA admin or supervisor submitting this request? We don't want a volunteer doing that.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be in a "policy" file |
||
| <%= link_to case_contacts_impersonate_and_edit_path(creator_id: contact.creator.id, casa_case_id: @casa_case), class: "text-danger", data: { turbo: false } do %> | ||
| <i class="lni lni-pencil-alt"></i> View/Edit | ||
| <% end %> | ||
| <% else %> | ||
| <%= link_to edit_case_contact_path(contact), class: "text-danger", data: { turbo: false } do %> | ||
| <i class="lni lni-pencil-alt"></i> Edit | ||
| <% end %> | ||
| <% end %> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,17 +73,16 @@ | |
| enable_pundit(view, admin) | ||
| allow(view).to receive(:current_user).and_return(admin) | ||
| end | ||
|
|
||
| context "occurred_at is before the last day of the month in the quarter that the case contact was created" do | ||
| let(:case_contact) { build_stubbed(:case_contact, creator: volunteer) } | ||
| let(:case_contact2) { build_stubbed(:case_contact, deleted_at: Time.current, creator: volunteer) } | ||
|
|
||
| it "shows edit button" do | ||
| it "shows view/edit button" do | ||
| assign :case_contact, case_contact | ||
| assign :casa_cases, [case_contact.casa_case] | ||
|
|
||
| render(partial: "case_contacts/case_contact", locals: {contact: case_contact}) | ||
| expect(rendered).to have_link(nil, href: "/case_contacts/#{case_contact.id}/edit") | ||
| expect(rendered).to have_link(nil, href: "/case_contacts/impersonate_and_edit?creator_id=#{case_contact.creator.id}") | ||
| end | ||
|
Comment on lines
+80
to
86
|
||
|
|
||
| it "shows make reminder button" do | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redirecting to
casa_case_path(params[:casa_case_id])after impersonation can fail because volunteers are only authorized to view cases they are actively assigned to (seeCasaCasePolicy#show?). If the case contact was authored by a volunteer who is no longer actively assigned, the impersonated session will be blocked from the case details page, defeating the workflow.Consider redirecting directly to the case contact edit flow (passing the case contact id) rather than the case details page, or otherwise ensuring the impersonated volunteer can access the target case.