diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d77ccb958..bc3719685 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -115,31 +115,42 @@ class UsersController < ApplicationController
@user_course_messages = @user.course_messages.reverse
@user_forge_messages = @user.forge_messages.reverse
@user_forum_messages = @user.forum_messages.reverse
+ @user_course_messages_count = @user_course_messages.count
+ @user_forge_messages_count = @user_forum_messages.count
when 'homework'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
- @user_forge_messages = nil
+ @user_course_messages_count = @user_course_messages.count
when 'course_message'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
+ @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")
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
when 'forge_news'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc")
when 'poll'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc")
+ @user_course_messages_count = @user_course_messages.count
when 'works_reviewers'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc")
+ @user_course_messages_count = @user_course_messages.count
when 'works_reply'
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc")
+ @user_course_messages_count = @user_course_messages.count
when 'issue'
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc")
- @user_course_messages = nil
+ @user_forge_messages_count = @user_forge_messages.count
when 'journal' # 缺陷状态更新、留言
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc")
- @user_course_messages = nil
+ @user_forge_messages_count = @user_forge_messages.count
when 'forum'
@user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc")
+ @user_forum_messages_count = @user_forum_messages.count
+ else
+ render_404
+ return
end
respond_to do |format|
format.html{render :layout=>'base_users_new'}
diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb
index 089dca32f..233b5bcb2 100644
--- a/app/views/users/user_messages.html.erb
+++ b/app/views/users/user_messages.html.erb
@@ -7,19 +7,31 @@
- <%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
-
- - <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
- - <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
- - <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
-
- - <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
- - <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
- - <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
-
- - <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
- - <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
- - <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
- - <%= link_to "项目新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
+ <%# 课程相关消息 %>
+ <% unless @user_course_messages.nil? %>
+ <% unless @user_course_messages_count > 0 %>
+ - <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
+ <% end %>
+ - <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
+ - <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
+ - <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
+ <% unless @user_course_messages_count > 0 %>
+ - <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
+ <% end %>
+ - <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
+ <% end %>
+ <%# 项目相关消息 %>
+ <% unless @user_forge_messages.nil? %>
+ - <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
+ - <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
+ - <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
+ - <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
+ <% end %>
+ <%# 公共贴吧 %>
+ <% unless @user_forum_messages.nil? %>
+ - <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
+ <% end %>
+ <%# 用户留言 %>
@@ -82,7 +94,7 @@
"><%= ucm.course_message.user %>
">作品评阅
- <%= link_to ucm.course_message.comment, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
+ <%= link_to ucm.course_message.comment, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %> %>
<%= time_tag(ucm.course_message.created_at).html_safe %>
<% end %>
@@ -92,7 +104,7 @@
"><%= ucm.course_message.user %>
">作品讨论
- <%= link_to ucm.course_message.notes, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
+ <%= link_to ucm.course_message.notes, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
<%= time_tag(ucm.course_message.created_on).html_safe %>
<% end %>
@@ -167,6 +179,8 @@
<% end %>
<% end %>
<% end %>
+ <% unless @user_forum_messages.nil? %>
+ <% end %>
<% else %>
暂无消息!
<% end %>