ishapi 0.1.8.62 → 0.1.8.63
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 +4 -4
- data/app/controllers/ishapi/application_controller.rb +21 -19
- data/app/controllers/ishapi/order_items_controller.rb +24 -3
- data/app/controllers/ishapi/users_controller.rb +0 -33
- data/app/views/ishapi/measurements/_show.jbuilder +4 -0
- data/app/views/ishapi/orders/_item.jbuilder +6 -2
- data/app/views/ishapi/orders/_show.jbuilder +1 -1
- data/app/views/ishapi/users/show.jbuilder +4 -0
- data/lib/ishapi/engine.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fac8d1833645b4ebde8a98e64c2a451d60a12af
|
4
|
+
data.tar.gz: f3b896338ce76e55694ec832a741d294b9560aaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 683cbd2710a726497fe846b8cacd1595454a6285b0b030f3245cb405cb5a11a08d908a75cd1ae57bf2b8d1ad42f9a77deb42eba21f5d992a4d4ead780d709410
|
7
|
+
data.tar.gz: 875d767317fe3bea45b5c4cd897d2626450e25a250e0914901beb6f6872e70ec03e42c426dc6ee8026f30b4f45e140dc873d53257bc3ec22cc3103d98977f387
|
@@ -15,52 +15,51 @@ module Ishapi
|
|
15
15
|
def check_profile
|
16
16
|
accessToken = request.headers[:accessToken]
|
17
17
|
accessToken ||= params[:fb_long_access_token]
|
18
|
-
accessToken ||= params[:accessToken]
|
18
|
+
accessToken ||= params[:accessToken]
|
19
19
|
if accessToken
|
20
20
|
@graph = Koala::Facebook::API.new( accessToken )
|
21
21
|
@me = @graph.get_object( 'me', :fields => 'email' )
|
22
22
|
@current_user = User.find_by :email => @me['email']
|
23
|
-
@current_profile = @current_user.profile
|
24
|
-
@current_order = @current_profile.orders.where( :submitted_at => nil ).first || ::CoTailors::Order.create( :profile_id => @current_profile.id )
|
25
23
|
else
|
26
|
-
@current_user
|
24
|
+
@current_user = current_user if Rails.env.test?
|
27
25
|
end
|
26
|
+
@current_profile = @current_user.profile
|
27
|
+
@current_order = @current_profile.current_order
|
28
|
+
# orders.where( :submitted_at => nil ).first || ::CoTailors::Order.create( :profile_id => @current_profile.id )
|
28
29
|
end
|
29
30
|
|
30
31
|
def set_profile
|
31
32
|
accessToken = request.headers[:accessToken]
|
32
33
|
accessToken ||= params[:fb_long_access_token]
|
33
|
-
accessToken ||= params[:accessToken]
|
34
|
+
accessToken ||= params[:accessToken]
|
34
35
|
|
35
|
-
params[:domain] ||= '_default'
|
36
|
+
# params[:domain] ||= '_default'
|
36
37
|
|
37
38
|
if accessToken
|
38
39
|
begin
|
39
40
|
@graph = Koala::Facebook::API.new( accessToken )
|
40
41
|
@me = @graph.get_object( 'me', :fields => 'email' )
|
41
|
-
@
|
42
|
+
@current_user = User.find_or_create_by :email => @me['email']
|
42
43
|
@oauth = Koala::Facebook::OAuth.new( FB[params['domain']][:app], FB[params['domain']][:secret] )
|
43
44
|
get_token = get_long_token( accessToken )
|
44
45
|
@long_lived_token = get_token['access_token']
|
45
46
|
|
46
47
|
begin
|
47
|
-
@
|
48
|
-
@
|
48
|
+
@current_profile = IshModels::UserProfile.find_by :email => @me['email']
|
49
|
+
@current_profile.update_attributes({ :fb_access_token => @long_lived_token,
|
49
50
|
:fb_long_access_token => @long_lived_token,
|
50
51
|
:fb_expires_in => get_token['expires_in']
|
51
52
|
})
|
52
53
|
rescue Mongoid::Errors::DocumentNotFound
|
53
|
-
@
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
@current_profile = IshModels::UserProfile.create :user => @current_user, :email => @me['email'],
|
55
|
+
:fb_access_token => @long_lived_token,
|
56
|
+
:fb_long_access_token => @long_lived_token,
|
57
|
+
:fb_expires_in => get_token['expires_in'],
|
58
|
+
:fb_id => params[:id],
|
59
|
+
:name => params[:name],
|
60
|
+
:signed_request => params[:signedRequest]
|
60
61
|
end
|
61
|
-
@current_user
|
62
|
-
@current_profile = @profile
|
63
|
-
@current_order = @current_profile.orders.where( :submitted_at => nil ).first || ::CoTailors::Order.new( :profile_id => @current_profile.id )
|
62
|
+
@current_user.reload
|
64
63
|
rescue Koala::Facebook::AuthenticationError => e
|
65
64
|
render :json => { :status => :not_ok, :errors => "Probably expired token: #{accessToken}" }
|
66
65
|
return
|
@@ -68,6 +67,9 @@ module Ishapi
|
|
68
67
|
else
|
69
68
|
@current_user = current_user if Rails.env.test?
|
70
69
|
end
|
70
|
+
@current_profile = @current_user.profile
|
71
|
+
@current_order = @current_profile.current_order
|
72
|
+
# orders.where( :submitted_at => nil ).first || ::CoTailors::Order.new( :profile_id => @current_profile.id )
|
71
73
|
end
|
72
74
|
|
73
75
|
def get_long_token accessToken
|
@@ -5,18 +5,39 @@ module Ishapi
|
|
5
5
|
before_action :check_profile, :only => [ :create ]
|
6
6
|
|
7
7
|
def create
|
8
|
-
# byebug
|
9
|
-
|
10
8
|
authorize! :add, CoTailors::OrderItem
|
11
|
-
@
|
9
|
+
@measurement = CoTailors::ProfileMeasurement.create params['order_item'].permit( :neck_around )
|
10
|
+
@order_item = CoTailors::OrderItem.new params['order_item'].permit( :quantity, :kind, :fabric )
|
12
11
|
@order_item.order_id = @current_order.id
|
12
|
+
@order_item.measurement = @measurement
|
13
|
+
@measurement.order_item_id = @order_item.id
|
14
|
+
@measurement.save
|
15
|
+
|
16
|
+
if params[:order_item][:saveMeasurement]
|
17
|
+
m = @current_profile.measurements[0] || CoTailors::ProfileMeasurement.create( :profile => @current_profile )
|
18
|
+
flag = m.update_attributes( measurement_params )
|
19
|
+
render :json => { :statuc => :not_ok, :error => m.errors.messages } and return if !flag
|
20
|
+
end
|
21
|
+
|
13
22
|
flag = @order_item.save
|
14
23
|
if flag
|
24
|
+
puts! @order_item.measurement, 'ok'
|
15
25
|
render :json => { :status => :ok, :message => 'Successfully put an order item' }
|
16
26
|
else
|
17
27
|
render :json => { :status => :not_ok, :error => @order_item.errors.messages }
|
18
28
|
end
|
19
29
|
end
|
20
30
|
|
31
|
+
#
|
32
|
+
# private
|
33
|
+
#
|
34
|
+
private
|
35
|
+
|
36
|
+
def measurement_params
|
37
|
+
out = {}
|
38
|
+
out[:neck_around] = params[:order_item][:neckAround] if params[:order_item][:neckAround]
|
39
|
+
out
|
40
|
+
end
|
41
|
+
|
21
42
|
end
|
22
43
|
end
|
@@ -12,40 +12,7 @@ module Ishapi
|
|
12
12
|
|
13
13
|
def show
|
14
14
|
authorize! :fb_sign_in, Ishapi
|
15
|
-
=begin
|
16
|
-
begin
|
17
|
-
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
18
|
-
me = @graph.get_object( 'me', :fields => 'email' )
|
19
|
-
@user = User.find_by :email => me['email']
|
20
|
-
@user_profile = IshModels::UserProfile.find_by :email => me['email']
|
21
|
-
rescue Koala::Facebook::AuthenticationError => e
|
22
|
-
render :json => { :status => :not_ok, :errors => "Probably expired token." }
|
23
|
-
return
|
24
|
-
end
|
25
|
-
=end
|
26
15
|
end
|
27
16
|
|
28
|
-
=begin
|
29
|
-
def update
|
30
|
-
authorize! :fb_sign_in, Ishapi
|
31
|
-
begin
|
32
|
-
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
33
|
-
me = @graph.get_object( 'me', :fields => 'email' )
|
34
|
-
@user = User.find_by( :email => me['email'] )
|
35
|
-
@user_profile = IshModels::UserProfile.find_by :email => me['email']
|
36
|
-
flag = @user_profile.update_attributes( params[:user_profile].permit( :about, :current_city_id ) )
|
37
|
-
@errors = @user_profile.errors.messages
|
38
|
-
rescue Koala::Facebook::AuthenticationError => e
|
39
|
-
flag = false
|
40
|
-
@errors = "Probably expired token."
|
41
|
-
end
|
42
|
-
if flag
|
43
|
-
render :json => { :status => :ok }
|
44
|
-
else
|
45
|
-
render :json => { :status => :not_ok, :errors => @errors }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
=end
|
49
|
-
|
50
17
|
end
|
51
18
|
end
|
@@ -19,5 +19,9 @@ if @current_profile.addresses[0]
|
|
19
19
|
json.partial! 'ishapi/addresses/show', :address => @current_profile.addresses[0]
|
20
20
|
end
|
21
21
|
|
22
|
+
if @current_profile.measurements[0]
|
23
|
+
json.partial! 'ishapi/measurements/show', :measurement => @current_profile.measurements[0]
|
24
|
+
end
|
25
|
+
|
22
26
|
json.partial! 'ishapi/orders/show', :order => @current_order
|
23
27
|
|
data/lib/ishapi/engine.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ishapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.63
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- app/views/ishapi/galleries/index.jbuilder~
|
241
241
|
- app/views/ishapi/galleries/show.jbuilder
|
242
242
|
- app/views/ishapi/galleries/show.jbuilder~
|
243
|
+
- app/views/ishapi/measurements/_show.jbuilder
|
243
244
|
- app/views/ishapi/my/reports/index.jbuilder
|
244
245
|
- app/views/ishapi/my/reports/index.jbuilder~
|
245
246
|
- app/views/ishapi/newsitems/_index.jbuilder
|