|
|
|
@ -47,6 +47,40 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
MailerProxy.new(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 作业匿评开启
|
|
|
|
|
def send_mail_anonymous_comment_open(homework_common)
|
|
|
|
|
course = homework_common.course
|
|
|
|
|
course.student.each do |student|
|
|
|
|
|
user = student.user
|
|
|
|
|
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
|
|
|
|
@token = Token.get_token_from_user(user, 'autologin')
|
|
|
|
|
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
|
|
|
|
@anonymous_comment_close_name = homework_common.name
|
|
|
|
|
@author = homework_common.user
|
|
|
|
|
#收件人邮箱
|
|
|
|
|
recipient = user.mail
|
|
|
|
|
mail :to => recipient,
|
|
|
|
|
:subject => @subject
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 作业匿评关闭
|
|
|
|
|
def send_mail_anonymous_comment_close(homework_common)
|
|
|
|
|
course = homework_common.course
|
|
|
|
|
course.student.each do |student|
|
|
|
|
|
user = student.user
|
|
|
|
|
@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}"
|
|
|
|
|
@token = Token.get_token_from_user(user, 'autologin')
|
|
|
|
|
@anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
|
|
|
|
@anonymous_comment_close_name = homework_common.name
|
|
|
|
|
@author = homework_common.user
|
|
|
|
|
#收件人邮箱
|
|
|
|
|
recipient = user.mail
|
|
|
|
|
mail :to => recipient,
|
|
|
|
|
:subject => @subject
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# author: alan
|
|
|
|
|
# 邀请未注册用户加入项目
|
|
|
|
|
# 功能: 在加入项目的同时自动注册用户
|
|
|
|
@ -82,14 +116,15 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
@token = Token.get_token_from_user(user, 'autologin')
|
|
|
|
|
@project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value)
|
|
|
|
|
# 发送消息邀请
|
|
|
|
|
send_message(user,project)
|
|
|
|
|
send_message_request_member(user,project)
|
|
|
|
|
# end
|
|
|
|
|
mail :to => email, :subject => @subject
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 邀请信息消息 注:forge_message_id 为邀请人ID(特殊情况)
|
|
|
|
|
def send_message(user, project)
|
|
|
|
|
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "Project_Invite",:forge_message_id => User.current.id, :viewed => false)
|
|
|
|
|
def send_message_request_member(user, project)
|
|
|
|
|
key = newpass(6).to_s
|
|
|
|
|
ForgeMessage.create(:user_id => user.id, :project_id => project.id, :forge_message_type => "ProjectInvite",:forge_message_id => User.current.id, :viewed => false, :secret_key =>key)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# author: alan
|
|
|
|
|