Class: SectionsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/sections_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/sections_controller.rb', line 14

def create
  @section = Section.new
  params[:section][:price] = TicketType.price_to_cents(params[:section][:price])
  @section.update_attributes(params[:section])
  @section.chart_id = @chart.id
  if @section.save
    Ticket.create_many(@chart.show, @section, @section.capacity, true)
  else
    flash[:error] = "We couldn't save your ticket type because " + @section.errors.full_messages.to_sentence
  end
  redirect_to event_show_path(@chart.show.event, @chart.show)
end

#editObject



9
10
11
12
# File 'app/controllers/sections_controller.rb', line 9

def edit
  @section = Section.find(params[:id])
  render :layout => false
end

#newObject



4
5
6
7
# File 'app/controllers/sections_controller.rb', line 4

def new
  @section = @chart.sections.build()
  render :layout => false
end

#off_saleObject



41
42
43
44
45
46
47
# File 'app/controllers/sections_controller.rb', line 41

def off_sale
  @qty = params[:quantity].to_i
  @section = Section.find(params[:id])
  @section.take_off_sale @qty
  flash[:notice] = "Tickets are now off sale"
  redirect_to event_show_path(@section.chart.show.event, @section.chart.show)
end

#on_saleObject



33
34
35
36
37
38
39
# File 'app/controllers/sections_controller.rb', line 33

def on_sale
  @qty = params[:quantity].to_i
  @section = Section.find(params[:id])
  @section.put_on_sale @qty
  flash[:notice] = "Tickets are now on sale"
  redirect_to event_show_path(@section.chart.show.event, @section.chart.show)
end

#updateObject



27
28
29
30
31
# File 'app/controllers/sections_controller.rb', line 27

def update
  @section = Section.find(params[:id])
  @section.update_attributes(params[:section])
  redirect_to event_show_path(@chart.show.event, @chart.show)
end