ishapi 0.1.8.69 → 0.1.8.70

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
  SHA1:
3
- metadata.gz: 673c9fe837a1ba77d8bb26a1ca23fb2b6e135b2e
4
- data.tar.gz: 6be81ac105a8e49db4e40d341eef339750620405
3
+ metadata.gz: 60a5d993e107b12d47480b884b7a77031e35a8c8
4
+ data.tar.gz: 82650adbc7f1cc677edcad7c86073e811ba62700
5
5
  SHA512:
6
- metadata.gz: 3890acc78628bada8285236719ca9c480638ddf98e5fa8e0f4061c84122fc9e43b057520cb2cb3569afade071522c5e3526e7db531b04cd5d0cc6b57d398f7bf
7
- data.tar.gz: f9b7aaee47cba2bcad6a2d4c8bd84519626580b5d61d270d4fb2570ec28f3587530b56da2b817a94ac62fc1925b36e03e0385d6550e9e92c0f48db59ead0b001
6
+ metadata.gz: c80d17b2fccfcc9037009bf85d9c84f9f9be5723d661e176df0a352f3b1b08b98a46bafd37161fe36d34301c50b44070bd4d45ba79200f8543c0cdf2ef4dbb07
7
+ data.tar.gz: 539fb1597817625b4644653b78caeb8c438196e7bb6ccd2b375b1e282ff2f574d0fcc5ef1b2a0b18ae4adf7a93979194fbc95073c434a0cc1b0cbbee9754371b
@@ -0,0 +1,26 @@
1
+ require_dependency "ishapi/application_controller"
2
+
3
+ module Ishapi
4
+ class MeasurementsController < ApplicationController
5
+ before_action :check_profile, :only => [ :update ]
6
+
7
+ def update
8
+ authorize! :update_measurements, CoTailors::Order
9
+ flag = @current_profile.measurement.update_attributes params[:measurement].permit( CoTailors::Order::MEASUREMENT_PARAMS )
10
+
11
+ # byebug
12
+
13
+ if flag
14
+ render :json => { :status => :ok }
15
+ else
16
+ render :json => { :status => :not_ok, :error => @current_profile.measurement.errors.messages }
17
+ end
18
+ end
19
+
20
+ #
21
+ # private
22
+ #
23
+ private
24
+
25
+ end
26
+ end
@@ -6,22 +6,32 @@ module Ishapi
6
6
 
7
7
  def create
8
8
  authorize! :add, CoTailors::OrderItem
9
- @measurement = CoTailors::ProfileMeasurement.create params['order_item'].permit( :neck_around )
10
9
  @order_item = CoTailors::OrderItem.new params['order_item'].permit( :quantity, :kind, :fabric )
11
10
  @order_item.order_id = @current_order.id
12
11
  @order_item.measurement = @measurement
13
- @measurement.order_item_id = @order_item.id
14
- @measurement.save
12
+ @order_item.cost = case params[:order_item][:kind]
13
+ when CoTailors::OrderItem::KIND_SHIRT
14
+ CoTailors::Shirt.cost
15
+ when CoTailors::OrderItem::KIND_PANTS
16
+ CoTaiilors::Pant.cost
17
+ when CoTailors::OrderItem::KIND_SUIT
18
+ CoTailors::Suit.cost
19
+ end
20
+ @order_item.measurement = CoTailors::ProfileMeasurement.create params['order_item'].permit( CoTailors::Order::MEASUREMENT_PARAMS )
21
+
22
+ # byebug
15
23
 
16
24
  if params[:order_item][:saveMeasurement]
17
- m = @current_profile.measurements[0] || CoTailors::ProfileMeasurement.create( :profile => @current_profile )
25
+ m = @current_profile.measurement # || CoTailors::ProfileMeasurement.create( :profile => @current_profile )
18
26
  flag = m.update_attributes( measurement_params )
19
- render :json => { :statuc => :not_ok, :error => m.errors.messages } and return if !flag
27
+ if !flag
28
+ render :json => { :statuc => :not_ok, :error => m.errors.messages }
29
+ return
30
+ end
20
31
  end
21
32
 
22
33
  flag = @order_item.save
23
34
  if flag
24
- puts! @order_item.measurement, 'ok'
25
35
  render :json => { :status => :ok, :message => 'Successfully put an order item' }
26
36
  else
27
37
  render :json => { :status => :not_ok, :error => @order_item.errors.messages }
@@ -16,6 +16,15 @@ params = {"token"=>{"id"=>"tok_1BoLkRDpn3WurCccVNQK4pfV", "object"=>"token", "ca
16
16
 
17
17
  @order = CoTailors::Order.where( :profile_id => @current_profile.id, :submitted_at => nil ).first
18
18
  @order.submitted_at = Time.now
19
+
20
+ Stripe.api_key = STRIPE_SK
21
+ charge = Stripe::Charge.create :amount => @order.grand_total, :currency => 'usd', :source => params['token']['id']
22
+ flag = charge.outcome[:type] == 'authorized'
23
+ if !flag
24
+ render :json => { :status => :not_ok, :message => "Something went wrong with the charge: " + charge.outcome.to_s }
25
+ return
26
+ end
27
+
19
28
  flag = @order.save
20
29
  if flag
21
30
  render :json => { :status => :ok, :message => 'Successfully placed the order' }
@@ -17,12 +17,11 @@ class Ishapi::Ability
17
17
  gallery.user == user
18
18
  end
19
19
 
20
-
21
20
  can [ :update ], ::CoTailors::Address do |address|
22
21
  puts [ user.inspect, address.inspect ], '+++ user in cancancan'
23
22
  true
24
23
  end
25
-
24
+
26
25
  end
27
26
  #
28
27
  # anonymous user
@@ -33,8 +32,8 @@ class Ishapi::Ability
33
32
 
34
33
  can [ :update ], ::CoTailors::Address
35
34
  can [ :add ], ::CoTailors::OrderItem
36
- can [ :create ], ::CoTailors::Order
37
-
35
+ can [ :create, :update_measurements ], ::CoTailors::Order
36
+
38
37
  can [ :index, :show ], Event
39
38
 
40
39
  can [ :index ], Gallery
@@ -1,4 +1,14 @@
1
1
 
2
+ # _vp_ 20180309
3
+ # MEASUREMENT_PARAMS = [ :neck_around, :chest_around, :waist_around, :sleeve_length, :shoulder_width, :shirt_length, :bicep_around ]
4
+ #
5
+
2
6
  json.measurement do
3
- json.neck_around measurement.neck_around
7
+ json.neck_around measurement.neck_around
8
+ json.chest_around measurement.chest_around
9
+ json.waist_around measurement.waist_around
10
+ json.sleeve_length measurement.sleeve_length
11
+ json.shoulder_width measurement.shoulder_width
12
+ json.shirt_length measurement.shirt_length
13
+ json.bicep_around measurement.bicep_around
4
14
  end
@@ -2,6 +2,7 @@
2
2
  json.kind item.kind
3
3
  json.fabric item.fabric
4
4
  json.quantity item.quantity
5
+ json.cost item.cost
5
6
  if item.measurement
6
7
  json.neck_around item.measurement.neck_around
7
8
  end
@@ -1,7 +1,9 @@
1
1
 
2
2
  # ishapi / orders / _show
3
3
 
4
- json.n_items order.items.length
4
+ json.n_items order.items.length
5
+ json.order_total order.items.map { |i| i.cost }.reduce( :+ )
6
+
5
7
  json.order do
6
8
  json.array! order.items do |item|
7
9
  json.partial! 'ishapi/orders/item', :item => item
@@ -19,8 +19,8 @@ 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]
22
+ if @current_profile.measurement
23
+ json.partial! 'ishapi/measurements/show', :measurement => @current_profile.measurement
24
24
  end
25
25
 
26
26
  json.partial! 'ishapi/orders/show', :order => @current_order
@@ -9,9 +9,11 @@ json.venues do
9
9
  json.id venue.id.to_s
10
10
  json.name venue.name
11
11
  json.name_seo venue.name_seo
12
+ json.subhead venue.subhead
12
13
  json.description venue.descr
13
14
  json.x venue.x
14
15
  json.y venue.y
15
16
  json.photo venue.profile_photo.photo.url( :thumb ) if venue.profile_photo
17
+ json.partial! 'ishapi/tags/index', :tags => venue.tags
16
18
  end
17
19
  end
@@ -7,9 +7,10 @@ Ishapi::Engine.routes.draw do
7
7
  get 'cities', :to => 'cities#index'
8
8
  get 'cities/view/:cityname', :to => 'cities#show'
9
9
  get 'cities/features', :to => 'cities#features'
10
-
11
- post 'co_tailors/orders', :to => 'orders#create'
12
- post 'co_tailors/order_items', :to => 'order_items#create'
10
+
11
+ post 'co_tailors/orders', :to => 'orders#create'
12
+ post 'co_tailors/order_items', :to => 'order_items#create'
13
+ post 'co_tailors/measurements', :to => 'measurements#update'
13
14
  namespace :co_tailors do
14
15
  end
15
16
 
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.69
4
+ version: 0.1.8.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-11 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -191,6 +191,7 @@ files:
191
191
  - app/controllers/ishapi/galleries_controller.rb
192
192
  - app/controllers/ishapi/galleries_controller.rb~
193
193
  - app/controllers/ishapi/invoices_controller.rb
194
+ - app/controllers/ishapi/measurements_controller.rb
194
195
  - app/controllers/ishapi/my/my_controller.rb
195
196
  - app/controllers/ishapi/my/my_controller.rb~
196
197
  - app/controllers/ishapi/my/reports_controller.rb