Additional fixes to email markup and logic [SCI-443]

This commit is contained in:
Oleksii Kriuchykhin 2016-10-07 09:45:30 +02:00
parent 3f219e1bfe
commit 90c853743c
4 changed files with 18 additions and 8 deletions

View file

@ -16,8 +16,10 @@ class AppMailer < Devise::Mailer
def notification(user, notification) def notification(user, notification)
@user = user @user = user
@notification = notification @notification = notification
headers = { to: @user.email, headers = {
subject: "#{I18n.t('notifications.email_title')} - #{notification.title}" } to: @user.email,
subject: I18n.t('notifications.email_title')
}
mail(headers) mail(headers)
end end
end end

View file

@ -31,11 +31,19 @@ class UserNotification < ActiveRecord::Base
end end
def send_email def send_email
if notification.type_of == 'system_message' case notification.type_of
send_email_notification(user, notification) when 'system_message'
elsif user.assignments_notification_email ||
user.recent_notification_email
send_email_notification(user, notification) send_email_notification(user, notification)
when 'assignment'
send_email_notification(
user,
notification
) if user.assignments_notification_email
when 'recent_changes'
send_email_notification(
user,
notification
) if user.recent_notification_email
end end
end end
end end

View file

@ -1,6 +1,6 @@
<p>Hello <%= @user.name %>!</p> <p>Hello <%= @user.name %>!</p>
<p>You got new notification!</p> <p><%= I18n.t("notifications.email_title") %></p>
<p>Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %></p> <p>Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %></p>

View file

@ -1523,7 +1523,7 @@ en:
assignment: "Assignment" assignment: "Assignment"
recent_changes: "Recent changes" recent_changes: "Recent changes"
system_message: "sciNote system message" system_message: "sciNote system message"
email_title: "sciNote notification" email_title: "You've received a sciNote notification!"
# This section contains general words that can be used in any parts of # This section contains general words that can be used in any parts of
# application. # application.