Class: Storefront::Users::OrdersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/storefront/users/orders_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/workarea/storefront/users/orders_controller.rb', line 5

def index
  models = Order.recent(
    current_user.id,
    Workarea.config.storefront_user_order_display_count
  )
  statuses = Fulfillment.find_statuses(*models.map(&:id))

  @orders = models.map do |order|
    Storefront::OrderViewModel.new(
      order,
      fulfillment_status: statuses[order.id]
    )
  end
end

#showObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/workarea/storefront/users/orders_controller.rb', line 20

def show
  model = Order.find(params[:id])

  if model.user_id != current_user.id.to_s
    head :forbidden and return
  else
    @order = Storefront::OrderViewModel.new(model)
  end
end