Sha256: b8151bcfce72958ce9d1ce0c4a92213cc5b728535c305d43f58984d73440ea10

Contents?: true

Size: 1.31 KB

Versions: 599

Compression:

Stored size: 1.31 KB

Contents

module Caboose
  class CalendarEvent < ActiveRecord::Base    
    self.table_name = "calendar_events"
    
    belongs_to :calendar
    belongs_to :calendar_event_group
    attr_accessible :id        ,
      :calendar_id             ,
      :calendar_event_group_id , 
      :name                    ,
      :description             ,
      :location                ,
      :begin_date              ,
      :end_date                ,
      :all_day                 ,
      :repeats

    def self.events_for_day(calendar_id, d)
      q = ["calendar_id = ? 
        and cast(begin_date as date) <= ?
        and cast(end_date   as date) >= ?",
        calendar_id, d.to_date, d.to_date]
      self.where(q).reorder(:begin_date).all
    end
    
    def duplicate(d)
      e = CalendarEvent.create(        
        :calendar_id             => self.calendar_id,
        :calendar_event_group_id => self.calendar_event_group_id,
        :name                    => self.name,
        :description             => self.description,
        :location                => self.location,
        :begin_date              => d,
        :end_date                => d + (self.end_date - self.begin_date).seconds,
        :all_day                 => self.all_day,
        :repeats                 => self.repeats
      )
      return e
    end

  end
end

Version data entries

599 entries across 599 versions & 1 rubygems

Version Path
caboose-cms-0.9.44 app/models/caboose/calendar_event.rb
caboose-cms-0.9.43 app/models/caboose/calendar_event.rb
caboose-cms-0.9.40 app/models/caboose/calendar_event.rb
caboose-cms-0.9.38 app/models/caboose/calendar_event.rb
caboose-cms-0.9.37 app/models/caboose/calendar_event.rb
caboose-cms-0.9.35 app/models/caboose/calendar_event.rb
caboose-cms-0.9.34 app/models/caboose/calendar_event.rb
caboose-cms-0.9.33 app/models/caboose/calendar_event.rb
caboose-cms-0.9.32 app/models/caboose/calendar_event.rb
caboose-cms-0.9.31 app/models/caboose/calendar_event.rb
caboose-cms-0.9.30 app/models/caboose/calendar_event.rb
caboose-cms-0.9.29 app/models/caboose/calendar_event.rb
caboose-cms-0.9.28 app/models/caboose/calendar_event.rb
caboose-cms-0.9.27 app/models/caboose/calendar_event.rb
caboose-cms-0.9.26 app/models/caboose/calendar_event.rb
caboose-cms-0.9.25 app/models/caboose/calendar_event.rb
caboose-cms-0.9.24 app/models/caboose/calendar_event.rb
caboose-cms-0.9.23 app/models/caboose/calendar_event.rb
caboose-cms-0.9.22 app/models/caboose/calendar_event.rb
caboose-cms-0.9.21 app/models/caboose/calendar_event.rb