piggybak 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/app/controllers/piggybak/orders_controller.rb +4 -4
- data/app/models/piggybak/address.rb +1 -1
- data/app/models/piggybak/cart.rb +1 -1
- data/app/models/piggybak/line_item.rb +4 -4
- data/app/models/piggybak/order.rb +1 -1
- data/app/models/piggybak/order_note.rb +1 -1
- data/app/models/piggybak/payment_method.rb +1 -1
- data/app/models/piggybak/shipping_method.rb +2 -2
- data/app/models/piggybak/tax_calculator/percent.rb +1 -1
- data/lib/piggybak/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4470f4fbdba7afd56c0a7e3613540222c9e86c2a
|
4
|
+
data.tar.gz: da084dbabde7d4edaa8c435399961701ccf8a21e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b07bb758a5d9ecf2f8021ec00d26e747df8dead296a6b8a12506a9f275e1e19794f5f51765ae241f39109a1e152102f6e117b49e3c4f3be36fe9223b5b9d677
|
7
|
+
data.tar.gz: 16f9e4f36cd536d3a0847a1c6a9ce73c7ec892fb366828921e6e4b14e59d8d7de24682c1a5f051592b5ce2f250db0b638ebf84af262afea6717f7c3573b0db16
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Modular / mountable ecommerce gem. Features:
|
|
11
11
|
|
12
12
|
* Fully defined backend RailsAdmin interface for adding orders on the backend
|
13
13
|
|
14
|
-
* Piggybak 0.7.0 is compatible with Rails 4, and earlier
|
14
|
+
* Piggybak 0.7.1 is compatible with Rails 4.1, 0.7.0 is compatible with Rails 4, and earlier version compatible with Rails 3.
|
15
15
|
|
16
16
|
|
17
17
|
Announcements
|
@@ -74,7 +74,7 @@ module Piggybak
|
|
74
74
|
return
|
75
75
|
end
|
76
76
|
|
77
|
-
@order = Piggybak::Order.
|
77
|
+
@order = Piggybak::Order.where(id: session[:last_order]).first
|
78
78
|
end
|
79
79
|
|
80
80
|
def list
|
@@ -82,7 +82,7 @@ module Piggybak
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def download
|
85
|
-
@order = Piggybak::Order.
|
85
|
+
@order = Piggybak::Order.where(id: params[:id]).first
|
86
86
|
|
87
87
|
if can?(:download, @order)
|
88
88
|
render :layout => false
|
@@ -92,7 +92,7 @@ module Piggybak
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def email
|
95
|
-
order = Piggybak::Order.
|
95
|
+
order = Piggybak::Order.where(id: params[:id]).first
|
96
96
|
|
97
97
|
if can?(:email, order)
|
98
98
|
Piggybak::Notifier.order_notification(order).deliver
|
@@ -104,7 +104,7 @@ module Piggybak
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def cancel
|
107
|
-
order = Piggybak::Order.
|
107
|
+
order = Piggybak::Order.where(id: params[:id]).first
|
108
108
|
|
109
109
|
if can?(:cancel, order)
|
110
110
|
order.recorded_changer = current_user.id
|
data/app/models/piggybak/cart.rb
CHANGED
@@ -12,7 +12,7 @@ module Piggybak
|
|
12
12
|
self.errors = []
|
13
13
|
cookie ||= ''
|
14
14
|
cookie.split(';').each do |item|
|
15
|
-
item_sellable = Piggybak::Sellable.
|
15
|
+
item_sellable = Piggybak::Sellable.where(id: item.split(':')[0]).first
|
16
16
|
if item_sellable.present?
|
17
17
|
self.sellables << { :sellable => item_sellable, :quantity => (item.split(':')[1]).to_i }
|
18
18
|
end
|
@@ -9,7 +9,7 @@ module Piggybak
|
|
9
9
|
validates :quantity, presence: true
|
10
10
|
validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0
|
11
11
|
|
12
|
-
default_scope
|
12
|
+
default_scope { order('created_at ASC') }
|
13
13
|
|
14
14
|
after_create :decrease_inventory, :if => Proc.new { |line_item| line_item.line_item_type == 'sellable' && !line_item.sellable.unlimited_inventory }
|
15
15
|
after_destroy :increase_inventory, :if => Proc.new { |line_item| line_item.line_item_type == 'sellable' && !line_item.sellable.unlimited_inventory }
|
@@ -46,7 +46,7 @@ module Piggybak
|
|
46
46
|
return
|
47
47
|
end
|
48
48
|
|
49
|
-
sellable = Piggybak::Sellable.
|
49
|
+
sellable = Piggybak::Sellable.where(id: self.sellable_id).first
|
50
50
|
|
51
51
|
return if sellable.nil?
|
52
52
|
|
@@ -85,7 +85,7 @@ module Piggybak
|
|
85
85
|
def preprocess_payment
|
86
86
|
if self.new_record?
|
87
87
|
self.build_payment if self.payment.nil?
|
88
|
-
self.payment.payment_method_id ||= Piggybak::PaymentMethod.
|
88
|
+
self.payment.payment_method_id ||= Piggybak::PaymentMethod.where(active: true).first.id
|
89
89
|
self.description = "Payment"
|
90
90
|
self.price = 0
|
91
91
|
end
|
@@ -140,7 +140,7 @@ module Piggybak
|
|
140
140
|
|
141
141
|
def update_inventory
|
142
142
|
if self.sellable_id != self.sellable_id_was
|
143
|
-
old_sellable = Sellable.
|
143
|
+
old_sellable = Sellable.where(id: self.sellable_id_was).first
|
144
144
|
old_sellable.update_inventory(self.quantity_was)
|
145
145
|
self.sellable.update_inventory(-1*self.quantity)
|
146
146
|
else
|
@@ -30,7 +30,7 @@ module Piggybak
|
|
30
30
|
after_save :record_order_note
|
31
31
|
after_save :deliver_order_confirmation, :if => Proc.new { |order| !order.confirmation_sent }
|
32
32
|
|
33
|
-
default_scope
|
33
|
+
default_scope { order('created_at ASC') }
|
34
34
|
|
35
35
|
def deliver_order_confirmation
|
36
36
|
Piggybak::Notifier.order_notification(self).deliver
|
@@ -26,7 +26,7 @@ module Piggybak
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
validates_each :active do |record, attr, value|
|
29
|
-
if value && PaymentMethod.
|
29
|
+
if value && PaymentMethod.where(active: true).select { |p| p != record }.size > 0
|
30
30
|
record.errors.add attr, "You may only have one active payment method."
|
31
31
|
end
|
32
32
|
end
|
@@ -27,13 +27,13 @@ module Piggybak
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.available_methods(cart)
|
30
|
-
active_methods = ShippingMethod.
|
30
|
+
active_methods = ShippingMethod.where(active: true)
|
31
31
|
|
32
32
|
active_methods.select { |method| method.klass.constantize.available?(method, cart) }
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.lookup_methods(cart)
|
36
|
-
active_methods = ShippingMethod.
|
36
|
+
active_methods = ShippingMethod.where(active: true)
|
37
37
|
|
38
38
|
methods = active_methods.inject([]) do |arr, method|
|
39
39
|
klass = method.klass.constantize
|
@@ -6,7 +6,7 @@ module Piggybak
|
|
6
6
|
id = method.metadata.detect { |t| t.key == "state_id" }.value
|
7
7
|
|
8
8
|
if object.is_a?(Cart) && object.extra_data.has_key?(:state_id) && object.extra_data[:state_id] != ''
|
9
|
-
state = State.
|
9
|
+
state = State.where(id: object.extra_data[:state_id]).first
|
10
10
|
return state.id == id.to_i if state
|
11
11
|
elsif object.is_a?(Order) && object.billing_address && object.billing_address.state
|
12
12
|
return object.billing_address.state.id == id.to_i
|
data/lib/piggybak/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steph Skardal
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: countries
|