Sha256: 2e3a200fb521bb2fe2f65aa8fea4081615651f0039efd9aa91a6027c5a18362c

Contents?: true

Size: 831 Bytes

Versions: 3

Compression:

Stored size: 831 Bytes

Contents

# == Schema Information
#
# Table name: latenesses
#
#  id         :integer          not null, primary key
#  reason     :string(255)
#  shift_id   :integer
#  notify     :boolean          default(FALSE)
#  created_at :datetime
#  updated_at :datetime
#

class Lateness < ActiveRecord::Base

  belongs_to :shift

  validates_presence_of :reason
  validates_presence_of :shift

  after_save :notify_to_managers

  def shift_detail
    "AS #{shift.job_name} from #{shift.start_time.strftime('%H:%M')} to #{shift.end_time.strftime('%H:%M')} on #{shift.formatted_due_date}"
  end
  private

  def notify_to_managers
    if notify
      managers = shift.schedule.user.organizations.find_by_id(shift.schedule.organization_id).get_managers
      managers.each do |manager|
        manager.notify_message(self)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pshq_engine-0.1.6 app/models/lateness.rb
pshq_engine-0.1.5 app/models/lateness.rb
pshq_engine-0.0.1 app/models/lateness.rb