Skip to content

Feature/1885 Give user the ability to customise which SMS notifications they want to receive#3543

Merged
compwron merged 17 commits into
rubyforgood:mainfrom
harsohailB:feature/1885
May 22, 2022
Merged

Feature/1885 Give user the ability to customise which SMS notifications they want to receive#3543
compwron merged 17 commits into
rubyforgood:mainfrom
harsohailB:feature/1885

Conversation

@harsohailB
Copy link
Copy Markdown
Collaborator

@harsohailB harsohailB commented May 20, 2022

What github issue is this PR for, if any?

Resolves #1885

What changed, and why?

  • Created sms_notification_events table to store events that users can opt into for SMS notifications

    • This table has a column for user type which allows users to see the events that corresponds to them
  • Created user_sms_notification_events table to create many:many relationship between users table and sms_notification_events table

  • Rendered the events below "Text Me" option of edit profile

    • Event options are disabled if "Text Me" is not checked
  • Create an sms_notification_event_populator for seeding and prod db

    • Added an afterparty task to run this populator upon deployment

Events Added

Volunteer

  • CASA case youth has birthday

Supervisor

  • Volunteer made case contact
  • Volunteer edited case (case details, court order, court dates)

CASA Admin

  • New entry in reimbursement queue

💡 Feel free to add more events here and I can commit them into the code!

How will this affect user permissions?

  • Volunteer permissions: N/A
  • Supervisor permissions: N/A
  • Admin permissions: N/A

How is this tested? (please write tests!) 💖💪

  • Wrote requests tests to check if user_sms_notification_events table is updated correctly upon user selecting an event
  • Wrote view tests to check if the different user types can only see events that are meant for them

Screenshots please :)

Screen Shot 2022-05-19 at 6 12 38 PM

@harsohailB harsohailB requested review from 7riumph and xihai01 May 20, 2022 00:13
@github-actions github-actions Bot added dependencies Touches dependency files erb Touches ERB templates javascript Touches JavaScript code ruby Touches Ruby code zzz_archived: Tests no-skin-tone labels May 20, 2022
@harsohailB harsohailB requested a review from compwron May 20, 2022 00:21
@xihai01
Copy link
Copy Markdown
Collaborator

xihai01 commented May 20, 2022

what's up with all those model file changes?

@harsohailB
Copy link
Copy Markdown
Collaborator Author

what's up with all those model file changes?

Just ran the migrations after pulling in main. Not sure why that was not committed before 🤔

@harsohailB harsohailB self-assigned this May 21, 2022
@harsohailB harsohailB marked this pull request as ready for review May 21, 2022 05:49
Copy link
Copy Markdown
Collaborator

@7riumph 7riumph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is great! Always increasing my RoR arsenal when reviewing your PRs. Also wanted an extra explanation on users and sms_notification_events many:many relationship. I read https://medium.com/@pk60905/many-to-many-relationship-in-rails-cf86e12db8b0 but want to understand more on why it helps for this specific case

@7riumph 7riumph self-requested a review May 21, 2022 13:23
Comment thread app/javascript/src/require_communication_preference.js Outdated
Comment thread app/views/users/edit.html.erb Outdated
<%= form.collection_check_boxes("sms_notification_event_ids", SmsNotificationEvent.where(user_type: @user.type),
:id, :name) do |event| %>
<div class="form-check">
<%= event.check_box(class: "form-check-input", id: "toggle-sms-notification-event") %>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking ahead but as the number of notification events grow adding a drop-down/collapse menu could be good at some point. Probably in the same vein as password confirms dropdown. Checkbox is ticked → menus drops down with event checkboxes. checkbox is unticked → menu collapses

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@7riumph
Copy link
Copy Markdown
Collaborator

7riumph commented May 21, 2022

Events aren't displaying on the edit profile page on my end even after ticking "Text Me". Still unsure why. I'm on the clone branch, 7riumph:harsohail_sms_event for reference. Is anyone else getting this? Only ran rake db:migrate

@7riumph 7riumph self-requested a review May 21, 2022 17:06
@harsohailB
Copy link
Copy Markdown
Collaborator Author

Events aren't displaying on the edit profile page on my end even after ticking "Text Me". Still unsure why. I'm on the clone branch, 7riumph:harsohail_sms_event for reference. Is anyone else getting this? Only ran rake db:migrate

I think you will have to re-seed the database as well to populate the events data.

# updated_at :datetime not null
# supervisor_id :integer not null
# volunteer_id :integer not null
# supervisor_id :bigint not null
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so confused why they changed from int to bigint.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a local version difference with postgres maybe - bigint is arguably more correct.

@compwron compwron merged commit 29b6763 into rubyforgood:main May 22, 2022
Copy link
Copy Markdown
Collaborator

@xihai01 xihai01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

late to the party, but great stuff!

@harsohailB harsohailB added the codethechange code.the.change developers label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codethechange code.the.change developers dependencies Touches dependency files erb Touches ERB templates javascript Touches JavaScript code ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give user the ability to customise which SMS notifications they want to receive

4 participants