18 lines
632 B
Ruby
18 lines
632 B
Ruby
class AppliedContest < ActiveRecord::Base
|
|
belongs_to :contest
|
|
belongs_to :user
|
|
#status :0 新建 1 已批准 2 拒绝
|
|
attr_accessible :role, :status, :contest_id, :user_id
|
|
|
|
has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy
|
|
after_create :send_appliled_message
|
|
|
|
# 仅仅给项目管理人员发送消息
|
|
def send_appliled_message
|
|
self.contest.managers.each do |member|
|
|
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :applied_user_id => self.user_id, :role => self.role)
|
|
end
|
|
# end
|
|
end
|
|
end
|