Story #17 Promotional Email Updates | User and Technical Documentation - cseseniordesign/reservations GitHub Wiki

End User Documentation

Dev Testing Instructions

  1. Make sure you are on the most recent version of the dev-promo-emails branch.
  2. Start your dev environment and log in with development2 so you have all permissions.
  3. Navigate to the "My Account" page
  4. Verify that there is a label and checkbox to opt-out of future emails. Verify that changing this checkbox and updating the profile updates the user's space_status appropriately in the database. The space_status should be either current, expired, current_no_email, or expired_no_email based on their expiration date and opt-out status.
    • You can view the space_status of development2 with this query: select space_status from users where id=3488;
    • You should change the expiration date either via database or the edit users page to test that space_status is set appropriately for both current and expired users.
  5. Navigate to the Admin -> Email page and click "compose"
  6. Verify there are labels and checkboxes for sending emails to all active users, all inactive users, and all users with specific tool authorizations. There should also be a multiple select field for the tool authorizations.
    • Currently line 30 in emails.rb is hardcoded to only send emails to users with [email protected] email. Change this to be your email for testing purposes. This line will be removed before these changes are merged to stable and rolled to production.
    • Ensure that sending emails by these methods works as expected. Change the expiration date, UNL relation, and tool authorizations of whichever account is connected to the hardcoded email (in my case it was development2 since I was using [email protected]) if necessary to ensure that all of these functionalities work.
    • Ensure that checking the option to include the opt-out message works by appending that message to the email. Ensure the link works and make sure if the box isn't checked that the message is not appended to the email. If the user is already logged in when the link is clicked it should take them straight to the me page to adjust their email preferences. If they are not logged in then it should take them to the login page and redirect them to the me page after they log in.
  7. Ensure there are no errors in the console throughout your testing, the page is still responsive on all screen sizes, and everything is readable in dark and light mode.

Production Testing Instructions

  1. Go to https://innovationstudio-manager.unl.edu/login/ and log in with an account that has elevated permissions to view the Admin -> Email page.
  2. Navigate to the "My Account" page
  3. Verify that there is a label and checkbox to opt-out of future emails. Verify that changing this checkbox and updating the profile updates the user's space_status appropriately in the database. The space_status should be either current, expired, current_no_email, or expired_no_email based on their expiration date and opt-out status.
    • You can view the space_status of development2 by searching for development2 on the Admin -> Users page and then clicking the "edit" button. Form there it will show you the space_status of the user.
    • You should change the expiration date either via the edit users page to test that space_status is set appropriately for both current and expired users.
  4. Navigate to the Admin -> Email page and click "compose"
  5. Verify there are labels and checkboxes for sending emails to all active users, all inactive users, and all users with specific tool authorizations. There should also be a multiple select field for the tool authorizations.
    • Ensure that sending emails by these methods works as expected.
    • Ensure that checking the option to include the opt-out message works by appending that message to the email. Ensure the link works and make sure if the box isn't checked that the message is not appended to the email. If the user is already logged in when the link is clicked it should take them straight to the me page to adjust their email preferences. If they are not logged in then it should take them to the login page and redirect them to the me page after they log in.
  6. Ensure there are no errors in the console throughout your testing, the page is still responsive on all screen sizes, and everything is readable in dark and light modes.

Technical Documentation

app.rb

  • Added an optional parameter to require_login named redirect_after_login. If this parameter is passed to the method then a next_page parameter will be added to the login route. This is used for redirecting to the me page when a user clicks the link in an email to opt-out.

models/user.rb

  • Added a new method get_expiration_date.

routes/auth.rb

  • Added a new GET action, /opt_out/?. This action will require a login and if the user is not logged in then it will redirect them to the me page after they log in. If the user is already logged in they are redirected to the me page.
  • Changes within the POST /me/? action:
    • Added logic to check if the user's expiration date is current or expired so that the user's space_status can be set accurately. If the user checked the box to opt-out of future emails on the me page then "_no_email" is appended to their space_status.

routes/admin/emails.rb

  • Changes within the GET /admin/email/send/? action:
    • Grab all tools from database and pass to the view.
  • Changes within the POST /admin/email/send/? action:
    • Logic only considers sending emails to users where their space_status does not contain "no_email".
    • Added logic for sending emails to all active users, all inactive users, and users with specific tool authorizations if the corresponding checkbox is checked.
    • Added logic to append a message to the email with a link to opt out of future emails if the corresponding checkbox is checked.

routes/admin/users.rb

  • Added "Membership Current (opted out of emails)" to STUDIO_STATII so that it shows in the dropdown on the edit user page.

views/login.erb

  • Added a hidden field to store the value of next_page so that it can be posted to the controller along with the login form fields.

views/me.erb

  • Added a label and checkbox for users to choose if they want to opt-out of emails.

views/admin/send_email.erb

  • Added labels and checkboxes for admins to select if they want to send emails to all active users, all inactive users, and all users with specific tool authorizations. Also added a multiple select field for the admins to select the tool authorizations from.
  • Added a label and checkbox under the email body textarea for admins to check if they want to append a message to the email body letting the users know they can opt-out of future emails by clicking the link in the message.