ishapi 0.1.8.62 → 0.1.8.63

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
  SHA1:
3
- metadata.gz: 9fb0c5570bfa0936c96dd1a529a792a849879f70
4
- data.tar.gz: 23112a0870d3736f43a13704c84e01c4a4f07f8e
3
+ metadata.gz: 6fac8d1833645b4ebde8a98e64c2a451d60a12af
4
+ data.tar.gz: f3b896338ce76e55694ec832a741d294b9560aaf
5
5
  SHA512:
6
- metadata.gz: 2a4b8ebbe8a1a4462ce6887a31d51b0812c9cd903b9f75fc2a069cb2d627618465c6b12c19e5a52df5ee9b975c51f70ee133bb528619da8bb53800a824c9431c
7
- data.tar.gz: bd728510c8311d0698b3d695c57a01b3d6fc79c84c68d6a2c675fc561a06296b13931a02022200cf3c6cb12ad7f64f81f838c678972f3a7e385e1479f445cbed
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] # if (params[:debug] == 'abba' && Rails.env.development?)
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 = current_user if Rails.env.test?
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] # if (params[:debug] == 'abba' && Rails.env.development?)
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
- @user = User.find_or_create_by :email => @me['email']
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
- @profile = IshModels::UserProfile.find_by :email => @me['email']
48
- @profile.update_attributes({ :fb_access_token => @long_lived_token,
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
- @profile = IshModels::UserProfile.create :user => @user, :email => @me['email'],
54
- :fb_access_token => @long_lived_token,
55
- :fb_long_access_token => @long_lived_token,
56
- :fb_expires_in => get_token['expires_in'],
57
- :fb_id => params[:id],
58
- :name => params[:name],
59
- :signed_request => params[:signedRequest]
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 = @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
- @order_item = CoTailors::OrderItem.new params['order_item'].permit!
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
@@ -0,0 +1,4 @@
1
+
2
+ json.measurement do
3
+ json.neck_around measurement.neck_around
4
+ end
@@ -1,3 +1,7 @@
1
1
 
2
- json.kind item.kind
3
- json.fabric item.fabric
2
+ json.kind item.kind
3
+ json.fabric item.fabric
4
+ json.quantity item.quantity
5
+ if item.measurement
6
+ json.neck_around item.measurement.neck_around
7
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  json.n_items order.items.length
5
5
  json.order do
6
- order.items.each do |item|
6
+ json.array! order.items do |item|
7
7
  json.partial! 'ishapi/orders/item', :item => item
8
8
  end
9
9
  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
@@ -1,7 +1,7 @@
1
1
 
2
2
  require 'rubygems'
3
3
  require 'rack/throttle'
4
- require 'jbuilder'
4
+ # require 'jbuilder'
5
5
 
6
6
  module Ishapi
7
7
  class Engine < ::Rails::Engine
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.62
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-15 00:00:00.000000000 Z
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