Sha256: 5c941c2e7cb822bdd7ff71e6a90ec648d04072692f44af50e42386e1260cc50a
Contents?: true
Size: 1.96 KB
Versions: 26
Compression:
Stored size: 1.96 KB
Contents
class Backlog < ActiveRecord::Base validates_presence_of :name validates_length_of :name, :allow_nil => false, :maximum => 64 validates_inclusion_of :track_todo, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank] validates_inclusion_of :track_done, :in => [true, false], :allow_nil => true, :message => ActiveRecord::Errors.default_error_messages[:blank] validates_inclusion_of :track_times, :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] validates_length_of :invoice_code, :allow_nil => true, :maximum => 255 has_many :tasks, :order => 'period_id, position', :dependent => :destroy 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 estimate_data(date) total = 0 periods.each do |period| total += period.estimate_data(date) end total end def work_data(date) total = 0 periods.each do |period| total += period.work_data(date) end total 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? !invoice_code.nil? && invoice_code.length > 0 end end
Version data entries
26 entries across 26 versions & 1 rubygems