Class: Event
Constant Summary
collapse
- CATEGORIES =
["Dance", "Film & Electronic Media", "Literary Arts", "Music", "Theater", "Visual Arts", "Other"]
Constants included
from Ext::Uuid
Ext::Uuid::PREFIX
Instance Method Summary
collapse
included
#glance
Methods included from Ext::Uuid
included, #set_uuid, uuid
#shows_with_sales
Instance Method Details
#<=>(obj) ⇒ Object
157
158
159
160
161
|
# File 'app/models/event.rb', line 157
def <=>(obj)
return -1 unless obj.kind_of? Event
self.name.downcase <=> obj.name.downcase
end
|
#artfully_ticketed ⇒ Object
57
58
59
|
# File 'app/models/event.rb', line 57
def artfully_ticketed
true
end
|
#as_full_calendar_json ⇒ Object
128
129
130
131
132
133
134
135
136
137
|
# File 'app/models/event.rb', line 128
def as_full_calendar_json
shows.collect do |p|
{ :title => '',
:start => p.datetime_local_to_event,
:allDay => false,
:color => '#077083',
:id => p.id
}
end
end
|
#as_json(options = {}) ⇒ Object
139
140
141
|
# File 'app/models/event.rb', line 139
def as_json(options = {})
super(options)
end
|
124
125
126
|
# File 'app/models/event.rb', line 124
def as_widget_json(options = {})
as_json(options.merge(:methods => ['shows', 'charts', 'venue', 'uuid'])).merge('performances' => upcoming_public_shows.as_json)
end
|
#assign_chart(chart) ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'app/models/event.rb', line 143
def assign_chart(chart)
if already_has_chart(chart)
self.errors[:base] << "Chart \"#{chart.name}\" has already been added to this event"
return self
end
if is_free? && chart.has_paid_sections?
self.errors[:base] << "Cannot add chart with paid sections to a free event"
return self
end
chart.assign_to(self)
self
end
|
#create_default_chart ⇒ Object
86
87
88
89
90
91
|
# File 'app/models/event.rb', line 86
def create_default_chart
chart = self.charts.build({ :name => self.name,
:is_template => false })
chart.organization = self.organization
chart.save
end
|
#default_chart ⇒ Object
93
94
95
|
# File 'app/models/event.rb', line 93
def default_chart
charts.first
end
|
#destroy ⇒ Object
62
63
64
|
# File 'app/models/event.rb', line 62
def destroy
update_attribute(:deleted_at, Time.now)
end
|
#destroy! ⇒ Object
61
|
# File 'app/models/event.rb', line 61
alias :destroy! :destroy
|
#destroyable? ⇒ Boolean
66
67
68
|
# File 'app/models/event.rb', line 66
def destroyable?
items.blank?
end
|
#filter_charts(charts) ⇒ Object
78
79
80
|
# File 'app/models/event.rb', line 78
def filter_charts(charts)
charts.reject { |chart| already_has_chart(chart) }
end
|
#free? ⇒ Boolean
53
54
55
|
# File 'app/models/event.rb', line 53
def free?
is_free?
end
|
#imported? ⇒ Boolean
70
71
72
|
# File 'app/models/event.rb', line 70
def imported?
!self.import_id.nil?
end
|
#items ⇒ Object
74
75
76
|
# File 'app/models/event.rb', line 74
def items
Item.where(:show_id => self.shows)
end
|
#next_public_show ⇒ Object
109
110
111
|
# File 'app/models/event.rb', line 109
def next_public_show
upcoming_public_shows.empty? ? nil : upcoming_public_shows.first
end
|
#next_show ⇒ Object
117
118
119
120
121
122
|
# File 'app/models/event.rb', line 117
def next_show
shows.build(:datetime => Show.next_datetime(shows.last))
show = shows.pop
show.chart = default_chart.dup!
show
end
|
#played_shows(limit = 5) ⇒ Object
103
104
105
106
107
|
# File 'app/models/event.rb', line 103
def played_shows(limit = 5)
played = shows.select { |show| show.datetime_local_to_event < (DateTime.now - 1.hours) }
return played if limit == :all
played.take(limit)
end
|
#set_primary_category ⇒ Object
82
83
84
|
# File 'app/models/event.rb', line 82
def set_primary_category
self.primary_category ||= "Other"
end
|
#upcoming_public_shows ⇒ Object
113
114
115
|
# File 'app/models/event.rb', line 113
def upcoming_public_shows
upcoming_shows(:all).select(&:published?)
end
|
#upcoming_shows(limit = 5) ⇒ Object
97
98
99
100
101
|
# File 'app/models/event.rb', line 97
def upcoming_shows(limit = 5)
upcoming = shows.includes(:event => :venue).select { |show| show.datetime_local_to_event > (DateTime.now - 1.hours) }
return upcoming if limit == :all
upcoming.take(limit)
end
|