Class: TicketsController
- Inherits:
-
ArtfullyOseController
- Object
- ActionController::Base
- ArtfullyOseController
- TicketsController
- Defined in:
- app/controllers/tickets_controller.rb
Instance Method Summary collapse
- #bulk_edit ⇒ Object
- #change_prices ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #new ⇒ Object
- #off_sale ⇒ Object
- #on_sale ⇒ Object
- #set_new_price ⇒ Object
- #when_section_selected ⇒ Object
Instance Method Details
#bulk_edit ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/controllers/tickets_controller.rb', line 85 def bulk_edit :bulk_edit, Ticket @show = Show.find(params[:show_id]) @selected_tickets = params[:selected_tickets] if @selected_tickets.nil? flash[:error] = "No tickets were selected" redirect_to event_show_url(@show.event, @show) and return elsif 'Update Price' == params[:commit] set_new_price else with_confirmation do bulk_edit_tickets(@show, @selected_tickets, params[:commit]) redirect_to event_show_url(@show.event, @show) and return end end end |
#change_prices ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'app/controllers/tickets_controller.rb', line 117 def change_prices @grouped_tickets = params[:grouped_tickets] with_confirmation_price_change do @selected_tickets = params[:selected_tickets] @price = params[:price] @show = Show.find(params[:show_id]) if @show.bulk_change_price(@selected_tickets, @price) flash[:notice] = "Updated the price of #{to_plural(@selected_tickets.size, 'ticket')}. " else flash[:error] = "Tickets that have been sold or comped can't be given a new price." end redirect_to event_show_url(@show.event, @show) and return end end |
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/tickets_controller.rb', line 25 def create @show = Show.find(params[:show_id]) @section = Section.find(params[:section_id]) @quantity = params[:quantity].to_i @on_sale = params[:on_sale] == "true" if @quantity > 1000 flash[:error] = "You cannot add more than 1000 tickets at a time." redirect_to event_show_path(@show.event, @show) elsif @quantity > 0 result = Ticket.create_many(@show, @section, @quantity, @on_sale) flash[:notice] = "Successfully added #{to_plural(@quantity, 'tickets')}." redirect_to event_show_path(@show.event, @show) else flash[:error] = "Enter a number greater than 0 to add tickets to the show." redirect_to event_show_path(@show.event, @show) end end |
#delete ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/tickets_controller.rb', line 72 def delete @show = Show.find(params[:show_id]) @selected_tickets = params[:selected_tickets] with_confirmation do if @show.bulk_delete(@selected_tickets) flash[:notice] = "Deleted #{to_plural(@selected_tickets.size, 'ticket')}. " else flash[:error] = "Tickets that have been sold or comped can't be put on or taken off sale. A ticket that is already on sale or off sale can't be put on or off sale again." end redirect_to event_show_url(@show.event, @show) end end |
#new ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/controllers/tickets_controller.rb', line 8 def new @show = Show.find(params[:show_id]) when_section_selected do @section = Section.find(params[:section_id]) @summary = @section.summarize end end |
#off_sale ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/tickets_controller.rb', line 58 def off_sale :bulk_edit, Ticket with_confirmation do @show = Show.find(params[:show_id]) @selected_tickets = params[:selected_tickets] if @show.bulk_off_sale(@selected_tickets) flash[:notice] = "Put #{to_plural(@selected_tickets.size, 'ticket')} off sale. " else flash[:error] = "Tickets that have been sold or comped can't be put on or taken off sale. A ticket that is already on sale or off sale can't be put on or off sale again." end redirect_to event_show_url(@show.event, @show) end end |
#on_sale ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/tickets_controller.rb', line 44 def on_sale :bulk_edit, Ticket with_confirmation do @show = Show.find(params[:show_id]) @selected_tickets = params[:selected_tickets] if @show.bulk_on_sale(@selected_tickets) flash[:notice] = "Put #{to_plural(@selected_tickets.size, 'ticket')} on sale. " else flash[:error] = "Tickets that have been sold or comped can't be put on or taken off sale. A ticket that is already on sale or off sale can't be put on or off sale again." end redirect_to event_show_url(@show.event, @show) end end |
#set_new_price ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/tickets_controller.rb', line 103 def set_new_price @show = Show.find(params[:show_id]) unless @show.event.is_free == "true" @selected_tickets = params[:selected_tickets] tix = @selected_tickets.collect{|id| Ticket.find( id )} sections = tix.group_by(&:section) @grouped_tickets = Hash[ sections.collect{ |name, tix| [name, tix.group_by(&:price)] } ] render 'tickets/set_new_price' and return else flash[:alert] = "You cannot change the ticket prices of a free event." redirect_to event_show_url(@show.event, @show) and return end end |
#when_section_selected ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/tickets_controller.rb', line 16 def when_section_selected if !params[:section_id].blank? yield elsif @show.chart.sections.length == 1 params[:section_id] = @show.chart.sections.first.id yield end end |