Sha256: d1abbd642d5bcb9ac3a876b9c9a25c7ec5e9774df73d23178ca7d29a8a35cbab
Contents?: true
Size: 1.74 KB
Versions: 24
Compression:
Stored size: 1.74 KB
Contents
class Backlog < ActiveRecord::Base validates_presence_of :name validates_length_of :name, :allow_nil => false, :maximum => 64 validates_uniqueness_of :name validates_inclusion_of :track_todo, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank] validates_inclusion_of :enable_subtasks, :in => [true, false], :allow_nil => false, :message => ActiveRecord::Errors.default_error_messages[:blank] validates_inclusion_of :enable_customer, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank] validates_inclusion_of :enable_users, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank] belongs_to :work_account belongs_to :customer has_many :tasks, :order => 'period_id, position', :dependent => :destroy has_many :unplanned_tasks, :class_name => 'Task', :conditions => 'period_id IS NULL', :order => 'position' def active_tasks tasks.find(:all, :conditions => "finished_at IS NULL", :order => "position") end def recent_tasks Task.find(:all, :conditions => "period_id = #{periods.first.id} AND (position IS NOT NULL OR finished_at >= '#{1.week.ago.iso8601}')", :order => "position, finished_at") end def tasks_with_children tasks.map {|t| t.self_with_children}.flatten end def first_active_period t = active_tasks periods = t.map {|t| t.period}.compact.uniq periods = periods.select {|p| p.active?} periods.sort_by {|p| p.end_on}.first end def enable_invoicing? work_account && work_account.enable_invoicing? end def track_done? not work_account.nil? end def track_times? work_account && work_account.track_times? end end
Version data entries
24 entries across 24 versions & 1 rubygems