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