Sha256: 20067c961d10e544ab323036d1e3eb7879f64a3b81ad6ba9aa01cb8fee6334c6

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

class SectionsController < ArtfullyOseController
  before_filter :find_chart, :except => [:on_sale, :off_sale, :edit]

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

  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

  def update
    @section = Section.find(params[:id])
    @section.update_attributes(params[:section])
    redirect_to event_show_path(@chart.show.event, @chart.show)
  end
  
  def on_sale
    @qty = params[:quantity].to_i
    @section = Section.find(params[:id])
    @section.put_on_sale @qty
    flash[:notice] = "Tickets in section #{@section.name} are now on sale"
    redirect_to event_show_path(@section.chart.show.event, @section.chart.show)
  end
  
  def off_sale
    @qty = params[:quantity].to_i
    @section = Section.find(params[:id])
    @section.take_off_sale @qty
    flash[:notice] = "Tickets in section #{@section.name} are now off sale"
    redirect_to event_show_path(@section.chart.show.event, @section.chart.show)
  end

  private

    def find_chart
      @chart = Chart.find(params[:chart_id] || params[:section][:chart_id])
    end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.19 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.15 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.12 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.11 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.10 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.9 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.8 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.7 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.6 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.5 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.4 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.3 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.2 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre.1 app/controllers/sections_controller.rb
artfully_ose-1.2.0.pre app/controllers/sections_controller.rb