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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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 @@ -226,6 +226,12 @@
<%= @organization.default_email_text.presence || 'Not defined' %>
</p>
</div>
<div class="col-lg-8">
<h3 class='font-bold'>Reminder email text:</h3>
<p>
<%= @organization.reminder_email_text.presence || 'Not defined' %>
</p>
</div>
</div>

<% if can_administrate? %>
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 @@ -138,6 +138,11 @@
<%= f.rich_text_area :default_email_text, placeholder: 'Enter distribution email content...' %>
<% end %>

<% 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: "Reminder Email Content", hint: default_reminder_email_text_hint.html_safe do %>
<%= f.rich_text_area :reminder_email_text, placeholder: 'Enter reminder email content...' %>
<% end %>

<%= f.input :logo, wrapper: :input_group do %>

<% if current_organization.logo.attached? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<p>Hello <%= @partner.name %>,</p>
<p><%= @reminder_email_text_interpolated.html_safe %></p>
<p>
This is a friendly reminder that <%= @organization.name %> requires your human essentials requests to be submitted by <%= @deadline.strftime('%a, %d %b %Y') %>
if you would like to receive a distribution next month.</p>
Expand Down
2 changes: 2 additions & 0 deletions app/views/reminder_deadline_mailer/notify_deadline.text.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Hello <%= @partner.name %>,

<%= @reminder_email_text_interpolated %>

This is a friendly reminder that <%= @organization.name %> requires your human essentials requests to be submitted by <%= @deadline.strftime('%a, %d %b %Y') %>
if you would like to receive a distribution next month.

Expand Down
6 changes: 6 additions & 0 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 Down Expand Up @@ -33,5 +34,10 @@
"be submitted by Tue, 01 Feb 2022")
end
end

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