2014-04-04 17:54:20 +08:00
|
|
|
class Softapplication < ActiveRecord::Base
|
2014-04-11 09:00:00 +08:00
|
|
|
attr_accessible :android_min_version_available, :app_type_id, :app_type_name, :description, :name, :user_id, :contest_id
|
2014-04-09 09:25:24 +08:00
|
|
|
acts_as_attachable
|
2014-04-10 08:33:30 +08:00
|
|
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
2014-04-11 16:40:09 +08:00
|
|
|
has_many :contesting_softapplications, :dependent => :destroy
|
2014-04-10 08:33:30 +08:00
|
|
|
belongs_to :user
|
2014-04-11 09:00:00 +08:00
|
|
|
belongs_to :contest
|
2014-04-10 08:33:30 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
else
|
|
|
|
jfm = self.journals_for_messages.build(options)
|
|
|
|
jfm.save
|
|
|
|
jfm
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def set_commit(commit)
|
|
|
|
self.update_attribute(:commit, commit)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-04-04 17:54:20 +08:00
|
|
|
end
|