完成课程留言点对点逻辑结构

This commit is contained in:
huang 2015-09-18 13:03:35 +08:00
parent e09cdb2587
commit f823046bc3
4 changed files with 31 additions and 16 deletions

View File

@ -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

View File

@ -9,5 +9,3 @@
</ul>
<div class="cl" style="margin-top: 30px; clear:both; overflow:hidden;"></div>
</div>

View File

@ -1,7 +1,5 @@
<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><%= @subject %> </p>
@ -10,13 +8,8 @@
<p>您的账号为:<%= @email %></p>
<p>密码为: <%= @password %></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>

View File

@ -97,7 +97,7 @@
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% if ma.course_message_type == "HomeworkCommon" %>
<% if ma.course_message_type == "HomeworkCommon" && ma.status != 1 %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布了作业:</span></li>
@ -175,7 +175,7 @@
<a href="javascript:void(0);"><%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a>
</li>
<li class="homepageNewsPubType fl"><%= link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">发布了课程留言</span>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">在课程中留言了</span>
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),