| Class | SingleDayEvent |
| In: |
app/models/single_day_event.rb
|
| Parent: | Event |
Event that takes place on one day only
Notifies parent event on save or destroy
# File app/models/single_day_event.rb, line 19
19: def SingleDayEvent.find_all_by_conditions(conditions, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar)
20: conditions.first << " and practice in (?)"
21: conditions << [RacingAssociation.current.show_practices_on_calendar?, false]
22:
23: if sanctioned_by
24: conditions.first << " and sanctioned_by = ?"
25: conditions << RacingAssociation.current.default_sanctioned_by
26: end
27:
28: if discipline
29: conditions.first << " and discipline = ?"
30: conditions << discipline.name
31: end
32:
33: SingleDayEvent.find(:all, :conditions => conditions)
34: end
# File app/models/single_day_event.rb, line 14
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)
15: conditions = ["date between ? and ?", "#{Time.at(start_date.to_i).strftime('%Y-%m-%d')}", "#{Time.at(end_date.to_i).strftime('%Y-%m-%d')}"]
16: SingleDayEvent.find_all_by_conditions(conditions, discipline, sanctioned_by)
17: end
# File app/models/single_day_event.rb, line 9
9: def SingleDayEvent.find_all_by_year(year, discipline = nil, sanctioned_by = RacingAssociation.current.show_only_association_sanctioned_races_on_calendar)
10: conditions = ["date between ? and ?", "#{year}-01-01", "#{year}-12-31"]
11: SingleDayEvent.find_all_by_conditions(conditions, discipline, sanctioned_by)
12: end
# File app/models/single_day_event.rb, line 57
57: def friendly_class_name
58: 'Single Day Event'
59: end
# File app/models/single_day_event.rb, line 49
49: def missing_parent
50: if parent_id.nil?
51: MultiDayEvent.same_name_and_year(self)
52: else
53: nil
54: end
55: end
# File app/models/single_day_event.rb, line 45
45: def missing_parent?
46: !missing_parent.nil?
47: end
# File app/models/single_day_event.rb, line 61
61: def parent_not_single_day_event
62: errors.add(:parent, "SingleDayEvents cannot be children of other SingleDayEvents") if parent.is_a?(SingleDayEvent)
63: end
# File app/models/single_day_event.rb, line 36
36: def series_event?
37: parent && parent.is_a?(WeeklySeries)
38: end