Skip to content

Commit

Permalink
updated complete_feedback mailer to use do-not-reply as sender addres…
Browse files Browse the repository at this point in the history
…s. Updated default margins for plan exports
  • Loading branch information
briri committed Jun 3, 2020
1 parent 66f71fb commit c4ea3ab
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 16 deletions.
44 changes: 31 additions & 13 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
class UserMailer < ActionMailer::Base
include MailerHelper

# =====================================
# Start DMPTool Customization
# =====================================
include Dmptool::Mailers::UserMailer
# =====================================
# End DMPTool Customization
# =====================================

helper MailerHelper
helper FeedbacksHelper

Expand Down Expand Up @@ -64,19 +73,28 @@ def feedback_notification(recipient, plan, requestor)
end
end

def feedback_complete(recipient, plan, requestor)
@requestor = requestor
@user = recipient
@plan = plan
@phase = plan.phases.first
if recipient.active?
FastGettext.with_locale FastGettext.default_locale do
mail(to: recipient.email,
from: requestor.org.contact_email,
subject: _("%{application_name}: Expert feedback has been provided for %{plan_title}") % {application_name: Rails.configuration.branding[:application][:name], plan_title: @plan.title})
end
end
end
# =====================================
# Start DMPTool Customization
# See lib/dmptool/mailer/user_mailer for override of this method that changes
# the sender address to be the 'do-not-reply' one defined in Branding.yml. AWS
# SES does not allow the sender to be be from a different domain!
# =====================================
# def feedback_complete(recipient, plan, requestor)
# @requestor = requestor
# @user = recipient
# @plan = plan
# @phase = plan.phases.first
# if recipient.active?
# FastGettext.with_locale FastGettext.default_locale do
# mail(to: recipient.email,
# from: requestor.org.contact_email,
# subject: _("%{application_name}: Expert feedback has been provided for %{plan_title}") % {application_name: Rails.configuration.branding[:application][:name], plan_title: @plan.title})
# end
# end
# end
# =============================
# End DMPTool Customization
# =============================

def feedback_confirmation(recipient, plan, requestor)
user = requestor
Expand Down
31 changes: 28 additions & 3 deletions app/models/settings/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,35 @@ class Template < RailsSettings::SettingObject

VALID_FORMATS = ['csv', 'html', 'pdf', 'text', 'docx']

# =================================
# Start DMPTool Customization
# Update margins to 25mm default
# =================================
# DEFAULT_SETTINGS = {
# formatting: {
# margin: {
# top: 25,
# bottom: 20,
# left: 12,
# right: 12
# },
# font_face: 'Arial, Helvetica, Sans-Serif',
# font_size: 10 # pt
# },
# max_pages: 3,
# fields: {
# admin: VALID_ADMIN_FIELDS,
# questions: :all
# },
# title: ""
# }
DEFAULT_SETTINGS = {
formatting: {
margin: {
top: 25,
bottom: 20,
left: 12,
right: 12
bottom: 25,
left: 25,
right: 25
},
font_face: 'Arial, Helvetica, Sans-Serif',
font_size: 10 # pt
Expand All @@ -45,6 +67,9 @@ class Template < RailsSettings::SettingObject
},
title: ""
}
# =================================
# End DMPTool Customization
# =================================

validate do
formatting = value['formatting']
Expand Down
29 changes: 29 additions & 0 deletions lib/dmptool/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module Dmptool

module Mailers

module UserMailer

# AWS SES does not allow the sender to be be from a different domain so
# we remove the `from:` that was being used to pretendd it is coming from
# the Org's contact_email
def feedback_complete(recipient, plan, requestor)
@requestor = requestor
@user = recipient
@plan = plan
@phase = plan.phases.first
if recipient.active?
FastGettext.with_locale FastGettext.default_locale do
mail(to: recipient.email,
subject: _("%{application_name}: Expert feedback has been provided for %{plan_title}") % {application_name: Rails.configuration.branding[:application][:name], plan_title: @plan.title})
end
end
end

end

end

end

0 comments on commit c4ea3ab

Please sign in to comment.