diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7b72d043c..5e8f3d5d6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -580,6 +580,8 @@ class UsersController < ApplicationController org_querys = OrgMessage.where("user_id=? and viewed=0", user) at_querys = AtMessage.where("user_id=? and viewed=0", user) contest_querys = ContestMessage.where(:user_id => user, :viewed => 0) + blog_querys = BlogMessage.where(:user_id => user, :viewed => 0) + applied_querys = AppliedMessage.where("user_id=? and viewed =?", user, 0) course_querys.update_all(:viewed => true) unless course_querys.nil? forge_querys.update_all(:viewed => true) unless forge_querys.nil? user_querys.update_all(:viewed => true) unless user_querys.nil? @@ -587,7 +589,8 @@ class UsersController < ApplicationController org_querys.update_all(:viewed => true) unless org_querys.nil? at_querys.update_all(:viewed => true) unless at_querys.nil? contest_querys.update_all(:viewed => true) unless contest_querys.nil? - + blog_querys.update_all(:viewed => true) unless blog_querys.nil? + applied_querys.update_all(:viewed => true) unless applied_querys.nil? end end @@ -2008,7 +2011,7 @@ class UsersController < ApplicationController def show if User.current == @user # 全部设为已读 - if params[:viewed] == "all" + if params[:viewed] == "set_viewed" update_message_viewed(@user) end # 自己的主页显示消息 diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 7510af649..dcac601a4 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -308,7 +308,9 @@ module UsersHelper user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count at_count = user.at_messages.where(viewed: false).count contest_count = ContestMessage.where(:user_id => user, :viewed => 0).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count + contest_count + applied_count = AppliedMessage.where("user_id=? and viewed =?", user, 0).count + blog_count = BlogMessage.where(:user_id => user, :viewed => 0).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count + contest_count + blog_count + applied_count end def user_mail_notification_options(user) diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 6189d435f..cf241ce3b 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -6,6 +6,7 @@ class BlogComment < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :blog belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + has_many :blog_messages, :class_name => 'BlogMessage', :as => :blog_message, :dependent => :destroy acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" acts_as_attachable diff --git a/app/models/message.rb b/app/models/message.rb index 406ad067d..39902d757 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -48,7 +48,6 @@ class Message < ActiveRecord::Base has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy has_many :at_messages, as: :at_message, dependent: :destroy - has_many :blog_messages, :class_name => 'BlogMessage', :as => :blog_message, :dependent => :destroy has_many :ActivityNotifies,:as => :activity, :dependent => :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 135ffb0f2..afc099d35 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -407,7 +407,8 @@ class User < Principal at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count - messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count = BlogMessage.where("user_id=? and viewed=? and created_at >?", user.id, 0, onclick_time).count + messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count end # 查询指派给我的缺陷记录 diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 293bb9131..330dd1cca 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -101,7 +101,7 @@ <% end %> <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>