solidus_promotions 4.8.0 → 4.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 811d1da52213897e7b0d15eb5edcebfff15c589a2cba817a78cd71102108bda8
4
- data.tar.gz: 97b589f9439bee201fee75b9a6b290c55e04f8f4f9980108052b8162308fd932
3
+ metadata.gz: 79beb1a8ee4edcac021b5cd4769756f28ea1305408124eb3e0ae313a753041b1
4
+ data.tar.gz: 7e866a5a779bb70d027464b0aec5bfccc17cf55f9cf2868fbb0f21c67e33b1be
5
5
  SHA512:
6
- metadata.gz: ba882e0b5172335780662f5d13acd8d12e569318d7998b0ba05d057353d8ada749b916d9520cc180e0978fd6bdf9a557c55d2cb39589ab01848dae40d3b88427
7
- data.tar.gz: e4277bbede3bcb99ea59d265a9e86f0bb75dce9f09cfb17079231144919a8b5d2e8435d372a5d4eaf9027785ec57c9e7638879f4dc3797498c2bb4b04651360a
6
+ metadata.gz: 19341dcf6493884c6a8424ca1f7a33adb51a7437295154f2d62b3cdf8872671d562d5cd9739356255cea21ac94d5529979b19616b0485eb8a4ed2fc3c73f1d7d
7
+ data.tar.gz: b8af4afc61a94cd2bff690f1f73197d9f7e39c7a792ce5e907f91ce0dcc58f189f8e29292eaa4c0ed48faff26caedd694c3cc12c83d7207cfe7d2b4135da3ed9
@@ -12,7 +12,7 @@ module SolidusPromotions
12
12
 
13
13
  def index
14
14
  promotions = apply_search_to(
15
- SolidusPromotions::Promotion.order(id: :desc),
15
+ accessible_promotions.order(id: :desc),
16
16
  param: :q
17
17
  )
18
18
 
@@ -25,6 +25,7 @@ module SolidusPromotions
25
25
 
26
26
  def destroy
27
27
  @promotions = SolidusPromotions::Promotion.where(id: params[:id])
28
+ @promotions.each { authorize! :destroy, _1 }
28
29
 
29
30
  SolidusPromotions::Promotion.transaction { @promotions.destroy_all }
30
31
 
@@ -34,6 +35,12 @@ module SolidusPromotions
34
35
 
35
36
  private
36
37
 
38
+ def accessible_promotions
39
+ return SolidusPromotions::Promotion.all if current_ability.has_block?(:index, SolidusPromotions::Promotion)
40
+
41
+ SolidusPromotions::Promotion.accessible_by(current_ability, :index)
42
+ end
43
+
37
44
  def load_promotion
38
45
  @promotion = SolidusPromotions::Promotion.find_by!(number: params[:id])
39
46
  authorize! action_name, @promotion
@@ -5,6 +5,10 @@ module SolidusPromotions
5
5
  class PromotionCategoriesController < BaseController
6
6
  private
7
7
 
8
+ def permitted_resource_params
9
+ params.require(:promotion_category).permit(:name, :code)
10
+ end
11
+
8
12
  def model_class
9
13
  SolidusPromotions::PromotionCategory
10
14
  end
@@ -22,6 +22,10 @@ module SolidusPromotions
22
22
 
23
23
  private
24
24
 
25
+ def permitted_resource_params
26
+ params.require(:promotion_code_batch).permit(:base_code, :number_of_codes, :join_characters, :email)
27
+ end
28
+
25
29
  def build_promotion_code_batch
26
30
  @promotion_code_batch.process
27
31
  end
@@ -29,6 +29,13 @@ module SolidusPromotions
29
29
 
30
30
  private
31
31
 
32
+ def permitted_resource_params
33
+ params.require(:promotion).permit(
34
+ :name, :customer_label, :description, :promotion_category_id, :usage_limit,
35
+ :per_code_usage_limit, :starts_at, :expires_at, :lane, :apply_automatically, :path
36
+ )
37
+ end
38
+
32
39
  def collection
33
40
  return @collection if @collection
34
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_promotions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff