From f823046bc3f220203b49b180f02d2903429ca1e9 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 18 Sep 2015 13:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BE=E7=A8=8B=E7=95=99?= =?UTF-8?q?=E8=A8=80=E7=82=B9=E5=AF=B9=E7=82=B9=E9=80=BB=E8=BE=91=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 30 +++++++++++++++++-- .../mailer/homework_endtime__added.html.erb | 4 +-- .../mailer/send_invite_in_project.html.erb | 9 +----- app/views/users/user_messages.html.erb | 4 +-- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index c7165dfe7..81ada2f80 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -198,12 +198,36 @@ class JournalsForMessage < ActiveRecord::Base end end # 课程留言 - if jour_type == 'Course' + if self.jour_type == 'Course' + receivers = [] + teachers = [] + # 获取课程的老师 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) + if m.user.allowed_to?(:as_teacher, self.jour) + teachers << m end end + if self.reply_id == 0 # 主留言,即不是回复某条留言 + teachers.each do |teacher| + if teacher.user_id != self.user_id + receivers << teacher.user_id + end + end + else # 留言回复 + reply_to = User.find(self.reply_id) + if self.user_id != self.reply_id # 添加我回复的那个人 + receivers << reply_to.id + end + # 给老师发送。 过滤条件:老师自己给自己发;回复对象为老师则排除改老师 + teachers.each do |teacher| + if teacher.user_id != self.user_id && self.reply_id != teacher.user_id + receivers << teacher.user_id + end + end + end + receivers.each do |r| + self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false) + end end end diff --git a/app/views/mailer/homework_endtime__added.html.erb b/app/views/mailer/homework_endtime__added.html.erb index ce832d362..e639ab51a 100644 --- a/app/views/mailer/homework_endtime__added.html.erb +++ b/app/views/mailer/homework_endtime__added.html.erb @@ -8,6 +8,4 @@
- - - + \ No newline at end of file diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb index d752d6060..54435e9ef 100644 --- a/app/views/mailer/send_invite_in_project.html.erb +++ b/app/views/mailer/send_invite_in_project.html.erb @@ -1,7 +1,5 @@ -
-
-
- - + \ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c7443ecf3..db8b6c326 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -97,7 +97,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status != 1 %>