workarea-cart_sharing 1.0.2.pre → 1.0.3.pre
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '03038bd1fc388a4aa6e727281b84eaa617b2b2b22f193ccd48f54d54e0968241'
|
4
|
+
data.tar.gz: b5de9f7feb5d4e69d1b7d831d2da4020f3b8c832ab8bdc27b3249afadd90eb00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82d865fefadc37dc75d3336226cfb37ec68dcce40ab8a828146c196e2dd0b768ee17323c09f89d2dd6ac7c101ee8fabaa9ab6160536dcedf3611172d7335d8ad
|
7
|
+
data.tar.gz: 016b0dc2dd1e03210d961eaf20826fed321483b735eae562a07380034c7db0f5eb1f66bb33457d242987150c11c50f3ce9fd1c42fa2b0ddbe5319443e24099ef
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module Workarea
|
2
2
|
decorate Storefront::CartsController, with: :cart_sharing do
|
3
|
+
decorated do
|
4
|
+
before_action :set_sharable_token
|
5
|
+
end
|
3
6
|
def from
|
4
7
|
if order = Order.find_by(sharable_token: params[:token]) rescue nil
|
5
8
|
|
@@ -18,6 +21,12 @@ module Workarea
|
|
18
21
|
this_order.items = this_order.items + items
|
19
22
|
this_order.save
|
20
23
|
end
|
24
|
+
|
25
|
+
def set_sharable_token
|
26
|
+
return true if self.current_order.sharable_token.present?
|
27
|
+
self.current_order.sharable_token = Workarea::Order.generate_unique_secure_token
|
28
|
+
self.current_order.save
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
end
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-cart_sharing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gunasekaran.r
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- app/views/workarea/storefront/carts/_sharable.html.haml
|
46
46
|
- bin/rails
|
47
47
|
- config/initializers/appends.rb
|
48
|
-
- config/initializers/sharable_token.rb
|
49
48
|
- config/initializers/workarea.rb
|
50
49
|
- config/locales/en.yml
|
51
50
|
- config/routes.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Workarea::SharableToken
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
|
4
|
-
include ActiveRecord::SecureToken
|
5
|
-
|
6
|
-
included do
|
7
|
-
field :sharable_token, type: String
|
8
|
-
index({ sharable_token: 1 })
|
9
|
-
has_secure_token
|
10
|
-
before_validation :ensure_token_exists
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def find_by_token(sharable_token)
|
15
|
-
find_by(sharable_token: sharable_token) rescue nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def ensure_token_exists
|
22
|
-
self.sharable_token = self.class.generate_unique_secure_token if sharable_token.blank?
|
23
|
-
end
|
24
|
-
end
|