diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f677bc4d4..22aab5435 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -122,57 +122,62 @@ class UsersController < ApplicationController @new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count case params[:type] when nil - @all_message = MessageAll.where("user_id =?",@user).order("created_at desc") - @user_course_messages = CourseMessage.where("user_id =?",@user).order("created_at desc") - @user_forge_messages = ForgeMessage.where("user_id =?",@user).order("created_at desc") - @user_memo_messages = MemoMessage.where("user_id =?",@user).order("created_at desc") - @user_feedback_messages = UserFeedbackMessage.where("user_id =?",@user).order("created_at desc") - @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 + @message_alls = [] + messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages.each do |message_all| + @message_alls << message_all.message + end + + # @user_course_messages = MessageAll.where("user_id =? and message_type=?",@user,"CourseMessage").order("created_at desc") + # @user_forge_messages = MessageAll.where("user_id =? and message_type=?",@user,"ForgeMessage").order("created_at desc") + # @user_memo_messages = MessageAll.where("user_id =? and message_type=?",@user,"MemoMessage").order("created_at desc") + # @user_feedback_messages = MessageAll.where("user_id =? and message_type=?",@user,"UserFeedbackMessage").order("created_at desc") + # @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 + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") + #@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 + @message_alls = 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") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = 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 + @message_alls = 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") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count when 'course_news_reply' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count when 'forge_news_reply' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_forge_messagess_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_forge_messagess_count = @user_forge_messages.count 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 + @message_alls = 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 + @message_alls = 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 + @message_alls = 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_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count when 'issue_update' # 缺陷状态更新、留言 - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count 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 + @message_alls = 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 =?", "JournalsForMessage", @user).order("created_at desc") - @user_feedback_messages_count = @user_feedback_messages.count + @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + #@user_feedback_messages_count = @user_feedback_messages.count else render_404 return @@ -201,50 +206,62 @@ class UsersController < ApplicationController @new_message_count = @user.forge_messages.count + @user.memo_messages.count + @user.course_messages.count + @user.user_feedback_messages.count case params[:type] when nil - @user_message_all = MessageAll.where("user_id =?", @user).order("created_at desc") - @user_message_all_count = @user_message_all.count + @message_alls = [] + messages = MessageAll.where("user_id =?",@user).order("created_at desc") + messages.each do |message_all| + @message_alls << message_all.message + end + + # @user_course_messages = MessageAll.where("user_id =? and message_type=?",@user,"CourseMessage").order("created_at desc") + # @user_forge_messages = MessageAll.where("user_id =? and message_type=?",@user,"ForgeMessage").order("created_at desc") + # @user_memo_messages = MessageAll.where("user_id =? and message_type=?",@user,"MemoMessage").order("created_at desc") + # @user_feedback_messages = MessageAll.where("user_id =? and message_type=?",@user,"UserFeedbackMessage").order("created_at desc") + # @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 + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") + #@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 + @message_alls = 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") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = 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 + @message_alls = 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") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count when 'course_news_reply' - @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_course_messages_count = @user_course_messages.count + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_course_messages_count = @user_course_messages.count when 'forge_news_reply' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") - @user_forge_messagess_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Comment", @user).order("created_at desc") + #@user_forge_messagess_count = @user_forge_messages.count 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 + @message_alls = 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 + @message_alls = 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 + @message_alls = 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_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count when 'issue_update' # 缺陷状态更新、留言 - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") - @user_forge_messages_count = @user_forge_messages.count + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + #@user_forge_messages_count = @user_forge_messages.count 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 + @message_alls = 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 =?", "JournalsForMessage", @user).order("created_at desc") - @user_feedback_messages_count = @user_feedback_messages.count + @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + #@user_feedback_messages_count = @user_feedback_messages.count else render_404 return diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index e8bfac941..16a1bdf4b 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -37,217 +37,213 @@
<% if @new_message_count >0 %> <%# 课程消息 %> - <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> - <% if ucm.course_message_type == "News" %> - - <% end %> - <% if ucm.course_message_type == "Comment" %> - - <% end %> - <% if ucm.course_message_type == "HomeworkCommon" %> - - <% end %> - <% if ucm.course_message_type == "Poll" %> - - <% end %> - <% if ucm.course_message_type == "Message" %> - + <% end %> + <% if ma.course_message_type == "Message" %> + + <% end %> + <% if ma.course_message_type == "StudentWorksScore" %> + + <% end %> + <% if ma.course_message_type == "JournalsForMessage" %> + + <% end %> <% end %> + + <% if ma.class == ForgeMessage %> + <% if ma.forge_message_type == "Issue" %> + + <% end %> + <% if ma.forge_message_type == "Journal" %> + + <% end %> + <% if ma.forge_message_type == "Message" %> + + <% end %> + <% if ma.forge_message_type == "News" %> + + <% end %> + <% if ma.forge_message_type == "Comment" %> + + <% end %> + <% end %> + + <% if ma.class == MemoMessage %> + <% if ma.memo_type == "Memo" %> + + <% end %> + <% end %> + + <% if ma.class == UserFeedbackMessage %> + <% if ma.journals_for_message_type == "JournalsForMessage" %> + + <% end %> + <% end %> <% end %> <% end %> - <% unless @user_forge_messages.nil? %> - <% @user_forge_messages.each do |ufm| %> - <% if ufm.forge_message_type == "Issue" %> - - <% end %> - <% if ufm.forge_message_type == "Journal" %> - - <% end %> - <% if ufm.forge_message_type == "Message" %> - - <% end %> - <% if ufm.forge_message_type == "News" %> - - <% end %> - <% if ufm.forge_message_type == "Comment" %> - - <% end %> - <% end %> - <% end %> - <%# 公共贴吧 %> - <% unless @user_memo_messages.nil? %> - <% @user_memo_messages.each do |urm| %> - <% if urm.memo_type == "Memo" %> - - <% end %> - <% end %> - <% end %> - <%# 用户留言消息 %> - <% unless @user_feedback_messages.nil? %> - <% @user_feedback_messages.each do |ufm| %> - <% if ufm.journals_for_message_type == "JournalsForMessage" %> - - <% end %> - <% end %> - <% end %> <% else %>
暂无消息!
<% end %> diff --git a/app/views/users/user_messages_new.html.erb b/app/views/users/user_messages_new.html.erb index d861f867d..4f612b8b6 100644 --- a/app/views/users/user_messages_new.html.erb +++ b/app/views/users/user_messages_new.html.erb @@ -37,180 +37,214 @@
<% if @new_message_count >0 %> <%# 课程消息 %> - <% unless @user_message_all.nil? %> - <% @user_message_all.each do |uma| %> - <% if uma.message.course_message_type == "News" %> - - <% end %> - <% if uma.message.course_message_type == "Comment" %> - - <% end %> - <% if uma.message.course_message_type == "HomeworkCommon" %> - - <% end %> - <% if uma.message.course_message_type == "Poll" %> - - <% end %> - <% if uma.message.course_message_type == "Message" %> - + <% end %> + <% if ma.course_message_type == "Message" %> + + <% end %> + <% if ma.course_message_type == "StudentWorksScore" %> + + <% end %> + <% if ma.course_message_type == "JournalsForMessage" %> + + <% end %> <% end %> + + <% if ma.class == ForgeMessage %> + <% if ma.forge_message_type == "Issue" %> + + <% end %> + <% if ma.forge_message_type == "Journal" %> + + <% end %> + <% if ma.forge_message_type == "Message" %> + + <% end %> + <% if ma.forge_message_type == "News" %> + + <% end %> + <% if ma.forge_message_type == "Comment" %> + + <% end %> <% end %> - <% if uma.message.forge_message_type == "Journal" %> - + + <% if ma.class == MemoMessage %> + <% if ma.memo_type == "Memo" %> + + <% end %> <% end %> - <% if uma.message.forge_message_type == "Message" %> - + + <% if ma.class == UserFeedbackMessage %> + <% if ma.journals_for_message_type == "JournalsForMessage" %> + + <% end %> <% end %> - <% if uma.message.forge_message_type == "News" %> - - <% end %> - <% if uma.message.forge_message_type == "Comment" %> - - <% end %> - - <% end %> <% end %> - <%# 公共贴吧 %> - - <%# 用户留言消息 %> <% else %>
暂无消息!
diff --git a/db/schema.rb b/db/schema.rb index 0bd96d52d..791c5b14d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,11 +14,12 @@ ActiveRecord::Schema.define(:version => 20150824133916) do create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" end add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" @@ -881,14 +882,6 @@ ActiveRecord::Schema.define(:version => 20150824133916) do t.datetime "updated_at", :null => false end - create_table "message_publics", :force => true do |t| - t.integer "message_id" - t.string "massage_type" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "messages", :force => true do |t| t.integer "board_id", :null => false t.integer "parent_id" @@ -1539,6 +1532,7 @@ ActiveRecord::Schema.define(:version => 20150824133916) do t.string "identity_url" t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 + t.integer "gid" end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"