-
-
Notifications
You must be signed in to change notification settings - Fork 529
Feature/1887 Volunteer receives SMS notification when their account is reactivated by admin #3641
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
Changes from all commits
018958c
e4871f2
c818310
48ca5ae
65b8968
8366aaf
c14fb16
daf59b0
1a85465
dc4c594
ad6ff25
a4e65c5
f810489
f2b8101
3120088
a072174
d23ba51
3452e38
dc71a5e
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 |
|---|---|---|
|
|
@@ -85,6 +85,16 @@ def resend_invitation | |
| end | ||
| end | ||
|
|
||
| def send_reactivation_alert | ||
| authorize @volunteer | ||
| if @volunteer.save | ||
| send_sms_to(volunteers_phone_number, "Hello #{@volunteer.display_name}, \n \n Your CASA/Prince George’s County volunteer console account has been reactivated. You can login using the credentials you were already using. \n \n If you have any questions, please contact your most recent Case Supervisor for assistance. \n \n CASA/Prince George’s County") | ||
| redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer reactivation alert sent" | ||
| else | ||
| redirect_to edit_volunteer_path(@volunteer), alert: "Volunteer reactivation alert failed" | ||
| end | ||
| end | ||
|
|
||
| def reminder | ||
| authorize @volunteer | ||
| with_cc = params[:with_cc].present? | ||
|
|
@@ -134,4 +144,22 @@ def update_volunteer_params | |
| .new(params) | ||
| .without_active | ||
| end | ||
|
|
||
| def volunteers_phone_number | ||
| authorize @volunteer | ||
|
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. you don't need to authorize twice |
||
| @volunteers_phone_number = @volunteer.phone_number | ||
| end | ||
|
|
||
| def send_sms_to(phone_number, body) | ||
| twilio = TwilioService.new(current_user.casa_org.twilio_api_key_sid, current_user.casa_org.twilio_api_key_secret, current_user.casa_org.twilio_account_sid) | ||
| req_params = {From: current_user.casa_org.twilio_phone_number, Body: body, To: phone_number} | ||
|
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. lowercase is more normal than uppercase |
||
| twilio_res = twilio.send_sms(req_params) | ||
|
|
||
| # Error handling for spec test purposes | ||
|
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. It might be better to just leave |
||
| if twilio_res.error_code.nil? | ||
| "SMS has been sent to Volunteer!" | ||
| else | ||
| "SMS was not sent to Volunteer due to an error." | ||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| <div class="field form-group"> | ||
| <% if user.active? %> | ||
| Volunteer is <span class="badge badge-success text-uppercase display-1">Active</span> | ||
| Volunteer is <span class="badge badge-success text-uppercase display-1">Active</span><br> | ||
| <% if policy(user).deactivate? %> | ||
| <%= link_to "Deactivate volunteer", | ||
| deactivate_volunteer_path(user), | ||
|
|
@@ -22,8 +22,13 @@ | |
| <% if (current_user.supervisor? || | ||
| current_user.casa_admin?) && | ||
| user.invitation_accepted_at.nil? %> | ||
| <%= link_to "Resend Invitation", | ||
| <%= link_to "Resend Invitation (Email)", | ||
| resend_invitation_volunteer_path(user), | ||
| class: "btn btn-outline-danger" %> | ||
| <% end %> | ||
| <% if current_user.casa_admin? %> | ||
|
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. linter might be sad here? |
||
| <%= link_to "Send Reactivation Alert (SMS)", | ||
| send_reactivation_alert_volunteer_path(user), | ||
| class: "btn btn-outline-danger" %> | ||
| <% end %> | ||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| patch :deactivate | ||
| patch :activate | ||
| patch :resend_invitation | ||
| post :send_reactivation_alert | ||
| patch :change_to_supervisor | ||
| end | ||
| end | ||
|
|
@@ -107,6 +108,7 @@ | |
| patch :activate | ||
| patch :deactivate | ||
| get :resend_invitation | ||
| get :send_reactivation_alert | ||
|
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. Why is there a get here? Seems odd... |
||
| patch :reminder | ||
| get :impersonate | ||
| end | ||
|
|
||
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.
Maybe add the failure notes from
volunteer.errors.full_messages?