Sha256: a06ed9c89871e8c03a4a5a27fbdd36cd2cb7dc2c65c3072476b911ca9e18e3bb

Contents?: true

Size: 655 Bytes

Versions: 54

Compression:

Stored size: 655 Bytes

Contents

module Spree
  module Api
    class PromotionsController < Spree::Api::BaseController
      before_filter :requires_admin
      before_filter :load_promotion

      def show
        if @promotion
          respond_with(@promotion, default_template: :show)
        else
          raise ActiveRecord::RecordNotFound
        end
      end

      private 
        def requires_admin
          return if @current_user_roles.include?("admin")
          unauthorized and return
        end

        def load_promotion
          @promotion = Spree::Promotion.find_by_id(params[:id]) || Spree::Promotion.with_coupon_code(params[:id])
        end
    end
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
solidus_api-1.1.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.1.0.pre2 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.1.0.pre1 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.1.0.beta1 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.2 app/controllers/spree/api/promotions_controller.rb
spree_api-3.0.4 app/controllers/spree/api/promotions_controller.rb
spree_api-2.4.10 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.1 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0.rc2 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0.rc1 app/controllers/spree/api/promotions_controller.rb
spree_api-3.0.3 app/controllers/spree/api/promotions_controller.rb
spree_api-2.4.9 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0.pre3 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0.pre2 app/controllers/spree/api/promotions_controller.rb
spree_api-3.0.2 app/controllers/spree/api/promotions_controller.rb
spree_api-2.4.8 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.0.0.pre app/controllers/spree/api/promotions_controller.rb
spree_api-3.0.1 app/controllers/spree/api/promotions_controller.rb
spree_api-2.4.7 app/controllers/spree/api/promotions_controller.rb