Class: ConsoleSalesController

Inherits:
ArtfullyOseController show all
Includes:
CartFinder
Defined in:
app/controllers/console_sales_controller.rb

Instance Method Summary collapse

Methods included from CartFinder

#cart_name, #create_new_cart, #current_box_office_cart, #current_cart, #current_cart=, #current_sales_console_cart, #session_cart, #session_key

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/console_sales_controller.rb', line 29

def create
  unless payment_method_is_vaild? &&
         membership_and_pass_requirements_met &&
         member_is_valid?
    
    redirect_to new_console_sale_path(:person_id => @person.try(:id)) and return
  end   

  @checkout = ConsoleSale::Checkout.new(current_sales_console_cart, payment, params[:order_notes])
  
  if @checkout.valid? && @checkout.finish
    @order = @checkout.order
    flash[:notice] = success_flash_message(@order, @checkout.person.email)
    redirect_to new_console_sale_path
  else      
    flash[:error] = @checkout.message
    redirect_to new_console_sale_path(:person_id => @person.try(:id))
  end 
rescue Exception => e
  checkout_error(e)   
end

#destroyObject



24
25
26
27
# File 'app/controllers/console_sales_controller.rb', line 24

def destroy
  current_sales_console_cart.clear!
  redirect_to new_console_sale_path(:person_id => @person.try(:id))
end

#eventsObject



51
52
53
54
55
# File 'app/controllers/console_sales_controller.rb', line 51

def events
  @event = current_organization.events.find(params[:event_id])
  @shows = @event.upcoming_shows(:all)
  render :json => @shows
end

#newObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/console_sales_controller.rb', line 7

def new  
  @events = Event.where(:id => current_organization.shows.unplayed.pluck(:event_id).uniq)
  @membership_types = current_organization.membership_types.sales_valid

  @membership_types_hash = {}
  @membership_types.each {|mt| @membership_types_hash[mt.id] = {:allow_multiple_memberships => mt.allow_multiple_memberships?,:formatted_ends_at => I18n.l(mt.ends_at, :format => :date_for_input)}}

  @pass_types = current_organization.pass_types.all
end

#showsObject



57
58
59
60
61
# File 'app/controllers/console_sales_controller.rb', line 57

def shows
  @show = current_organization.shows.find(params[:show_id])
  @ticket_types = @show.chart.sections.first.ticket_types_for(nil)
  render :partial => "shows"
end

#updateObject



17
18
19
20
21
22
# File 'app/controllers/console_sales_controller.rb', line 17

def update
  handler = OrderHandler.new(current_sales_console_cart, nil)
  handler.handle(params, current_organization)
  flash[:alert] = handler.error unless handler.error.blank?
  redirect_to new_console_sale_path(:person_id => @person.try(:id))
end