添加查看通知/新闻的消息状态更新
This commit is contained in:
parent
e89fbd2c8e
commit
d980513551
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue