diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index d45392af44..536f2d81e9 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -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, diff --git a/app/mailers/reminder_deadline_mailer.rb b/app/mailers/reminder_deadline_mailer.rb index 9407f41d27..a7268bbb94 100644 --- a/app/mailers/reminder_deadline_mailer.rb +++ b/app/mailers/reminder_deadline_mailer.rb @@ -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 diff --git a/app/models/organization.rb b/app/models/organization.rb index 55408e9d3c..5c70feaf7c 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -115,6 +115,7 @@ def flipper_id ].freeze has_rich_text :default_email_text + has_rich_text :reminder_email_text has_one_attached :logo diff --git a/app/views/organizations/_details.html.erb b/app/views/organizations/_details.html.erb index 5cfc6a2125..911ea552a8 100644 --- a/app/views/organizations/_details.html.erb +++ b/app/views/organizations/_details.html.erb @@ -76,6 +76,12 @@ <%= @organization.deadline_day.blank? ? 'Not defined' : "The #{@organization.deadline_day.ordinalize} of each month" %>

+
+

Additional text for reminder email

+

+ <%= @organization.reminder_email_text.presence || 'Not defined' %> +

+

Default Intake Location

diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb index 3f65bcbe39..b3f19ef5dc 100644 --- a/app/views/organizations/edit.html.erb +++ b/app/views/organizations/edit.html.erb @@ -87,6 +87,11 @@ <%= render 'shared/deadline_day_fields', f: f %> + <% default_reminder_email_text_hint = "You can use the variable %{partner_name} 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' %> diff --git a/app/views/reminder_deadline_mailer/notify_deadline.html.erb b/app/views/reminder_deadline_mailer/notify_deadline.html.erb index b9bce0e6c6..4db99382d5 100644 --- a/app/views/reminder_deadline_mailer/notify_deadline.html.erb +++ b/app/views/reminder_deadline_mailer/notify_deadline.html.erb @@ -6,3 +6,4 @@ if you would like to receive a distribution next month.

before this date and submit your request if you are intending to submit an essentials request.

Please contact <%= @organization.name %> at <%= @organization.email %> if you have any questions about this!

+

<%= @reminder_email_text_interpolated.html_safe %>

diff --git a/app/views/reminder_deadline_mailer/notify_deadline.text.erb b/app/views/reminder_deadline_mailer/notify_deadline.text.erb deleted file mode 100644 index feb1e10a5f..0000000000 --- a/app/views/reminder_deadline_mailer/notify_deadline.text.erb +++ /dev/null @@ -1,9 +0,0 @@ -Hello <%= @partner.name %>, - -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. - -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 <%= @organization.name %> at <%= @organization.email %> -if you have any questions about this! diff --git a/docs/user_guide/bank/getting_started_customization.md b/docs/user_guide/bank/getting_started_customization.md index e2bcbe2fbd..a84dd60c84 100644 --- a/docs/user_guide/bank/getting_started_customization.md +++ b/docs/user_guide/bank/getting_started_customization.md @@ -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: +
Hello [Partner's name], - +
+
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. - +
+
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 %> +
+
+Please contact [Your bank's name] at [Your bank's email] if you have any questions about this! - - - +
+
+[Additional text for reminder email (see below)] +
@@ -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 diff --git a/spec/mailers/reminder_deadline_mailer_spec.rb b/spec/mailers/reminder_deadline_mailer_spec.rb index fde33fa564..51c71c55c5 100644 --- a/spec/mailers/reminder_deadline_mailer_spec.rb +++ b/spec/mailers/reminder_deadline_mailer_spec.rb @@ -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 @@ -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