添加查看通知/新闻的消息状态更新
This commit is contained in:
parent
e89fbd2c8e
commit
d980513551
|
@ -119,12 +119,14 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
# 缺陷状态更新
|
# 缺陷状态更新
|
||||||
query_journals = @issue.journals
|
query_journals = @issue.journals
|
||||||
if User.current.id == @issue.author_id
|
|
||||||
query_journals.each do |query_journal|
|
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
|
||||||
|
# end
|
||||||
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
@journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
|
||||||
@journals.each_with_index {|j,i| j.indice = i+1}
|
@journals.each_with_index {|j,i| j.indice = i+1}
|
||||||
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
|
||||||
|
|
|
@ -99,30 +99,32 @@ class NewsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
#更新news对应的forge_messages的viewed字段
|
# 更新news对应的forge_messages的消息viewed字段
|
||||||
query_forge_news = @news.forge_messages
|
if @project
|
||||||
query_forge_news.each do |query|
|
query_message_news = @news.forge_messages
|
||||||
|
else
|
||||||
|
query_message_news = @news.course_messages
|
||||||
|
end
|
||||||
|
query_message_news.each do |query|
|
||||||
if User.current.id == query.user_id
|
if User.current.id == query.user_id
|
||||||
query.update_attributes(:viewed => true)
|
query.update_attributes(:viewed => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#更新news对应的course_messages的viewed字段
|
# 更新项目新闻的评阅的消息viewed字段
|
||||||
query_course_news = @news.course_messages
|
current_message_comments = @news.comments
|
||||||
query_course_news.each do |query|
|
current_message_comments.each do |current_message_comment|
|
||||||
if User.current.id == query.user_id
|
if @project
|
||||||
query.update_attributes(:viewed => true)
|
query_message_comment = current_message_comment.forge_messages
|
||||||
|
else
|
||||||
|
query_message_comment = current_message_comment.course_messages
|
||||||
end
|
end
|
||||||
end
|
query_message_comment.each do |query|
|
||||||
#更新项目新闻的评阅的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|
|
|
||||||
if User.current.id == query.user_id
|
if User.current.id == query.user_id
|
||||||
query.update_attributes(:viewed => true)
|
query.update_attributes(:viewed => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# end
|
||||||
|
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
result = cs.show_course_news params,User.current
|
result = cs.show_course_news params,User.current
|
||||||
|
|
|
@ -106,16 +106,16 @@ class UsersController < ApplicationController
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# 当前用户查看消息,则设置消息为已读
|
# 当前用户查看消息,则设置消息为已读
|
||||||
course_querys = @user.course_messages
|
# course_querys = @user.course_messages
|
||||||
forge_querys = @user.forge_messages
|
# forge_querys = @user.forge_messages
|
||||||
user_querys = @user.user_feedback_messages
|
# user_querys = @user.user_feedback_messages
|
||||||
forum_querys = @user.memo_messages
|
# forum_querys = @user.memo_messages
|
||||||
if User.current.id == @user.id
|
# if User.current.id == @user.id
|
||||||
course_querys.update_all(:viewed => true)
|
# course_querys.update_all(:viewed => true)
|
||||||
forge_querys.update_all(:viewed => true)
|
# forge_querys.update_all(:viewed => true)
|
||||||
user_querys.update_all(:viewed => true)
|
# user_querys.update_all(:viewed => true)
|
||||||
forum_querys.update_all(:viewed => true)
|
# forum_querys.update_all(:viewed => true)
|
||||||
end
|
# end
|
||||||
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
|
||||||
case params[:type]
|
case params[:type]
|
||||||
when nil
|
when nil
|
||||||
|
|
Loading…
Reference in New Issue