实现给教师发课程留言邮件时根据教师设置判断是否发送邮件
This commit is contained in:
parent
866ae3a38d
commit
45d17db8b6
|
@ -63,7 +63,10 @@ class Mailer < ActionMailer::Base
|
|||
#收件人邮箱
|
||||
@recipients ||= []
|
||||
@teachers.each do |teacher|
|
||||
@recipients << teacher.user.mail
|
||||
if teacher.user.notify_about? journals_for_message
|
||||
@recipients << teacher.user.mail
|
||||
end
|
||||
|
||||
end
|
||||
mail :to => @recipients,
|
||||
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
|
||||
|
|
|
@ -645,6 +645,7 @@ class User < Principal
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# Return true if the user is allowed to do the specified action on a specific context
|
||||
# Action can be:
|
||||
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
|
||||
|
@ -748,10 +749,39 @@ class User < Principal
|
|||
when News
|
||||
# always send to project members except when mail_notification is set to 'none'
|
||||
true
|
||||
#判定用户是否接受留言提醒邮件
|
||||
when JournalsForMessage
|
||||
##如果是直接留言并且留言对象是Project并且Project类型是课程(课程留言)
|
||||
if !object.at_user && object.jour.class.to_s.to_sym == :Project && object.jour.project_type == 1
|
||||
#根据用户设置邮件接收模式判定当前用户是否接受邮件提醒
|
||||
is_notified_project object.jour
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#用户是否接收project的消息提醒
|
||||
def is_notified_project arg
|
||||
if arg.is_a?(Project)
|
||||
case mail_notification
|
||||
when 'selected'
|
||||
notified_projects_ids.include?(arg.id)
|
||||
when 'only_my_events'
|
||||
projects.include?(arg)
|
||||
when 'only_assigned'
|
||||
false
|
||||
when 'only_owner'
|
||||
course = Course.find_by_extra(arg.identifier)
|
||||
course.teacher == self
|
||||
end
|
||||
#勾选的项目或用户的项目 TODO:需改
|
||||
#notified_projects_ids.include?(arg) || projects.include?(arg)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def self.current=(user)
|
||||
Thread.current[:current_user] = user
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue