added admin and changed subject

This commit is contained in:
Harry Bomrah 2015-11-13 22:05:29 +08:00
parent 25bd56e8ce
commit 51e462d13c
2 changed files with 10 additions and 2 deletions

View File

@ -49,12 +49,20 @@ module Admin::NewsHelper
sleep(2) sleep(2)
end end
end end
users = Workgroup.where(:key => "admin").first.users rescue []
users.each do |user|
email = user.member_profile.email
if !email.nil? && email != ""
send_email(user.name, email, news, type)
sleep(2)
end
end
end end
def send_email(name, useremail, news, type) def send_email(name, useremail, news, type)
url = page_for_news_bulletin(news) url = page_for_news_bulletin(news)
template = (type == "approval" ? "email/new_news_email.html.erb" : "email/reapproval_news_email.html.erb") template = (type == "approval" ? "email/new_news_email.html.erb" : "email/reapproval_news_email.html.erb")
email = Email.new(:mail_to => useremail, :mail_subject => "New news : #{news.title}.", :template => template, :template_data => {"url" => url, "submitter" => current_user.name, "name" => name}) email = Email.new(:mail_to => useremail, :mail_subject => "校園新聞請審核通知", :template => template, :template_data => {"url" => url, "submitter" => current_user.name, "name" => name})
email.deliver email.deliver
end end

View File

@ -1,3 +1,3 @@
<h3>Hello <%= @data["name"] %>,</h3> <h3>Hello <%= @data["name"] %>,</h3>
<p><%= @data["rejector"] %> has rejected your news<%= @data["reason"].nil? || @data["reason"] == "" ? "." : ", because #{@data["reason"]}" %></p> <p>Your news has been rejected<%= @data["reason"].nil? || @data["reason"] == "" ? "." : ", because #{@data["reason"]}" %></p>
<a href="<%= @data['url'] %>" > Please click here to view the news.</a> <a href="<%= @data['url'] %>" > Please click here to view the news.</a>