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

ML - notification email format update #1773

Merged
merged 8 commits into from
Apr 5, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/dashboard/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create
@recipient = @message.recipient
@notification.set_read_by(@recipient, false)

UserMailer.notification_received(@recipient, @notification.sub_service_request).deliver unless @recipient.email.blank?
UserMailer.notification_received(@recipient, @notification.sub_service_request, @user).deliver unless @recipient.email.blank?
end
@messages = @notification.messages
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dashboard/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create
ssr = @notification.sub_service_request
@notifications = Notification.belonging_to(@user.id, params[:sub_service_request_id])

UserMailer.notification_received(@recipient, ssr).deliver unless @recipient.email.blank?
UserMailer.notification_received(@recipient, ssr, @user).deliver unless @recipient.email.blank?
flash[:success] = 'Notification Sent!'
else
@errors = @message.errors
Expand Down
7 changes: 5 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ def authorized_user_changed(protocol, recipients, modified_roles, action)
end
end

def notification_received(user, ssr)
def notification_received(user, ssr, sender)
@sender_name = sender.full_name

if ssr.present?
@ssr_id = ssr.id
@protocol_id = ssr.protocol_id
@is_service_provider = user.is_service_provider?(ssr)
end

send_email(user, "#{t(:mailer)[:email_title][:new]} #{t('mailer.email_title.general', email_status: 'Notification', type: 'Protocol', id: ssr.protocol.id)}")
send_email(user, "#{t(:mailer)[:email_title][:new]} #{t('mailer.email_title.general_dashboard', email_status: 'Notification', type: 'Protocol', id: ssr.protocol.id)}")
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/views/user_mailer/notification_received.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- link = @is_service_provider == 'true' ? Setting.get_value("dashboard_link") + 'admin/sub_service_requests/' + @ssr_id : Setting.get_value("dashboard_link")
= t('mailer.received', :portal_root_url => link)
- link = @is_service_provider == 'true' ? Setting.get_value("dashboard_link") + '/admin/sub_service_requests/' + @ssr_id.to_s : Setting.get_value("dashboard_link") + '/notifications/'
= t('mailer.received', link: link, protocol_id: @protocol_id, sender_name: @sender_name).html_safe
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,7 @@ en:
new: "New"
new_account_registration: "New SPARCRequest Account Registration"
general: "SPARCRequest %{email_status} (%{type} %{id})"
general_dashboard: "SPARCDashboard %{email_status} (%{type} %{id})"
application_title: "SPARCRequest"
add_intro: "An Authorized User has been added in"
contact_information: "Contact Information"
Expand All @@ -1328,7 +1329,7 @@ en:
p_id: "Protocol ID:"
p_info: "Protocol Information"
proxy: "SPARC Proxy Rights"
received: "You have received a new notification on your SPARCRequest User Dashboard. Please login @ %{portal_root_url} to retrieve it. Thank you."
received: "%{sender_name} sent you a new notification on your <a href='%{link}'>SPARCDashboard</a> in regard to protocol (%{protocol_id})"
role: "Role:"
s_name: "Sponsor Name"
sparc_dashboard_period: "SPARCDashboard."
Expand Down