cirandas.net

ref: master

plugins/volunteers/models/volunteers_plugin/period.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class VolunteersPlugin::Period < ApplicationRecord

  attr_accessible :name
  attr_accessible :start, :end
  attr_accessible :owner_type
  attr_accessible :minimum_assigments
  attr_accessible :maximum_assigments

  belongs_to :owner, polymorphic: true

  has_many :assignments, -> {
    includes :profile
  }, class_name: 'VolunteersPlugin::Assignment', foreign_key: :period_id, dependent: :destroy

  validates_presence_of :owner
  validates_presence_of :name
  validates_presence_of :start, :end

  extend OrdersPlugin::DateRangeAttr::ClassMethods
  date_range_attr :start, :end

  extend SplitDatetime::SplitMethods
  split_datetime :start
  split_datetime :end

end