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)
@user = user
@notification = notification
headers = { to: @user.email,
subject: "#{I18n.t('notifications.email_title')} - #{notification.title}" }
headers = {
to: @user.email,
subject: I18n.t('notifications.email_title')
}
mail(headers)
end
end

View file

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

View file

@ -1,6 +1,6 @@
<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>

View file

@ -1523,7 +1523,7 @@ en:
assignment: "Assignment"
recent_changes: "Recent changes"
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
# application.