Class: Dscf::Marketplace::DeliveryStopsController

Inherits:
ApplicationController show all
Includes:
Core::Common
Defined in:
app/controllers/dscf/marketplace/delivery_stops_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#bypass_permissions_for_demo?, #pundit_user

Instance Method Details

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/dscf/marketplace/delivery_stops_controller.rb', line 6

def index
  super do
    if params[:delivery_order_id]
      stops = DeliveryStop.where(delivery_order_id: params[:delivery_order_id])
      options = { include: [:dropoff_address, :delivery_order_items] }
      [stops, options]
    else
       # Fallback or standard index if needed, though mostly used nested
       [DeliveryStop.all, {}]
    end
  end
end

#verifyObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/dscf/marketplace/delivery_stops_controller.rb', line 19

def verify
  @delivery_stop = DeliveryStop.find(params[:id])
  authorize @delivery_stop, :verify?
  if @delivery_stop.verify!(verified_by: current_user.id)
    render_success(
      data: @delivery_stop, 
      serializer_options: { include: [:dropoff_address, :delivery_order_items] }
    )
  else
    render_error(
      errors: @delivery_stop.errors.full_messages,
      status: :unprocessable_entity
    )
  end
end