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.64 app/models/caboose/calendar_event.rb
caboose-cms-0.9.63 app/models/caboose/calendar_event.rb
caboose-cms-0.9.62 app/models/caboose/calendar_event.rb
caboose-cms-0.9.61 app/models/caboose/calendar_event.rb
caboose-cms-0.9.60 app/models/caboose/calendar_event.rb
caboose-cms-0.9.59 app/models/caboose/calendar_event.rb
caboose-cms-0.9.58 app/models/caboose/calendar_event.rb
caboose-cms-0.9.57 app/models/caboose/calendar_event.rb
caboose-cms-0.9.56 app/models/caboose/calendar_event.rb
caboose-cms-0.9.55 app/models/caboose/calendar_event.rb
caboose-cms-0.9.54 app/models/caboose/calendar_event.rb
caboose-cms-0.9.53 app/models/caboose/calendar_event.rb
caboose-cms-0.9.52 app/models/caboose/calendar_event.rb
caboose-cms-0.9.51 app/models/caboose/calendar_event.rb
caboose-cms-0.9.50 app/models/caboose/calendar_event.rb
caboose-cms-0.9.49 app/models/caboose/calendar_event.rb
caboose-cms-0.9.48 app/models/caboose/calendar_event.rb
caboose-cms-0.9.47 app/models/caboose/calendar_event.rb
caboose-cms-0.9.46 app/models/caboose/calendar_event.rb
caboose-cms-0.9.45 app/models/caboose/calendar_event.rb