| Class | Event |
| In: |
app/models/event.rb
|
| Parent: | Article |
# File app/models/event.rb, line 31
31: def self.by_month(year = nil, month = nil)
32: self.find(:all, :conditions => { :start_date => date_range(year, month) })
33: end
# File app/models/event.rb, line 35
35: def self.date_range(year, month)
36: if year.nil? || month.nil?
37: today = Date.today
38: year = today.year
39: month = today.month
40: else
41: year = year.to_i
42: month = month.to_i
43: end
44:
45: first_day = Date.new(year, month, 1)
46: last_day = Date.new(year, month, 1) + 1.month - 1.day
47:
48: first_day..last_day
49: end
# File app/models/event.rb, line 51
51: def date_range
52: start_date..(end_date||start_date)
53: end
# File app/models/event.rb, line 95
95: def link=(value)
96: self.body[:link] = maybe_add_http(value)
97: end
# File app/models/event.rb, line 61
61: def to_html
62:
63: result = ''
64: html = Builder::XmlMarkup.new(:target => result)
65:
66: html.div(:class => 'event-info' ) {
67:
68: html.ul(:class => 'event-data' ) {
69: html.li(:class => 'event-dates' ) {
70: html.span _('When:')
71: html.text! show_period(start_date, end_date)
72: }
73: html.li {
74: html.span _('URL:')
75: html.a(self.link || "", 'href' => self.link || "")
76: }
77: html.li {
78: html.span _('Address:')
79: html.text! self.address || ""
80: }
81: }
82:
83: if self.description
84: html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description')
85: end
86: }
87:
88: if self.description
89: result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.description)
90: end
91:
92: result
93: end