effective_orders 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72eca7d0655eb6a817f703d2787d7a211d5b9da7889aaf1920ec79edb49384b7
|
4
|
+
data.tar.gz: ff602f25ce5ab9294c292e98060d505da015b6fb38c57f11463705d404871183
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 251acbaf892b9f51e0fd6ebd739d1a64538b6a597f071afcd4d2c0fd3b4b839c9f4423594620ae31ed7ce4dc8c92a79bbe30e7d6f2d07a3ab29607eab04accbe
|
7
|
+
data.tar.gz: bd8a5fd153eba267e138a32f598e01888c427fde5171327cc6271b8a1d7dcea7931f2d4b3187981f7bcea1e3e397cef4aafedd00aa64504c66b221f0deadd04b
|
data/README.md
CHANGED
@@ -351,7 +351,10 @@ The permissions you actually want to define for a regular user are as follows (u
|
|
351
351
|
|
352
352
|
```ruby
|
353
353
|
can [:manage], Effective::Cart, user_id: user.id
|
354
|
+
|
354
355
|
can [:manage], Effective::Order, user_id: user.id # Orders cannot be deleted
|
356
|
+
cannot [:edit, :update], Effective::Order, state: 'purchased'
|
357
|
+
|
355
358
|
can [:manage], Effective::Subscription, user_id: user.id
|
356
359
|
```
|
357
360
|
|
@@ -68,13 +68,13 @@ module Effective
|
|
68
68
|
|
69
69
|
# Always step1
|
70
70
|
def edit
|
71
|
-
@order ||= Effective::Order.find(params[:id])
|
71
|
+
@order ||= Effective::Order.not_purchased.find(params[:id])
|
72
72
|
EffectiveResources.authorize!(self, :edit, @order)
|
73
73
|
end
|
74
74
|
|
75
75
|
# Confirms the order from existing order
|
76
76
|
def update
|
77
|
-
@order ||= Effective::Order.find(params[:id])
|
77
|
+
@order ||= Effective::Order.not_purchased.find(params[:id])
|
78
78
|
EffectiveResources.authorize!(self, :update, @order)
|
79
79
|
|
80
80
|
@order.assign_attributes(checkout_params)
|
@@ -110,7 +110,7 @@ module Effective
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def send_buyer_receipt
|
113
|
-
@order = Effective::Order.find(params[:id])
|
113
|
+
@order = Effective::Order.purchased.find(params[:id])
|
114
114
|
EffectiveResources.authorize!(self, :show, @order)
|
115
115
|
|
116
116
|
if @order.send_order_receipt_to_buyer!
|
@@ -78,6 +78,10 @@ module Effective
|
|
78
78
|
self.state = EffectiveOrders::CONFIRMED if pending?
|
79
79
|
end
|
80
80
|
|
81
|
+
before_save(if: -> { state_was == EffectiveOrders::PURCHASED }) do
|
82
|
+
raise EffectiveOrders::AlreadyPurchasedException.new('cannot unpurchase an order') unless purchased?
|
83
|
+
end
|
84
|
+
|
81
85
|
# Order validations
|
82
86
|
validates :user_id, presence: true
|
83
87
|
validates :email, presence: true, email: true # email and cc validators are from effective_resources
|
@@ -338,6 +342,8 @@ module Effective
|
|
338
342
|
# It skips any address or bad user validations
|
339
343
|
# It's basically the same as save! on a new order, except it might send the payment request to buyer
|
340
344
|
def pending!
|
345
|
+
return false if purchased?
|
346
|
+
|
341
347
|
self.state = EffectiveOrders::PENDING
|
342
348
|
self.addresses.clear if addresses.any? { |address| address.valid? == false }
|
343
349
|
save!
|
@@ -348,6 +354,7 @@ module Effective
|
|
348
354
|
|
349
355
|
# Used by admin checkout only
|
350
356
|
def confirm!
|
357
|
+
return false if purchased?
|
351
358
|
update!(state: EffectiveOrders::CONFIRMED)
|
352
359
|
end
|
353
360
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|