Sha256: 13ee605f9fccca8c9116420d7cc781a5e01022522c570f831985cd02be2a81c0

Contents?: true

Size: 1.18 KB

Versions: 50

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Spree
  module Api
    class StockMovementsController < Spree::Api::BaseController
      before_action :stock_location, except: [:update, :destroy]

      def index
        authorize! :read, StockMovement
        @stock_movements = paginate(scope.ransack(params[:q]).result)
        respond_with(@stock_movements)
      end

      def show
        @stock_movement = scope.find(params[:id])
        respond_with(@stock_movement)
      end

      def create
        authorize! :create, StockMovement
        @stock_movement = scope.new(stock_movement_params)
        if @stock_movement.save
          respond_with(@stock_movement, status: 201, default_template: :show)
        else
          invalid_resource!(@stock_movement)
        end
      end

      private

      def stock_location
        @stock_location ||= Spree::StockLocation.accessible_by(current_ability, :read).find(params[:stock_location_id])
      end

      def scope
        @stock_location.stock_movements.accessible_by(current_ability, :read)
      end

      def stock_movement_params
        params.require(:stock_movement).permit(permitted_stock_movement_attributes)
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
solidus_api-2.10.5 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.10.3 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.10.2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.6 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.8.6 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.10.1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.5 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.10.0 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.4 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.6.6 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.7.4 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.8.5 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.3 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.10.0.beta1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.7.3 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.6.5 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.0 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.9.0.rc.1 app/controllers/spree/api/stock_movements_controller.rb