Skip to content
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

4176 customizing reminder message to partner #5093

2 changes: 1 addition & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def organization_params
params.require(:organization).permit(
:name, :short_name, :street, :city, :state,
:zipcode, :email, :url, :logo, :intake_location,
:default_storage_location, :default_email_text,
:default_storage_location, :default_email_text, :reminder_email_text,
:invitation_text, :reminder_day, :deadline_day,
:repackage_essentials, :distribute_monthly,
:ndbn_member_id, :enable_child_based_requests,
Expand Down
4 changes: 4 additions & 0 deletions app/mailers/reminder_deadline_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ def notify_deadline(partner)
@partner = partner
@organization = partner.organization
@deadline = deadline_date(partner)
reminder_email_text = @organization.reminder_email_text
@reminder_email_text_interpolated = TextInterpolatorService.new(reminder_email_text.body.to_s, {
partner_name: @partner.name
}).call

mail(to: @partner.email, subject: "#{@organization.name} Deadline Reminder")
end
Expand Down
1 change: 1 addition & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def flipper_id
].freeze

has_rich_text :default_email_text
has_rich_text :reminder_email_text

has_one_attached :logo

Expand Down
6 changes: 6 additions & 0 deletions app/views/organizations/_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
<%= @organization.deadline_day.blank? ? 'Not defined' : "The #{@organization.deadline_day.ordinalize} of each month" %>
</p>
</div>
<div class="mb-4">
<h3 class='font-bold'>Additional text for reminder email</h3>
<p>
<%= @organization.reminder_email_text.presence || 'Not defined' %>
</p>
</div>
<div class="mb-4">
<h3 class='font-bold'>Default Intake Location</h3>
<p>
Expand Down
5 changes: 5 additions & 0 deletions app/views/organizations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@

<%= render 'shared/deadline_day_fields', f: f %>

<% default_reminder_email_text_hint = "You can use the variable <code>%{partner_name}</code> to include the partner's name in the message." %>
<%= f.input :reminder_email_text, label: "Additional text for reminder email", hint: default_reminder_email_text_hint.html_safe do %>
<%= f.rich_text_area :reminder_email_text, placeholder: 'Enter reminder email content...' %>
<% end %>

<%= f.input :intake_location, :collection => current_organization.storage_locations.active.alphabetized, :label_method => :name, :value_method => :id, :label => "Default Intake Location", :include_blank => true, wrapper: :input_group %>

<%= f.label :partner_form_fields, 'Partner Profile Sections' %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ if you would like to receive a distribution next month.</p>
before this date and submit your request if you are intending to submit an essentials request.</p>
<p>Please contact <%= @organization.name %> at <%= @organization.email %>
if you have any questions about this!</p>
<p><%= @reminder_email_text_interpolated.html_safe %></p>
9 changes: 0 additions & 9 deletions app/views/reminder_deadline_mailer/notify_deadline.text.erb

This file was deleted.

22 changes: 15 additions & 7 deletions docs/user_guide/bank/getting_started_customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,23 @@ There is also a check-box on the Partner that must be checked for the Partner to

The text of this email will be:

<blockquote>
Hello [Partner's name],

<br/>
<br/>
This is a friendly reminder that [Your bank's name] requires your human essentials requests to be submitted by [the deadline date, including month and year]
if you would like to receive a Distribution next month.

<br/>
<br/>
Please log into Human Essentials at https://humanessentials.app before this date and submit your request if you are intending to submit an essentials request.

Please contact [Your bank's name] at <%= @organization.email %>
<br/>
<br/>
Please contact [Your bank's name] at [Your bank's email]
if you have any questions about this!



<br/>
<br/>
[Additional text for reminder email (see below)]
</blockquote>



Expand All @@ -76,6 +81,9 @@ If you do not pick a day, no reminder emails are sent.
#### Deadline day (Final day of the month to submit Requests)
This day will be included in the reminder email message,

#### Additional text for reminder email
If present, this text will be included in the reminder email after the default text. In the above email template, this additional message will replace `[Additional text for reminder email (see below)]`.

----------

#### Default Intake Location
Expand Down
10 changes: 6 additions & 4 deletions spec/mailers/reminder_deadline_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let(:partner) { create(:partner, organization: organization) }

before(:each) do
organization.reminder_email_text = "Custom reminder message"
organization.update!(reminder_day: today.day, deadline_day: 1)
end

Expand All @@ -25,13 +26,14 @@

it 'renders the body' do
travel_to today do
expect(html_body(subject))
.to include("This is a friendly reminder that #{organization.name} requires your human essentials requests to " \
"be submitted by Tue, 01 Feb 2022")
expect(text_body(subject))
expect(subject.body.encoded)
.to include("This is a friendly reminder that #{organization.name} requires your human essentials requests to " \
"be submitted by Tue, 01 Feb 2022")
end
end

it 'renders the body with the reminder email text' do
expect(subject.body.encoded).to include("Custom reminder message")
end
end
end