2014-04-14 09:50:36 +08:00
|
|
|
|
|
|
|
class ContestingSoftapplication < ActiveRecord::Base
|
|
|
|
attr_accessible :contest_id, :description, :softapplication_id, :user_id
|
|
|
|
|
|
|
|
belongs_to :contest
|
2014-07-31 14:02:25 +08:00
|
|
|
belongs_to :softapplication, :dependent => :destroy
|
2014-04-14 09:50:36 +08:00
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
|
|
|
|
def self.create_softapplication_contesting(contest_id, softapplication_id, description = nil)
|
|
|
|
self.create(:user_id => User.current.id, :contest_id => contest_id,
|
|
|
|
:softapplication_id => softapplication_id, :description => description)
|
|
|
|
end
|
2014-05-13 11:44:29 +08:00
|
|
|
|
|
|
|
def self.create_work_contesting(contest_id, softapplication_id)
|
|
|
|
self.create(:user_id => User.current.id, :contest_id => contest_id,
|
|
|
|
:softapplication_id => softapplication_id)
|
|
|
|
end
|
2014-05-14 16:19:12 +08:00
|
|
|
|
|
|
|
def update_reward(which)
|
|
|
|
self.update_attribute(:reward,which)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_reward
|
|
|
|
self.reward
|
|
|
|
end
|
2014-04-14 09:50:36 +08:00
|
|
|
|
|
|
|
end
|