Sha256: 1c3a61bc6882d0008089b94267a57775d19b3952e52d66fbc84c3e720ff95785

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

module Spree
  module Admin
    class PromotionsController < ResourceController
      before_action :load_data

      helper 'spree/promotion_rules'

      protected
        def location_after_save
          spree.edit_admin_promotion_url(@promotion)
        end

        def load_data
          @calculators = Rails.application.config.spree.calculators.promotion_actions_create_adjustments
          @promotion_categories = Spree::PromotionCategory.order(:name)
        end

        def collection
          return @collection if defined?(@collection)
          params[:q] ||= HashWithIndifferentAccess.new
          params[:q][:s] ||= 'id desc'

          @collection = super
          @search = @collection.ransack(params[:q])
          @collection = @search.result(distinct: true).
            includes(promotion_includes).
            page(params[:page]).
            per(params[:per_page] || Spree::Config[:promotions_per_page])
        end

        def promotion_includes
          [:promotion_actions]
        end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
spree_backend-3.1.14 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.13 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.12 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.11 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.10 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.9 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.8 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.7 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.6 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.5 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.4 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.3 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.2 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.1 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.0 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.0.rc4 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.0.rc3 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.0.rc2 app/controllers/spree/admin/promotions_controller.rb
spree_backend-3.1.0.rc1 app/controllers/spree/admin/promotions_controller.rb