From d980513551a6b34775483240f4d86f0f86aece17 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 2 Sep 2015 10:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9F=A5=E7=9C=8B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5/=E6=96=B0=E9=97=BB=E7=9A=84=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 10 ++++---- app/controllers/news_controller.rb | 36 +++++++++++++++------------- app/controllers/users_controller.rb | 20 ++++++++-------- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 0995d1304..67fec1b71 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -119,12 +119,14 @@ class IssuesController < ApplicationController end # 缺陷状态更新 query_journals = @issue.journals - if User.current.id == @issue.author_id query_journals.each do |query_journal| - query_journal.forge_messages.update_all(:viewed => true) + query_journal.forge_messages.each do |f| + if User.current.id == f.user_id + f.update_attributes(:viewed => true) + end + end end - end - # + # end @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index d445fc77c..d5c248f77 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -99,30 +99,32 @@ class NewsController < ApplicationController end def show - #更新news对应的forge_messages的viewed字段 - query_forge_news = @news.forge_messages - query_forge_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end + # 更新news对应的forge_messages的消息viewed字段 + if @project + query_message_news = @news.forge_messages + else + query_message_news = @news.course_messages end - #更新news对应的course_messages的viewed字段 - query_course_news = @news.course_messages - query_course_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end + query_message_news.each do |query| + if User.current.id == query.user_id + query.update_attributes(:viewed => true) + end end - #更新项目新闻的评阅的viewed字段 - current_forge_comments = @news.comments - current_forge_comments.each do |current_forge_comment| - query_forge_comment = current_forge_comment.forge_messages - query_forge_comment.each do |query| + # 更新项目新闻的评阅的消息viewed字段 + current_message_comments = @news.comments + current_message_comments.each do |current_message_comment| + if @project + query_message_comment = current_message_comment.forge_messages + else + query_message_comment = current_message_comment.course_messages + end + query_message_comment.each do |query| if User.current.id == query.user_id query.update_attributes(:viewed => true) end end end + # end cs = CoursesService.new result = cs.show_course_news params,User.current diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 101fadcd8..2c7574be7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -106,16 +106,16 @@ class UsersController < ApplicationController return end # 当前用户查看消息,则设置消息为已读 - course_querys = @user.course_messages - forge_querys = @user.forge_messages - user_querys = @user.user_feedback_messages - forum_querys = @user.memo_messages - if User.current.id == @user.id - course_querys.update_all(:viewed => true) - forge_querys.update_all(:viewed => true) - user_querys.update_all(:viewed => true) - forum_querys.update_all(:viewed => true) - end + # course_querys = @user.course_messages + # forge_querys = @user.forge_messages + # user_querys = @user.user_feedback_messages + # forum_querys = @user.memo_messages + # if User.current.id == @user.id + # course_querys.update_all(:viewed => true) + # forge_querys.update_all(:viewed => true) + # user_querys.update_all(:viewed => true) + # forum_querys.update_all(:viewed => true) + # end # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count case params[:type] when nil