You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
29 lines
1.1 KiB
class TrainingTask < ActiveRecord::Base
|
|
attr_accessible :description, :project_id, :subject, :tracker_id
|
|
belongs_to :project,:touch=> true
|
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
|
belongs_to :tracker
|
|
has_many :journals, :as => :journalized, :dependent => :destroy
|
|
has_many :visible_journals,
|
|
:class_name => 'Journal',
|
|
:as => :journalized,
|
|
:conditions => Proc.new {
|
|
["(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(User.current, :view_private_notes)}))", false]
|
|
},
|
|
:readonly => true
|
|
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
|
has_one :praise_tread_cache, as: :object, dependent: :destroy
|
|
has_many :forge_acts, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy
|
|
|
|
acts_as_attachable
|
|
|
|
validates_presence_of :subject, :author
|
|
validates_length_of :subject, :maximum => 255
|
|
after_create :act_as_forge_activity
|
|
|
|
def act_as_forge_activity
|
|
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.project_id)
|
|
end
|
|
|
|
end
|