老师收到课程留言区的直接留言及对老师的回复的邮件提醒

This commit is contained in:
z9hang 2014-05-28 14:17:43 +08:00
parent 31804b3d45
commit daecf1a53b
4 changed files with 26 additions and 15 deletions

View File

@ -1,9 +1,7 @@
# Added by young
class JournalsForMessageObserver < ActiveRecord::Observer
def after_create(journals_for_message)
Thread.new do
Mailer.journals_for_message_add(User.current, journals_for_message).deliver
end
end
end

View File

@ -44,16 +44,7 @@ class Mailer < ActionMailer::Base
when :Bid
respond_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Project
if journals_for_message.jour.project_type == 1
project = journals_for_message.jour
@teachers = searchTeacherAndAssistant journals_for_message.jour
@recipients ||= []
@teachers.each do |teacher|
@recipients << teacher
end
mail :to => @recipients,
:subject => "您的课程#{journals_for_message.jour.name}中有了新的留言"
end
return -1 if journals_for_message.jour.project_type == Project::ProjectType_project
project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Contest
show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
@ -63,7 +54,23 @@ class Mailer < ActionMailer::Base
logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
return -1
end
mail :to => @mail.mail, :subject => @title
#如果是直接留言并且留言对象是Project并且Project类型是课程
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Project && journals_for_message.jour.project_type == 1
project = journals_for_message.jour
#课程的教师
@teachers = searchTeacherAndAssistant journals_for_message.jour
#收件人邮箱
@recipients ||= []
@teachers.each do |teacher|
@recipients << teacher.user.mail
end
mail :to => @recipients,
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
else
mail :to => @mail.mail, :subject => @title
end
end
# Builds a Mail::Message object used to email recipients of the added issue.
@ -433,7 +440,10 @@ class Mailer < ActionMailer::Base
headers[:to].delete(@author.mail) if headers[:to].is_a?(Array)
headers[:cc].delete(@author.mail) if headers[:cc].is_a?(Array)
end
if !User.current.nil?
#不给本人发邮件
headers[:to].delete(User.current.mail) if headers[:to].is_a?(Array)
end
if @author && @author.logged?
redmine_headers 'Sender' => @author.login
end

View File

@ -1617,6 +1617,7 @@ en:
label_class_hour: period
label_activity_time: publish date
label_your_course: your course
label_have_message : have a new message
# ajax异步验证
modal_valid_passing: can be used.

View File

@ -1497,6 +1497,8 @@ zh:
label_tags_numbers: Tag统计
label_max_number: 至多25个字符。
label_mail_attention: qq邮箱可能收不到此邮件其他邮箱如果没有收到可能在垃圾邮件中其中gmail与教育网邮箱的激活邮件有时比较慢请耐心等待。
label_your_course: 您的课程《
label_have_message : 》有新的留言
label_all_revisions: 所有版本:
label_upassword_info: 该密码在项目组内可共享
label_how_commit_code: 查看如何提交代码: