Class: FullcalendarEngine::Event

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/fullcalendar_engine/event.rb

Constant Summary collapse

REPEATS =
{
  :no_repeat => "Does not repeat",
  :days      => "Daily",
  :weeks     => "Weekly",
  :months    => "Monthly",
  :years     => "Yearly"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commit_buttonObject

Returns the value of attribute commit_button.



4
5
6
# File 'app/models/fullcalendar_engine/event.rb', line 4

def commit_button
  @commit_button
end

#frequencyObject

Returns the value of attribute frequency.



4
5
6
# File 'app/models/fullcalendar_engine/event.rb', line 4

def frequency
  @frequency
end

#periodObject

Returns the value of attribute period.



4
5
6
# File 'app/models/fullcalendar_engine/event.rb', line 4

def period
  @period
end

Instance Method Details

#update_events(events, event) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/models/fullcalendar_engine/event.rb', line 25

def update_events(events, event)
  events.each do |e|
    begin 
      old_start_time, old_end_time = e.starttime, e.endtime
      e.attributes = event
      if event_series.period.downcase == 'monthly' or event_series.period.downcase == 'yearly'
        new_start_time = make_date_time(e.starttime, old_start_time) 
        new_end_time   = make_date_time(e.starttime, old_end_time, e.endtime)
      else
        new_start_time = make_date_time(e.starttime, old_end_time)
        new_end_time   = make_date_time(e.endtime, old_end_time)
      end
    rescue
      new_start_time = new_end_time = nil
    end
    if new_start_time and new_end_time
      e.starttime, e.endtime = new_start_time, new_end_time
      e.save
    end
  end
  
  event_series.attributes = event
  event_series.save
end

#validate_timingsObject



19
20
21
22
23
# File 'app/models/fullcalendar_engine/event.rb', line 19

def validate_timings
  if (starttime >= endtime) and !all_day
    errors[:base] << "Start Time must be less than End Time"
  end
end