Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq
This commit is contained in:
commit
3b49547b37
|
@ -190,20 +190,21 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 课程留言消息通知
|
||||
# 课程/作品回复 留言消息通知
|
||||
def act_as_course_message
|
||||
if self.jour_type == 'StudentWorksScore'
|
||||
if self.user_id != self.jour.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
else if jour_type == 'Course'
|
||||
self.jour.members.each do |m|
|
||||
if m.user_id != self.user_id
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.jour.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
# 课程留言
|
||||
if jour_type == 'Course'
|
||||
self.jour.members.each do |m|
|
||||
if m.user.allowed_to?(:as_teacher, self.jour) && m.user_id != self.user_id # 仅仅留言则给该课程的老师发消息
|
||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.jour.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 用户留言消息通知
|
||||
|
|
|
@ -50,7 +50,7 @@ class Mailer < ActionMailer::Base
|
|||
# author: alan
|
||||
# 邀请未注册用户加入项目
|
||||
# 功能: 在加入项目的同时自动注册用户
|
||||
def send_invite_in_project(email, project, invitor)
|
||||
def send_invite_in_project(email, project, invitor)
|
||||
@email = email
|
||||
@subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
|
||||
@password = newpass(6)
|
||||
|
@ -208,44 +208,17 @@ class Mailer < ActionMailer::Base
|
|||
end
|
||||
|
||||
# 作业截止时间邮件提醒
|
||||
def homework_endtime__added(homework_common, course)
|
||||
# modify by nwb
|
||||
#如果是直接留言并且留言对象是课程
|
||||
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
|
||||
|
||||
@author = journals_for_message.user
|
||||
#课程的教师
|
||||
@members = course_all_member journals_for_message.jour
|
||||
|
||||
|
||||
#收件人邮箱
|
||||
students = course.student
|
||||
recipients ||= []
|
||||
students.each do |students|
|
||||
recipients << recipients.user.mail
|
||||
end
|
||||
mail :to => @recipients,
|
||||
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ",
|
||||
:filter => true
|
||||
# elsif journals_for_message.jour.class.to_s.to_sym == :Bid
|
||||
# if !journals_for_message.jour.author.notify_about? journals_for_message
|
||||
# return -1
|
||||
# end
|
||||
#
|
||||
# mail :to => recipients, :subject => @title,:filter => true
|
||||
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
|
||||
if !journals_for_message.jour.author.notify_about? journals_for_message
|
||||
return -1
|
||||
end
|
||||
mail :to => recipients, :subject => @title,:filter => true
|
||||
else
|
||||
mail :to => recipients1, :subject => @title,:filter => true
|
||||
end
|
||||
recipients ||= []
|
||||
# 将帖子创建者邮箱地址加入数组
|
||||
recipients << course.student
|
||||
# 回复人邮箱地址加入数组
|
||||
recipients << @author.mail
|
||||
def homework_endtime__added(homework_common, user_id)
|
||||
user = User.find(user_id)
|
||||
@subject = "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} "
|
||||
@token = Token.get_token_from_user(user, 'autologin')
|
||||
@homework_endtime_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value))
|
||||
@homework_endtime_name = homework_common.name
|
||||
@author = homework_common.user
|
||||
#收件人邮箱
|
||||
recipient = user.mail
|
||||
mail :to => recipient,
|
||||
:subject => "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} "
|
||||
end
|
||||
|
||||
# 公共讨论区发帖、回帖添加邮件发送信息
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<div class="mail_box" style="border:1px solid #c8c8c8; width:570px; height: auto; padding:15px; margin-top:10px; margin-bottom:10px;">
|
||||
<ul style="list-style-type:none; margin:0; padding:0;">
|
||||
<li style="list-style-type:none; margin:0; padding:0;"><span style="float: left;"><strong><%= l(:mail_issue_content)%></strong></span>
|
||||
<span style="float: left; width: 526px">
|
||||
<p><%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @homework_endtime_name, @homework_endtime_url%> <span style="color: red">截止时间快到了!</span></p>
|
||||
<p style="color: red;font-size: 12px;">如果您还未交作业,请赶紧提交作业!</p>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
|
||||
</div>
|
||||
|
||||
|
|
@ -24,3 +24,5 @@ zh:
|
|||
mail_course_title_userin: "在课程"
|
||||
mail_course_homework_active: "中发布了作业"
|
||||
mail_attention: "请您关注!"
|
||||
mail_homework_endtime: "作业截止时间快到了!"
|
||||
mail_homework: "作业:"
|
|
@ -10,7 +10,8 @@ namespace :homework_endtime do
|
|||
if homework_common.end_time.day - Date.today.day < 2 && homework_common.end_time.year == Date.today.year
|
||||
homework_common.course.student.each do |s|
|
||||
homework_common.course_messages << CourseMessage.new(:user_id => s.student_id, :course_id => homework_common.course_id, :viewed => false, :status => true)
|
||||
Mailer.run.homework_endtime__added(homework_common, homework_common.course)
|
||||
# 发送邮件通知
|
||||
Mailer.homework_endtime__added(homework_common, s.student_id).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue