缺陷状态更新消息提醒

留言消息提醒
This commit is contained in:
huang 2015-08-13 16:55:25 +08:00
parent 69050b4271
commit c903325352
4 changed files with 30 additions and 3 deletions

View File

@ -117,6 +117,13 @@ class IssuesController < ApplicationController
if User.current.id == @issue.assigned_to_id if User.current.id == @issue.assigned_to_id
query.update_all(:viewed => true) query.update_all(:viewed => true)
end 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)
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}

View File

@ -29,6 +29,8 @@ class Journal < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联 # 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 被ForgeMessage虚拟关联
has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy
# end # end
attr_accessor :indice attr_accessor :indice
@ -48,7 +50,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes before_create :split_private_notes
# fq # fq
after_save :act_as_activity,:be_user_score,:act_as_forge_activity after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message
# end # end
#after_destroy :down_user_score #after_destroy :down_user_score
#before_save :be_user_score #before_save :be_user_score
@ -167,6 +169,13 @@ class Journal < ActiveRecord::Base
end end
# 缺陷状态更改,消息提醒
def act_as_forge_message
self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id,
:project_id => self.issue.project_id,
:viewed => false)
end
# 更新用户分数 -by zjc # 更新用户分数 -by zjc
def be_user_score def be_user_score
#新建了缺陷留言且留言不为空,不为空白 #新建了缺陷留言且留言不为空,不为空白

View File

@ -130,10 +130,11 @@ class User < Principal
# 关联虚拟表 # 关联虚拟表
has_many :forge_messages has_many :forge_messages
# end # end
# 虚拟转换 # 虚拟转换
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" 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 :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"'
has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"'
# 邮件邀请状态 # 邮件邀请状态
# has_many :invite_lists # has_many :invite_lists
# end # end
@ -250,6 +251,11 @@ class User < Principal
def count_new_issue_assign_to def count_new_issue_assign_to
self.issue_assigns self.issue_assigns
end end
# 查询指派给我的缺陷记录
def issue_status_update
self.status_updates
end
# end # end
def extensions def extensions

View File

@ -79,10 +79,15 @@
<%= "#{l(:label_project_message)}"+"("+User.current.count_new_issue_assign_to.count.to_s+")" %> <%= "#{l(:label_project_message)}"+"("+User.current.count_new_issue_assign_to.count.to_s+")" %>
<ul id="my_projects_message_ul" > <ul id="my_projects_message_ul" >
<% User.current.count_new_issue_assign_to.reverse.each do |issue_assign| %> <% User.current.count_new_issue_assign_to.reverse.each do |issue_assign| %>
<li title="<%=issue_assign.forge_message %>"> <li title="<%= issue_assign.forge_message %>">
<%= link_to issue_assign.forge_message, {:controller => 'issues', :action => 'show',id: issue_assign.forge_message_id, host: Setting.host_name }, target:"_blank" %> <%= link_to issue_assign.forge_message, {:controller => 'issues', :action => 'show',id: issue_assign.forge_message_id, host: Setting.host_name }, target:"_blank" %>
</li> </li>
<% end %> <% end %>
<% User.current.issue_status_update.reverse.each do |issue_update| %>
<li title="<%= issue_update.forge_message %>">
<%= link_to issue_update.forge_message.issue, {:controller => 'issues', :action => 'show',id: issue_update.forge_message_id, host: Setting.host_name }, target:"_blank" %>
</li>
<% end %>
</ul> </ul>
</li> </li>
<% end %> <% end %>