class SingleDayEvent

Event that takes place on one day only

Notifies parent event on save or destroy

Public Class Methods

find_all_by_conditions(conditions, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar) click to toggle source
# File app/models/single_day_event.rb, line 19
def SingleDayEvent.find_all_by_conditions(conditions, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar)
  conditions.first << " and practice in (?)"
  conditions << [RacingAssociation.current.show_practices_on_calendar?, false]

  if sanctioned_by
    conditions.first << " and sanctioned_by = ?"
    conditions << RacingAssociation.current.default_sanctioned_by
  end

  if discipline
    conditions.first << " and discipline = ?"
    conditions << discipline.name
  end

  SingleDayEvent.all :conditions => conditions
end
find_all_by_unix_dates(start_date, end_date, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar) click to toggle source
# File app/models/single_day_event.rb, line 14
def SingleDayEvent.find_all_by_unix_dates(start_date, end_date, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar)
  conditions = ["date between ? and ?", "#{Time.at(start_date.to_i).strftime('%Y-%m-%d')}", "#{Time.at(end_date.to_i).strftime('%Y-%m-%d')}"]
  SingleDayEvent.find_all_by_conditions(conditions, discipline, sanctioned_by)
end
find_all_by_year(year, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar) click to toggle source
# File app/models/single_day_event.rb, line 9
def SingleDayEvent.find_all_by_year(year, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar)
  conditions = ["date between ? and ?", "#{year}-01-01", "#{year}-12-31"]
  SingleDayEvent.find_all_by_conditions(conditions, discipline, sanctioned_by)
end

Public Instance Methods

friendly_class_name() click to toggle source
# File app/models/single_day_event.rb, line 57
def friendly_class_name
  'Single Day Event'
end
missing_parent() click to toggle source
# File app/models/single_day_event.rb, line 49
def missing_parent
  if parent_id.nil? 
    MultiDayEvent.same_name_and_year(self)
  else
    nil
  end
end
missing_parent?() click to toggle source
# File app/models/single_day_event.rb, line 45
def missing_parent?
  !missing_parent.nil?
end
parent_not_single_day_event() click to toggle source
# File app/models/single_day_event.rb, line 61
def parent_not_single_day_event
  errors.add(:parent, "SingleDayEvents cannot be children of other SingleDayEvents") if parent.is_a?(SingleDayEvent)
end
series_event?() click to toggle source
# File app/models/single_day_event.rb, line 36
def series_event?
  parent && parent.is_a?(WeeklySeries)
end
set_bar_points() click to toggle source
# File app/models/single_day_event.rb, line 40
def set_bar_points
  self.bar_points = 0 if series_event?
  true
end
to_s() click to toggle source
# File app/models/single_day_event.rb, line 65
def to_s
  "#<#{self.class} #{id} #{parent_id} #{discipline} #{name} #{date}>"
end