Story #55 Notify assigned trainer when assigned to event or when event details are modified - cseseniordesign/reservations GitHub Wiki

End User Documentation

Dev Testing Instructions

  1. Make sure you are on the most recent version of the dev-notify-trainers branch.
  2. Go to the Users page on the website.
  3. Start editing the user details for yourself.
  4. Scroll down and check the Make Trainer checkbox. This will allow you to be assigned as a Trainer to events. It also adds the My Trainings section to your Home Page.
  5. Click the Update button to finish editing the user.
  6. Go to the Events page and create a New Event.
  7. Fill out the required sections.
  8. Under the Trainer drop-down, select yourself.
  9. Create the event.
  10. You should receive an email notification saying you have been added as a trainer for the event.
  11. Edit the event.
  12. Optional: change some details, such as adding text to the Description.
  13. Click Save Event.
  14. You should receive an email notifying you of the event being modified. Verify that the "home page" link takes you to your home page.
  15. Navigate to your home page. Verify that the event is listed under My Trainings.
  16. Go back to the Events page and edit the event again.
  17. Remove the Trainer from the event.
  18. Click Save Event.
  19. You should receive an email notifying you of your removal from the event.
  20. Edit the event and assign yourself as a Trainer once again.
  21. Delete the event on the Events page.
  22. You should receive an email notifying you of the event's deletion.

Technical Documentation

models/user.rb

  • Defined a method to email the trainer when they are added to an event.
  • Defined a method to email the trainer when an event they are assigned to is modified. Added a dynamic "home page" link.
  • Defined a method to email the trainer when they are removed from an event.
  • Defined a method to email the trainer when an event they are assigned to is deleted.

routes/admin/events.rb

  • Created a User object with an id that matches the event's trainer_id. This object is present in the event create, edit, and delete methods.
  • User object is then passed to the respective method in models/user.rb
  • Created a User object to store the event's trainer_id before the event is updated. This is used later to compare the two User objects and determine if the Trainer has been changed.
  • If the Trainer has changed, the old trainer is notified of their removal and the new trainer is notified of their addition.

routes/home.rb

  • Added code to populate a Trainer's events. To be shown on the user's Home Page.

views/home.erb

  • Added code to show the Trainer's events on the user's Home Page.