Class: Mobile::OrdersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/mobile/orders_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



30
31
32
33
34
35
36
# File 'app/controllers/mobile/orders_controller.rb', line 30

def index
  organization = current_user.organizations.find(params[:organization_id])
  show = organization.shows.find(params[:show_id])
  door_list = DoorList.new(show)
  orders = Order.find(door_list.items.collect(&:order_id).uniq)
  render :json => orders, :each_serializer => OrderSerializer
end

#showObject



38
39
40
41
42
# File 'app/controllers/mobile/orders_controller.rb', line 38

def show
  organization = current_user.organizations.find(params[:organization_id])
  order = organization.orders.find(params[:id])
  render :json => order, :serializer => OrderSerializer
end

#validateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/mobile/orders_controller.rb', line 44

def validate
  organization = current_user.organizations.find(params[:organization_id])
  order = organization.orders.find(params[:id])

  Order.transaction do
    order.tickets.each do |item|
      ticket = item.product
      begin
        ticket.validate_ticket!(current_user)
      rescue Transitions::InvalidTransition
        # ignore
      end
    end
  end

  render :json => order, :serializer => OrderValidationSerializer
end