Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/controllers/volunteers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def new
end

def create
volunteer = User.new(create_volunteer_params)
@volunteer = User.new(create_volunteer_params)

if volunteer.save
if @volunteer.save
VolunteerMailer.account_setup(@volunteer).deliver
redirect_to root_path
else
render :new
Expand Down
9 changes: 8 additions & 1 deletion app/mailers/volunteer_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
class VolunteerMailer < ApplicationMailer
default from: "CASA Admin <no-reply@casa-r4g-staging.herokuapp.com>"

# send a signup email to the user, pass in the user object that contains the user's email address
# send a signup email to the user, pass in the user object that contains the user's email address
def deactivation(user)
@user = user
mail(to: @user.email, subject: "Your CASA volunteer account has been deactivated")
end

# send a signup email to the user, pass in the user object that contains the user's email address
def account_setup(user)
@user = user
@token = @user.generate_password_reset_token
mail(to: @user.email, subject: "Create a password & set up your account")
end
end
12 changes: 12 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ def past_names
# get past_names from paper_trail gem, version_limit is 10 so no performance concerns
versions.map { |version| version&.reify&.display_name }
end

# Generate a Devise reset_token, used for the account_setup mailer. This happens automatically
# when a user clicks "Reset My Password", so do not use this method in that flow.
def generate_password_reset_token
raw_token, hashed_token = Devise.token_generator.generate(self.class, :reset_password_token)

self.reset_password_token = hashed_token
self.reset_password_sent_at = Time.now.utc
save(validate: false)

raw_token
end
end

# == Schema Information
Expand Down
215 changes: 169 additions & 46 deletions app/views/devise/mailer/reset_password_instructions.html.erb
Original file line number Diff line number Diff line change
@@ -1,53 +1,176 @@
<!DOCTYPE html>
<html>
<body style="margin: 0 !important; padding: 0 !important; background-color: #edefed">
<html style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Actionable emails e.g. reset password</title>

<!-- HEADER -->
<table border="0" cellpadding="0" cellspacing="0" width="600" align="center">
<tr>
<td bgcolor="#edefed" align="center">
<h1 style="font-size: 36px; font-family: Helvetica, Arial, sans-serif;">CASA Password Reset</h1>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" align="center" style="padding: 30px 10px 30px 10px; border-radius: 7px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 530px;">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #333333; padding-top: 0px;" class="padding">
<p>If you've lost your password or wish to reset it, click the button below. If you didn’t request this, you can safely ignore this email.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="padding-top: 15px;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" bgcolor="#00447C"><a href="<%= "#{edit_password_url(@resource, reset_password_token: @token)}" %>" target="_blank" style="font-size: 20px;font-family: Helvetica, Arial, sans-serif;color: #ffffff;text-decoration: none; text-decoration: none;padding:15px 20px;display: inline-block;">Reset your password</a></td>

<style type="text/css">
img {
max-width: 100%;
}
body {
-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em;
}
body {
background-color: #f6f6f6;
}
@media only screen and (max-width: 640px) {
body {
padding: 0 !important;
}
h1 {
font-weight: 800 !important; margin: 20px 0 5px !important;
}
h2 {
font-weight: 800 !important; margin: 20px 0 5px !important;
}
h3 {
font-weight: 800 !important; margin: 20px 0 5px !important;
}
h4 {
font-weight: 800 !important; margin: 20px 0 5px !important;
}
h1 {
font-size: 22px !important;
}
h2 {
font-size: 18px !important;
}
h3 {
font-size: 16px !important;
}
.container {
padding: 0 !important; width: 100% !important;
}
.content {
padding: 0 !important;
}
.content-wrap {
padding: 10px !important;
}
.invoice {
width: 100% !important;
}
}
</style>
</head>

<body itemscope itemtype="http://schema.org/EmailMessage" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
<table class="main-body" style="box-sizing: border-box; min-height: 150px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; width: 100%; height: 100%; background-color: rgb(234, 236, 237);" width="100%" height="100%" bgcolor="rgb(234, 236, 237)">
<tbody style="box-sizing: border-box;">
<tr class="row" style="box-sizing: border-box; vertical-align: top;" valign="top">
<td class="main-body-cell" style="box-sizing: border-box;">
<table class="container" style="box-sizing: border-box; font-family: Helvetica, serif; min-height: 150px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: auto; margin-right: auto; margin-bottom: auto; margin-left: auto; height: 0px; width: 90%; max-width: 550px;" width="90%" height="0">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="container-cell" style="box-sizing: border-box; vertical-align: top; font-size: medium; padding-bottom: 50px;" valign="top">
<table class="c1766" style="box-sizing: border-box; margin-top: 0px; margin-right: auto; background:#728089;margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; width: 100%; min-height: 30px;" width="100%">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="cell c1776" style="box-sizing: border-box; width: 70%; vertical-align: middle;" width="70%" valign="middle">
<div class="c1144" style="box-sizing: border-box; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; font-size: 17px; font-weight: 500;text-align: center;color: #fff;">Court Appointed Special Advocate (CASA) / Prince George's County
<br style="box-sizing: border-box;">
</div>
</td>
</tr>
</tbody>
</table>
<table class="c1766" style="box-sizing: border-box; margin-top: 0px; margin-right: auto; background:#fff;margin-left: 0px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; width: 100%; min-height: 30px;" width="100%">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="cell c1776" style="box-sizing: border-box; width: 70%; vertical-align: middle;text-align:center;" width="70%" valign="middle">
<img src="https://user-images.githubusercontent.com/62810851/81514853-1e7f1600-92e6-11ea-8122-2b9faad228b3.jpg" alt="GrapesJS." class="c926" style="box-sizing: border-box; color: rgb(158, 83, 129); width: 50%; font-size: 50px; height: 265px;padding-top:10px;background:#fff;" height="531">
</td>
</tr>
</tbody>
</table>
<table class="card" style="background:#fff;box-sizing: border-box; min-height: 150px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-bottom: 20px; height: 0px;" height="0">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="card-cell" style="box-sizing: border-box; background-color: rgb(255, 255, 255); overflow-x: hidden; overflow-y: hidden; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-align: center;" bgcolor="rgb(255, 255, 255)" align="center">
<table class="table100 c1357" style="box-sizing: border-box; width: 100%; min-height: 150px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; height: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-collapse: collapse;" width="100%" height="0">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="card-content" style="box-sizing: border-box; font-size: 13px; line-height: 20px; color: rgb(111, 119, 125); padding-top: 10px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; vertical-align: top;" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 530px;">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" class="padding">
If you've lost your password or wish to reset it, click the button below. If you didn’t request this, you can safely ignore this email.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" style="padding-top: 15px;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left">
<a href="<%= "#{edit_password_url(@resource, reset_password_token: @token)}" %>" target="_blank" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #348eda; margin: 0; border-color: #348eda; border-style: solid; border-width: 10px 20px;">Reset your password</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="footer" style="box-sizing: border-box; margin-top: 50px; color: rgb(152, 156, 165); text-align: center; font-size: 11px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;" align="center">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td class="footer-cell" style="box-sizing: border-box;">
</td>
</tr>
</tbody>
</table>
<div class="c2577" style="text-align:center;box-sizing: border-box; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;">
<p class="footer-info" style="box-sizing: border-box;">Court Appointed Special Advocate (CASA) / Prince George's County
<br style="box-sizing: border-box;">
<br style="box-sizing: border-box;">6811 Kenilworth Ave. Suite 402, Riverdale, MD, 20737
</p>
<table id="iwvod" style="box-sizing: border-box; height: 150px; margin: 0 auto 10px auto; padding: 5px 5px 5px 5px; width: 100%;" width="100%" height="150">
<tbody style="box-sizing: border-box;">
<tr style="box-sizing: border-box;">
<td id="igyvi" style="box-sizing: border-box; font-size: 12px; font-weight: 300; vertical-align: top; color: rgb(111, 119, 125); margin: 0; padding: 0; width: 50%;" width="50%" valign="top">
<a id="izi4m" style="box-sizing: border-box; color: #000;">About CASA</a>
</td>
<td id="idvsy" style="box-sizing: border-box; font-size: 12px; font-weight: 300; vertical-align: top; color: rgb(111, 119, 125); margin: 0; padding: 0; width: 50%;" width="50%" valign="top">
<a id="ilo0w" style="box-sizing: border-box; color: #000;">Update Profile</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>

</body>
</tbody>
</table>
</body>
</html>
18 changes: 18 additions & 0 deletions app/views/volunteer_mailer/account_setup.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<meta itemprop="name" content="Confirm Email" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;" />
<table width="100%" cellpadding="0" cellspacing="0" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<tr style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
A CASA/Prince George’s County volunteer console account has been created for you. This console is for logging the time you spend and actions you take on your CASA case. You can log activity with your CASA youth, their family members, their foster family or placement, the DSS worker, your Case Supervisor and others associated with your CASA case (such as teachers and therapists).
</td>
</tr>
<tr style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
Your console account is associated with this email. If this is not the correct email to use, please stop here and contact your Case Supervisor to change the email address. If you are ready to get started, please set your password. This is the first step to accessing your new volunteer account.
</td>
</tr>
<tr style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
<td class="content-block" itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
<a href="<%= "#{edit_password_url(@user, reset_password_token: @token)}" %>" target="_blank" class="btn-primary" itemprop="url" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #348eda; margin: 0; border-color: #348eda; border-style: solid; border-width: 10px 20px;">Set Your Password</a>
</td>
</tr>
</table>
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

config.action_mailer.default_url_options = {host: "localhost", port: 3000} # for devise authentication
config.action_mailer.default_url_options = { host: "localhost", port: 3000 } # for devise authentication

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
Expand Down
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } # for devise authentication
config.action_mailer.default_url_options = { host: "localhost", port: 3000 } # for devise authentication

config.cache_classes = false

Expand Down
4 changes: 4 additions & 0 deletions lib/mailers/previews/volunteer_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ class VolunteerMailerPreview < ActionMailer::Preview
def deactivation
VolunteerMailer.deactivation(User.last)
end

def account_setup
VolunteerMailer.account_setup(User.last)
end
end
Loading