消息---用户留言界面

This commit is contained in:
huang 2015-08-20 12:44:32 +08:00
parent b256d0a24e
commit e4dda89c07
3 changed files with 50 additions and 15 deletions

View File

@ -98,7 +98,7 @@ class UsersController < ApplicationController
# 用户消息
# 说明: homework 发布作业message讨论区 news新闻 poll问卷works_reviewers作品评阅works_reply:作品回复
# issue问题journal缺陷状态更新 forum公共贴吧
# issue问题journal缺陷状态更新 forum公共贴吧: user_feedback: 用户留言
def user_messages
unless User.current.logged?
render_403
@ -115,9 +115,11 @@ class UsersController < ApplicationController
@user_course_messages = @user.course_messages.reverse
@user_forge_messages = @user.forge_messages.reverse
@user_memo_messages = @user.memo_messages.reverse
@user_feedback_messages = @user.user_feedback_messages.reverse
@user_course_messages_count = @user_course_messages.count
@user_forge_messages_count = @user_forge_messages.count
@user_memo_messages_count = @user_memo_messages.count
@user_feedback_messages_count = @user_feedback_messages.count
when 'homework'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
@ -126,6 +128,7 @@ class UsersController < ApplicationController
@user_course_messages_count = @user_course_messages.count
when 'forge_message'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc")
@user_forge_messages_count = @user_forge_messages.count
when 'course_news'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc")
@user_course_messages_count = @user_course_messages.count
@ -150,6 +153,9 @@ class UsersController < ApplicationController
when 'forum'
@user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc")
@user_memo_messages_count = @user_memo_messages.count
when 'user_feedback'
@user_feedback_messages = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "Principal", @user).order("created_at desc")
@user_feedback_messages_count = @user_feedback_messages.count
else
render_404
return

View File

@ -209,21 +209,24 @@ class JournalsForMessage < ActiveRecord::Base
end
else # 留言回复
# 添加留言回复人
# reply_to = User.find(self.reply_id)
if self.user_id != self.parent.user_id && self.user_id != self.reply_id && self.user_id != self.jour_id# 如果回帖人不是用户自己
receivers << User.find(self.reply_id)
reply_to = User.find(self.reply_id)
if self.user_id != self.parent.user_id # 如果回帖人不是用户自己
receivers << self.parent.jour
if self.reply_id != self.parent.user_id
receivers << reply_to
end
else # 用户自己回复别人的,别人收到消息通知
if self.user_id != self.reply_id # 过滤掉自己回复自己的
receivers << reply_to
end
end
# if self.user_id != self.parent.jour_id
# receivers << self.parent.jour
# end
end
if self.jour_type == 'Principal'
if self.user_id != self.jour_id
receivers.each do |r|
self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false)
end
end
end
end
end

View File

@ -25,6 +25,7 @@
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %></a></li>
<% end %>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %></a></li>
<% end %>
<%# 项目相关消息 %>
<% unless @user_forge_messages.nil? %>
@ -48,6 +49,11 @@
<% end %>
<% end %>
<%# 用户留言 %>
<% unless @user_forge_messages.nil? %>
<% unless @user_forge_messages_count > 0 %>
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %></a></li>
<% end %>
<% end %>
</ul>
</li>
</ul>
@ -214,6 +220,26 @@
<% end %>
<% end %>
<% end %>
<%# 用户留言消息 %>
<% unless @user_feedback_messages.nil? %>
<% @user_forge_messages.each do |urm| %>
<% if urm.memo_type == "Memo" %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(urm.memo.author), :width => "30", :height => "30") %></a>
</li>
<li class="homepageNewsPublisher fl">
<a href="javascript:void(0);" class="<%= urm.viewed == 0 ? "newsBlack" : "newsBlue" %>"><%= urm.memo.author %></a>
</li>
<li class="<%= urm.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">回复了贴吧帖子</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to urm.memo.subject, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "#{urm.viewed == 0 ? "newsBlack" : "newsGrey"}" %></a>
</li>
<li class="homepageNewsTime fl"><%= time_tag(urm.memo.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>
<% end %>
<% else %>
<div class="flash notice">暂无消息!</div>
<% end %>