shoppe 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/app/models/shoppe/order.rb +18 -18
- data/app/models/shoppe/order/actions.rb +17 -21
- data/app/models/shoppe/order/delivery.rb +1 -1
- data/app/models/shoppe/order_item.rb +2 -2
- data/app/models/shoppe/payment.rb +1 -1
- data/app/models/shoppe/user.rb +1 -1
- data/app/validators/permalink_validator.rb +1 -1
- data/lib/shoppe/version.rb +2 -2
- metadata +71 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b79095cb897e80d6693d4cb9f1458f1581d17c2
|
4
|
+
data.tar.gz: c44a89fb521ab3051320be885c2255e954265b27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fcb2055f19c5bdbb15b97a924f6fe6d312da850aa8ebbe3ddc94ef43e9c71f81be613e9f6c4ddff1322f224e5ac1325aec4d73e3db1a0b3d3a2e890b70c2ed1
|
7
|
+
data.tar.gz: f3ee60d2f4eb75d0ecc05786cc35772400c1a8783ff37e824d50a6066b41af889884aa466e69d4088e6dc7baa34029fdf5527c352b89b7657209e013c96f7bc7
|
data/Rakefile
CHANGED
@@ -22,13 +22,13 @@ namespace :shoppe do
|
|
22
22
|
task :changelog do
|
23
23
|
system "scp -P 32032 CHANGELOG.md vdt@185.44.252.32:/app/docs/CHANGELOG.md"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
desc "Publish RDoc documentation from doc to api.tryshoppe.com"
|
27
27
|
task :docs do
|
28
28
|
if File.exist?('Rakefile')
|
29
29
|
system "yard"
|
30
|
-
system "ssh root@
|
31
|
-
system "scp -r doc root@
|
30
|
+
system "ssh root@vm.adamcooke.io rm -Rf /var/www/shoppe-api"
|
31
|
+
system "scp -r doc root@vm.adamcooke.io:/var/www/shoppe-api"
|
32
32
|
system "rm -Rf doc"
|
33
33
|
end
|
34
34
|
end
|
data/app/models/shoppe/order.rb
CHANGED
@@ -2,40 +2,40 @@ module Shoppe
|
|
2
2
|
class Order < ActiveRecord::Base
|
3
3
|
|
4
4
|
self.table_name = 'shoppe_orders'
|
5
|
-
|
5
|
+
|
6
6
|
# Orders can have properties
|
7
|
-
key_value_store :properties
|
8
|
-
|
7
|
+
key_value_store :properties
|
8
|
+
|
9
9
|
# Require dependencies
|
10
10
|
require_dependency 'shoppe/order/states'
|
11
11
|
require_dependency 'shoppe/order/actions'
|
12
12
|
require_dependency 'shoppe/order/billing'
|
13
13
|
require_dependency 'shoppe/order/delivery'
|
14
|
-
|
14
|
+
|
15
15
|
# All items which make up this order
|
16
|
-
has_many :order_items, :dependent => :destroy, :class_name => 'Shoppe::OrderItem'
|
16
|
+
has_many :order_items, :dependent => :destroy, :class_name => 'Shoppe::OrderItem', :inverse_of => :order
|
17
17
|
accepts_nested_attributes_for :order_items, :allow_destroy => true, :reject_if => Proc.new { |a| a['ordered_item_id'].blank? }
|
18
18
|
|
19
19
|
# All products which are part of this order (accessed through the items)
|
20
20
|
has_many :products, :through => :order_items, :class_name => 'Shoppe::Product', :source => :ordered_item, :source_type => 'Shoppe::Product'
|
21
|
-
|
21
|
+
|
22
22
|
# Validations
|
23
23
|
validates :token, :presence => true
|
24
24
|
with_options :if => Proc.new { |o| !o.building? } do |order|
|
25
25
|
order.validates :email_address, :format => {:with => /\A\b[A-Z0-9\.\_\%\-\+]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,6}\b\z/i}
|
26
26
|
order.validates :phone_number, :format => {:with => /\A[\d\ \-x\(\)]{7,}\z/}
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
# Set some defaults
|
30
30
|
before_validation { self.token = SecureRandom.uuid if self.token.blank? }
|
31
|
-
|
31
|
+
|
32
32
|
# The order number
|
33
33
|
#
|
34
34
|
# @return [String] - the order number padded with at least 5 zeros
|
35
35
|
def number
|
36
36
|
id ? id.to_s.rjust(6, '0') : nil
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
# The length of time the customer spent building the order before submitting it to us.
|
40
40
|
# The time from first item in basket to received.
|
41
41
|
#
|
@@ -44,7 +44,7 @@ module Shoppe
|
|
44
44
|
return nil if self.received_at.blank?
|
45
45
|
self.created_at - self.received_at
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
# The name of the customer in the format of "Company (First Last)" or if they don't have
|
49
49
|
# company specified, just "First Last".
|
50
50
|
#
|
@@ -52,42 +52,42 @@ module Shoppe
|
|
52
52
|
def customer_name
|
53
53
|
company.blank? ? full_name : "#{company} (#{full_name})"
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
# The full name of the customer created by concatinting the first & last name
|
57
57
|
#
|
58
58
|
# @return [String]
|
59
59
|
def full_name
|
60
60
|
"#{first_name} #{last_name}"
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
# Is this order empty? (i.e. doesn't have any items associated with it)
|
64
64
|
#
|
65
65
|
# @return [Boolean]
|
66
66
|
def empty?
|
67
67
|
order_items.empty?
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
# Does this order have items?
|
71
71
|
#
|
72
72
|
# @return [Boolean]
|
73
73
|
def has_items?
|
74
74
|
total_items > 0
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Return the number of items in the order?
|
78
78
|
#
|
79
79
|
# @return [Integer]
|
80
80
|
def total_items
|
81
81
|
order_items.inject(0) { |t,i| t + i.quantity }
|
82
82
|
end
|
83
|
-
|
84
|
-
def self.ransackable_attributes(auth_object = nil)
|
83
|
+
|
84
|
+
def self.ransackable_attributes(auth_object = nil)
|
85
85
|
["id", "billing_postcode", "billing_address1", "billing_address2", "billing_address3", "billing_address4", "first_name", "last_name", "company", "email_address", "phone_number", "consignment_number", "status", "received_at"] + _ransackers.keys
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def self.ransackable_associations(auth_object = nil)
|
89
89
|
[]
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
end
|
93
93
|
end
|
@@ -54,15 +54,13 @@ module Shoppe
|
|
54
54
|
#
|
55
55
|
# @param user [Shoppe::User] the user who carried out this action
|
56
56
|
def accept!(user = nil)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
deliver_accepted_order_email
|
65
|
-
end
|
57
|
+
run_callbacks :acceptance do
|
58
|
+
self.accepted_at = Time.now
|
59
|
+
self.accepter = user if user
|
60
|
+
self.status = 'accepted'
|
61
|
+
self.save!
|
62
|
+
self.order_items.each(&:accept!)
|
63
|
+
deliver_accepted_order_email
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
@@ -70,28 +68,26 @@ module Shoppe
|
|
70
68
|
#
|
71
69
|
# @param user [Shoppe::User] the user who carried out the action
|
72
70
|
def reject!(user = nil)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
deliver_rejected_order_email
|
81
|
-
end
|
71
|
+
run_callbacks :rejection do
|
72
|
+
self.rejected_at = Time.now
|
73
|
+
self.rejecter = user if user
|
74
|
+
self.status = 'rejected'
|
75
|
+
self.save!
|
76
|
+
self.order_items.each(&:reject!)
|
77
|
+
deliver_rejected_order_email
|
82
78
|
end
|
83
79
|
end
|
84
80
|
|
85
81
|
def deliver_accepted_order_email
|
86
|
-
Shoppe::OrderMailer.accepted(self).
|
82
|
+
Shoppe::OrderMailer.accepted(self).deliver_now
|
87
83
|
end
|
88
84
|
|
89
85
|
def deliver_rejected_order_email
|
90
|
-
Shoppe::OrderMailer.rejected(self).
|
86
|
+
Shoppe::OrderMailer.rejected(self).deliver_now
|
91
87
|
end
|
92
88
|
|
93
89
|
def deliver_received_order_email
|
94
|
-
Shoppe::OrderMailer.received(self).
|
90
|
+
Shoppe::OrderMailer.received(self).deliver_now
|
95
91
|
end
|
96
92
|
|
97
93
|
end
|
@@ -6,7 +6,7 @@ module Shoppe
|
|
6
6
|
# The associated order
|
7
7
|
#
|
8
8
|
# @return [Shoppe::Order]
|
9
|
-
belongs_to :order, :class_name => 'Shoppe::Order', :touch => true
|
9
|
+
belongs_to :order, :class_name => 'Shoppe::Order', :touch => true, :inverse_of => :order_items
|
10
10
|
|
11
11
|
# The item which has been ordered
|
12
12
|
belongs_to :ordered_item, :polymorphic => true
|
@@ -20,7 +20,7 @@ module Shoppe
|
|
20
20
|
|
21
21
|
validate do
|
22
22
|
unless in_stock?
|
23
|
-
errors.add :quantity, :
|
23
|
+
errors.add :quantity, :too_high_quantity
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -11,7 +11,7 @@ module Shoppe
|
|
11
11
|
# @return [Shoppe::Payment]
|
12
12
|
belongs_to :parent, :class_name => "Shoppe::Payment", :foreign_key => "parent_payment_id"
|
13
13
|
|
14
|
-
#
|
14
|
+
# Validations
|
15
15
|
validates :amount, :numericality => true
|
16
16
|
validates :reference, :presence => true
|
17
17
|
validates :method, :presence => true
|
data/app/models/shoppe/user.rb
CHANGED
@@ -29,7 +29,7 @@ module Shoppe
|
|
29
29
|
self.password = SecureRandom.hex(8)
|
30
30
|
self.password_confirmation = self.password
|
31
31
|
self.save!
|
32
|
-
Shoppe::UserMailer.new_password(self).
|
32
|
+
Shoppe::UserMailer.new_password(self).deliver_now
|
33
33
|
end
|
34
34
|
|
35
35
|
# Attempt to authenticate a user based on email & password. Returns the
|
data/lib/shoppe/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Shoppe
|
2
|
-
VERSION = "1.0.
|
3
|
-
end
|
2
|
+
VERSION = "1.0.5"
|
3
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoppe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -34,56 +34,42 @@ dependencies:
|
|
34
34
|
name: bcrypt
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.1'
|
40
37
|
- - ">="
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: 3.1.2
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.2'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '3.1'
|
50
47
|
- - ">="
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: 3.1.2
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: ransack
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: 4.0.0
|
60
57
|
- - ">="
|
61
58
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
59
|
+
version: 1.2.0
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.6.3
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 4.0.0
|
70
67
|
- - ">="
|
71
68
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
73
|
-
-
|
74
|
-
name: ransack
|
75
|
-
requirement: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
- - "~>"
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version: '1.2'
|
80
|
-
type: :runtime
|
81
|
-
prerelease: false
|
82
|
-
version_requirements: !ruby/object:Gem::Requirement
|
83
|
-
requirements:
|
84
|
-
- - "~>"
|
69
|
+
version: 1.2.0
|
70
|
+
- - "<"
|
85
71
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
72
|
+
version: 1.6.3
|
87
73
|
- !ruby/object:Gem::Dependency
|
88
74
|
name: kaminari
|
89
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +79,7 @@ dependencies:
|
|
93
79
|
version: 0.14.1
|
94
80
|
- - "<"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
82
|
+
version: '0.17'
|
97
83
|
type: :runtime
|
98
84
|
prerelease: false
|
99
85
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -103,21 +89,27 @@ dependencies:
|
|
103
89
|
version: 0.14.1
|
104
90
|
- - "<"
|
105
91
|
- !ruby/object:Gem::Version
|
106
|
-
version: '0.
|
92
|
+
version: '0.17'
|
107
93
|
- !ruby/object:Gem::Dependency
|
108
94
|
name: haml
|
109
95
|
requirement: !ruby/object:Gem::Requirement
|
110
96
|
requirements:
|
111
|
-
- - "
|
97
|
+
- - ">="
|
112
98
|
- !ruby/object:Gem::Version
|
113
99
|
version: '4.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '5.0'
|
114
103
|
type: :runtime
|
115
104
|
prerelease: false
|
116
105
|
version_requirements: !ruby/object:Gem::Requirement
|
117
106
|
requirements:
|
118
|
-
- - "
|
107
|
+
- - ">="
|
119
108
|
- !ruby/object:Gem::Version
|
120
109
|
version: '4.0'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '5.0'
|
121
113
|
- !ruby/object:Gem::Dependency
|
122
114
|
name: dynamic_form
|
123
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,66 +132,24 @@ dependencies:
|
|
140
132
|
version: 1.1.4
|
141
133
|
- !ruby/object:Gem::Dependency
|
142
134
|
name: jquery-rails
|
143
|
-
requirement: !ruby/object:Gem::Requirement
|
144
|
-
requirements:
|
145
|
-
- - "~>"
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: '3'
|
148
|
-
type: :runtime
|
149
|
-
prerelease: false
|
150
|
-
version_requirements: !ruby/object:Gem::Requirement
|
151
|
-
requirements:
|
152
|
-
- - "~>"
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
version: '3'
|
155
|
-
- !ruby/object:Gem::Dependency
|
156
|
-
name: coffee-rails
|
157
|
-
requirement: !ruby/object:Gem::Requirement
|
158
|
-
requirements:
|
159
|
-
- - "~>"
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
version: '4'
|
162
|
-
type: :runtime
|
163
|
-
prerelease: false
|
164
|
-
version_requirements: !ruby/object:Gem::Requirement
|
165
|
-
requirements:
|
166
|
-
- - "~>"
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
version: '4'
|
169
|
-
- !ruby/object:Gem::Dependency
|
170
|
-
name: sass-rails
|
171
|
-
requirement: !ruby/object:Gem::Requirement
|
172
|
-
requirements:
|
173
|
-
- - "~>"
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: '4.0'
|
176
|
-
type: :runtime
|
177
|
-
prerelease: false
|
178
|
-
version_requirements: !ruby/object:Gem::Requirement
|
179
|
-
requirements:
|
180
|
-
- - "~>"
|
181
|
-
- !ruby/object:Gem::Version
|
182
|
-
version: '4.0'
|
183
|
-
- !ruby/object:Gem::Dependency
|
184
|
-
name: uglifier
|
185
135
|
requirement: !ruby/object:Gem::Requirement
|
186
136
|
requirements:
|
187
137
|
- - ">="
|
188
138
|
- !ruby/object:Gem::Version
|
189
|
-
version: '
|
139
|
+
version: '3'
|
190
140
|
- - "<"
|
191
141
|
- !ruby/object:Gem::Version
|
192
|
-
version: '
|
142
|
+
version: '4.1'
|
193
143
|
type: :runtime
|
194
144
|
prerelease: false
|
195
145
|
version_requirements: !ruby/object:Gem::Requirement
|
196
146
|
requirements:
|
197
147
|
- - ">="
|
198
148
|
- !ruby/object:Gem::Version
|
199
|
-
version: '
|
149
|
+
version: '3'
|
200
150
|
- - "<"
|
201
151
|
- !ruby/object:Gem::Version
|
202
|
-
version: '
|
152
|
+
version: '4.1'
|
203
153
|
- !ruby/object:Gem::Dependency
|
204
154
|
name: roo
|
205
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,16 +194,22 @@ dependencies:
|
|
244
194
|
name: nifty-utils
|
245
195
|
requirement: !ruby/object:Gem::Requirement
|
246
196
|
requirements:
|
247
|
-
- - "
|
197
|
+
- - ">="
|
248
198
|
- !ruby/object:Gem::Version
|
249
199
|
version: '1.0'
|
200
|
+
- - "<"
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '1.1'
|
250
203
|
type: :runtime
|
251
204
|
prerelease: false
|
252
205
|
version_requirements: !ruby/object:Gem::Requirement
|
253
206
|
requirements:
|
254
|
-
- - "
|
207
|
+
- - ">="
|
255
208
|
- !ruby/object:Gem::Version
|
256
209
|
version: '1.0'
|
210
|
+
- - "<"
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '1.1'
|
257
213
|
- !ruby/object:Gem::Dependency
|
258
214
|
name: nifty-attachments
|
259
215
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,22 +234,50 @@ dependencies:
|
|
278
234
|
name: nifty-dialog
|
279
235
|
requirement: !ruby/object:Gem::Requirement
|
280
236
|
requirements:
|
281
|
-
- - "
|
237
|
+
- - ">="
|
282
238
|
- !ruby/object:Gem::Version
|
283
239
|
version: 1.0.7
|
240
|
+
- - "<"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: '1.1'
|
243
|
+
type: :runtime
|
244
|
+
prerelease: false
|
245
|
+
version_requirements: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
284
247
|
- - ">="
|
285
248
|
- !ruby/object:Gem::Version
|
286
249
|
version: 1.0.7
|
287
|
-
|
250
|
+
- - "<"
|
251
|
+
- !ruby/object:Gem::Version
|
252
|
+
version: '1.1'
|
253
|
+
- !ruby/object:Gem::Dependency
|
254
|
+
name: coffee-rails
|
255
|
+
requirement: !ruby/object:Gem::Requirement
|
256
|
+
requirements:
|
257
|
+
- - "~>"
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
version: '4'
|
260
|
+
type: :development
|
288
261
|
prerelease: false
|
289
262
|
version_requirements: !ruby/object:Gem::Requirement
|
290
263
|
requirements:
|
291
264
|
- - "~>"
|
292
265
|
- !ruby/object:Gem::Version
|
293
|
-
version:
|
294
|
-
|
266
|
+
version: '4'
|
267
|
+
- !ruby/object:Gem::Dependency
|
268
|
+
name: sass-rails
|
269
|
+
requirement: !ruby/object:Gem::Requirement
|
270
|
+
requirements:
|
271
|
+
- - "~>"
|
295
272
|
- !ruby/object:Gem::Version
|
296
|
-
version:
|
273
|
+
version: '4.0'
|
274
|
+
type: :development
|
275
|
+
prerelease: false
|
276
|
+
version_requirements: !ruby/object:Gem::Requirement
|
277
|
+
requirements:
|
278
|
+
- - "~>"
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: '4.0'
|
297
281
|
- !ruby/object:Gem::Dependency
|
298
282
|
name: sqlite3
|
299
283
|
requirement: !ruby/object:Gem::Requirement
|