添加消息看过后即不显示功能

This commit is contained in:
huang 2015-08-13 10:10:01 +08:00
parent ee778b5968
commit 5dd2befe88
2 changed files with 10 additions and 6 deletions

View File

@ -112,7 +112,12 @@ class IssuesController < ApplicationController
end
def show
# 当前用户查看指派给他的缺陷消息,则设置消息为已读
query = @issue.forge_messages
if User.current.id == @issue.assigned_to_id
query.update_all(:viewed => true)
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)

View File

@ -109,7 +109,6 @@ class User < Principal
has_many :contests, :foreign_key => 'author_id', :dependent => :destroy
has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
has_many :journal_replies, :dependent => :destroy
has_many :activities, :dependent => :destroy
has_many :students_for_courses
@ -131,6 +130,9 @@ class User < Principal
# 关联虚拟表
has_many :forge_messages
# end
# 虚拟转换
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"'
# 邮件邀请状态
# has_many :invite_lists
@ -246,10 +248,7 @@ class User < Principal
# 查询指派给我的缺陷记录
def count_new_issue_assign_to
# count = self.forge_messages.where("viewed=? and forge_message_type=?", 0,Issue).count
self.forge_messages(:conditions => ["viewed=? and forge_message_type=?", 0,Issue])
#issue_assign_count = issue_assign_messages.count
self.issue_assigns
end
# end