|
|
|
@ -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
|
|
|
|
@ -128,8 +127,14 @@ class User < Principal
|
|
|
|
|
has_many :messages, :foreign_key => 'author_id'
|
|
|
|
|
has_one :user_score, :dependent => :destroy
|
|
|
|
|
has_many :documents # 项目中关联的文档再次与人关联
|
|
|
|
|
# 关联虚拟表
|
|
|
|
|
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 :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"'
|
|
|
|
|
# 邮件邀请状态
|
|
|
|
|
# has_many :invite_lists
|
|
|
|
|
# end
|
|
|
|
@ -235,6 +240,24 @@ class User < Principal
|
|
|
|
|
|
|
|
|
|
# ======================================================================
|
|
|
|
|
|
|
|
|
|
# 查询用户未读过的记录
|
|
|
|
|
# 用户留言记录
|
|
|
|
|
def count_new_jour
|
|
|
|
|
count = self.new_jours.count
|
|
|
|
|
# count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 查询指派给我的缺陷记录
|
|
|
|
|
def count_new_issue_assign_to
|
|
|
|
|
self.issue_assigns
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 查询指派给我的缺陷记录
|
|
|
|
|
def issue_status_update
|
|
|
|
|
self.status_updates
|
|
|
|
|
end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
def extensions
|
|
|
|
|
self.user_extensions ||= UserExtensions.new
|
|
|
|
|
end
|
|
|
|
@ -258,7 +281,7 @@ class User < Principal
|
|
|
|
|
###添加留言 fq
|
|
|
|
|
def add_jour(user, notes, reference_user_id = 0, options = {})
|
|
|
|
|
if options.count == 0
|
|
|
|
|
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true)
|
|
|
|
|
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false)
|
|
|
|
|
else
|
|
|
|
|
jfm = self.journals_for_messages.build(options)
|
|
|
|
|
jfm.save
|
|
|
|
@ -292,11 +315,6 @@ class User < Principal
|
|
|
|
|
end
|
|
|
|
|
## end
|
|
|
|
|
|
|
|
|
|
# 查询用户未读过的记录
|
|
|
|
|
def count_new_jour
|
|
|
|
|
count = self.journals_for_messages.where("status=?", 1).count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#added by nie
|
|
|
|
|
def count_new_journal_reply
|
|
|
|
|
count = self.journal_reply.count
|
|
|
|
|