Sha256: 209ad569d385412b8682bfbc91b21d3abb1791c561c9e593f82b803fbe6ffe11

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 Bytes

Contents

module Spree
  module Api
    module V2
      module Platform
        class CmsSectionsController < ResourceController
          before_action -> { doorkeeper_authorize! :write, :admin }, only: WRITE_ACTIONS << :reposition

          def reposition
            spree_authorize! :update, @moved_section if spree_current_user.present?

            @moved_section = scope.find(params[:section_id])
            new_index = params[:new_position_idx].to_i + 1

            if @moved_section && new_index
              @moved_section.set_list_position(new_index)
            else
              head :bad_request
            end

            if @moved_section.save
              head :no_content
            end
          end

          private

          def model_class
            Spree::CmsSection
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spree_api-4.3.3 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.2 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.1 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.0 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.0.rc3 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.0.rc2 app/controllers/spree/api/v2/platform/cms_sections_controller.rb
spree_api-4.3.0.rc1 app/controllers/spree/api/v2/platform/cms_sections_controller.rb