Sha256: 409da6b2aa6bb63726103503f3bc01986b578c915d9d7a4e80119ca7389cf9fa

Contents?: true

Size: 1.17 KB

Versions: 45

Compression:

Stored size: 1.17 KB

Contents

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

      def index
        authorize! :read, StockMovement
        @stock_movements = scope.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
        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 ||= 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

45 entries across 45 versions & 1 rubygems

Version Path
solidus_api-2.0.3 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.4.2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.2.3 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.1.4 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.0.7 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.0.2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.4.1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.0.1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.0.0 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.4.0 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.0.0.rc1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.4.0.rc1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-2.0.0.beta1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.4.0.beta1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.0 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.0.rc2 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.0.rc1 app/controllers/spree/api/stock_movements_controller.rb
solidus_api-1.3.0.beta1 app/controllers/spree/api/stock_movements_controller.rb