Class: Section
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Section
show all
- Includes:
- Ticket::Foundry
- Defined in:
- app/models/section.rb
Constant Summary
collapse
- @@channels =
Each channel needs its own boolean column in the sections table. @@channels = { :storefront => “S”, :box_office => “B”, :members => “M”}
{ :storefront => "S", :box_office => "B"}
Instance Attribute Summary collapse
Instance Method Summary
collapse
#build_tickets, #create_tickets, #foundry_template
Instance Attribute Details
#skip_create_first_ticket_type ⇒ Object
Returns the value of attribute skip_create_first_ticket_type.
3
4
5
|
# File 'app/models/section.rb', line 3
def skip_create_first_ticket_type
@skip_create_first_ticket_type
end
|
Instance Method Details
#as_json(options = {}) ⇒ Object
99
100
101
102
|
# File 'app/models/section.rb', line 99
def as_json(options = {})
options ||= {}
super(:methods => [:summary, :ticket_types]).merge(options)
end
|
#available ⇒ Object
95
96
97
|
# File 'app/models/section.rb', line 95
def available
Ticket.on_sale.where(:section_id => self.id).where(:cart_id => nil).count
end
|
#channels ⇒ Object
34
35
36
|
# File 'app/models/section.rb', line 34
def channels
@@channels
end
|
#create_first_ticket_type ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'app/models/section.rb', line 47
def create_first_ticket_type
if self.ticket_types.empty?
self.ticket_types.build({ :name => "General Admission",
:price => 0,
:limit => nil},
:without_protection => true).save
end
end
|
#dup! ⇒ Object
74
75
76
77
78
79
|
# File 'app/models/section.rb', line 74
def dup!
attrs = self.attributes.reject { |key, value| key == 'id' }
self.class.new(attrs).tap do |copy|
copy.ticket_types = self.ticket_types.collect { |ticket_type| ticket_type.dup! }
end
end
|
#put_on_sale(qty = 0) ⇒ Object
81
82
83
84
85
86
|
# File 'app/models/section.rb', line 81
def put_on_sale(qty = 0)
tickets.off_sale.limit(qty).each do |t|
t.put_on_sale
end
show.refresh_stats
end
|
#summarize ⇒ Object
38
39
40
41
|
# File 'app/models/section.rb', line 38
def summarize
tickets = Ticket.where(:section_id => id)
@summary = SectionSummary.for_tickets(tickets)
end
|
#summary ⇒ Object
43
44
45
|
# File 'app/models/section.rb', line 43
def summary
@summary || summarize
end
|
#take_off_sale(qty = 0) ⇒ Object
88
89
90
91
92
93
|
# File 'app/models/section.rb', line 88
def take_off_sale(qty = 0)
tickets.on_sale.limit(qty).each do |t|
t.take_off_sale
end
show.refresh_stats
end
|
#ticket_types_for(member = nil) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/section.rb', line 56
def ticket_types_for(member = nil)
types = []
types << ticket_types.storefront
unless member.nil?
types << ticket_types.members.select{|ticket_type| !ticket_type.member_ticket?} unless member.nil?
membership_type_ids = member.nil? ? [] : member.current_membership_types.collect(&:id)
types << ticket_types.select{|ticket_type| ticket_type.members && membership_type_ids.include?(ticket_type.membership_type_id) }
end
types.flatten.uniq
end
|