ishapi 0.1.8.171 → 0.1.8.174

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: 1061557c4a428d72d380f5eaa54ece94dfb5c6c5493707d23297007af653b929
4
- data.tar.gz: 310cf825c56d201501a57e592ef31a0ae8b282811c1d43d6cb91399f80d4deb2
3
+ metadata.gz: 5ca21156e5ba448350ec31e26cd9b5535e592f1466fcd93d2fdc20a95c54a6e6
4
+ data.tar.gz: 81296feba05c6e80d915ba72471a14bb478dbb56b4426a89fc8a74dc1ee9c879
5
5
  SHA512:
6
- metadata.gz: 238eaa5df713a592f8f88456771188a357b0ae4d1d5c463ad390e339573b3ce04749ac3c16779588b5be4374ff7798ee5a44155d932d1281f954ca6ab70f0f1f
7
- data.tar.gz: d9208f4b3fb2075bcb418badad07d7466818eed030381b13aba91474dc24db48d87fc8819ecf934b9ae9e7c296a289cec02b57b133753c51589548f076a3938e
6
+ metadata.gz: caf3f76f15dfa7ce327ad1397e2c5c5675a049319078d889e1d86975277052f3f7b93a0125965e3e0b1b6e391a3884b5f95f6590b1b298d5661edd21698a074f
7
+ data.tar.gz: a8d1894747b69ead5559264ed71c78f4ff3c4beb7add7890e9f87b1a928fba61c6afac94daa0e4cd1391ee8b2b6a8f8dfaee6143e771536ac5359e382f3a3b15
@@ -43,14 +43,16 @@ module Ishapi
43
43
  end
44
44
  end
45
45
 
46
- ## This is for guyd _vp_ 20200721
46
+ ## This is for guyd _vp_ 2020-07-21
47
+ ## It's been a while! _vp_ 2022-03-01
47
48
  def create2
48
49
  authorize! :create, ::Ish::Payment
50
+ current_user.profile.update_attributes({ is_purchasing: true })
49
51
 
50
52
  begin
51
53
  amount_cents = 503 # @TODO: change
52
54
 
53
- ::Stripe.api_key = STRIPE_SK
55
+ ::Stripe.api_key = ::STRIPE_SK
54
56
  intent = Stripe::PaymentIntent.create({
55
57
  amount: amount_cents,
56
58
  currency: 'usd',
@@ -59,18 +61,20 @@ module Ishapi
59
61
 
60
62
  payment = Ish::Payment.create!(
61
63
  client_secret: intent.client_secret,
62
- email: @current_user.email,
64
+ email: current_user.email,
63
65
  payment_intent_id: intent.id,
64
- profile_id: @current_user.profile.id )
66
+ profile_id: current_user.profile.id )
65
67
 
66
68
  render json: { client_secret: intent.client_secret }
67
69
  rescue Mongoid::Errors::DocumentNotFound => e
68
- puts! e, 'e'
70
+ puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
69
71
  render :status => 404, :json => e
70
72
  end
71
73
  end
72
74
 
75
+ ##
73
76
  ## webhook
77
+ ##
74
78
  def stripe_confirm
75
79
  authorize! :open_permission, ::Ishapi
76
80
  payload = request.body.read
@@ -78,7 +82,7 @@ module Ishapi
78
82
  begin
79
83
  event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
80
84
  rescue StandardError => e
81
- puts! e, 'e'
85
+ puts! e, 'could not #stripe_confirm'
82
86
  render status: 400, json: { status: :not_ok }
83
87
  return
84
88
  end
@@ -87,8 +91,11 @@ module Ishapi
87
91
 
88
92
  payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
89
93
  if payment && payment_intent['status'] == 'succeeded'
94
+
90
95
  payment.update_attributes( status: :confirmed )
91
- payment.profile.update_attributes!( n_unlocks: payment.profile.n_unlocks + 5 )
96
+ n_unlocks = payment.profile.n_unlocks + 5
97
+
98
+ payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false ) # @TODO: it's not always 5? adjust
92
99
  end
93
100
 
94
101
  render status: 200, json: { status: :ok }
@@ -98,18 +105,18 @@ module Ishapi
98
105
  authorize! :unlock, ::Ish::Payment
99
106
  item = Object::const_get(params['kind']).find params['id']
100
107
 
101
- puts! params, 'unlocking...'
102
-
103
108
  existing = Purchase.where( user_profile: @current_user.profile, item: item ).first
104
109
  if existing
105
110
  render status: 200, json: { status: :ok, message: 'already purchased' }
106
111
  return
107
112
  end
108
113
 
109
- @current_user.profile.update_attributes n_unlocks: @current_user.profile.n_unlocks - 1 # @TODO: the number is variable
114
+ @current_user.profile.inc( n_unlocks: -item.premium_tier )
115
+
110
116
  purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_user.profile, )
111
117
 
112
- render status: 200, json: { status: :ok }
118
+ @profile = @current_user.profile
119
+ render 'ishapi/users/account'
113
120
  end
114
121
 
115
122
  end
@@ -3,7 +3,7 @@ require_dependency "ishapi/application_controller"
3
3
  module Ishapi
4
4
  class UsersController < ApplicationController
5
5
 
6
- skip_authorization_check only: %i| fb_sign_in login |
6
+ skip_authorization_check only: %i| create fb_sign_in login |
7
7
 
8
8
  before_action :check_profile_hard, only: %i| account |
9
9
 
@@ -17,6 +17,20 @@ module Ishapi
17
17
  }, status: 401
18
18
  end
19
19
 
20
+ def create
21
+ @profile = Profile.new( email: params[:email] )
22
+ @user = User.new( email: params[:email], password: params[:password], profile: @profile )
23
+
24
+ if @profile.save && @user.save
25
+ @jwt_token = encode(user_id: @user.id.to_s)
26
+ render 'login'
27
+ else
28
+ render json: {
29
+ messages: [],
30
+ }, status: 401
31
+ end
32
+ end
33
+
20
34
  def fb_sign_in
21
35
  authorize! :fb_sign_in, Ishapi
22
36
  # render :json => { :status => :ok }
@@ -16,7 +16,18 @@ json.markers do
16
16
  json.title_img_path marker.title_image ? marker.title_image.image.url(:thumb) : image_missing
17
17
  json.item_type marker.item_type
18
18
  json.url marker.url
19
- json.premium_tier marker.destination.premium_tier
20
- json.id marker.destination.id.to_s
19
+
20
+ ## @TODO: this is copy-pasted and should be abstracted.
21
+ destination = marker.destination
22
+ json.premium_tier destination.premium_tier
23
+ json.id destination.id.to_s
24
+ if destination.is_premium
25
+ json.premium_tier destination.premium_tier
26
+ json.is_premium destination.premium_tier > 0
27
+ if current_user && current_user.profile
28
+ json.is_purchased current_user.profile.has_premium_purchase( destination )
29
+ end
30
+ end
31
+
21
32
  end
22
33
  end
@@ -39,7 +39,8 @@ json.newsitems do
39
39
  json.id item.report_id.to_s
40
40
  json.item_type item.report.class.name
41
41
  json.name item.report.name
42
- json.reportname item.report.slug
42
+ json.reportname item.report.slug # @TODO: @deprecated, remove
43
+ json.slug item.report.slug
43
44
  json.subhead item.report.subhead
44
45
  json.username item.report.user_profile.name if item.report.user_profile
45
46
 
@@ -8,10 +8,12 @@ key = [ @report, params ]
8
8
  json.cache! key do
9
9
  json.report do
10
10
  json.id @report.id.to_s
11
+ json.item_type @report.class.name
11
12
  json.name @report.name
12
- json.reportname @report.slug
13
+ json.reportname @report.slug # @TODO: @deprecated, remove
14
+ json.slug @report.slug
13
15
  if @report.photo
14
- json.photo_url @report.photo.photo.url( :small )
16
+ json.photo_url @report.photo.photo.url( :small )
15
17
  json.thumb_url @report.photo.photo.url( :thumb )
16
18
  end
17
19
 
@@ -22,7 +24,7 @@ json.cache! key do
22
24
  json.cityname @report.city.cityname if @report.city
23
25
  json.subhead @report.subhead
24
26
  json.description @report.descr
25
-
27
+
26
28
  if @report.photo
27
29
  json.photo do
28
30
  json.thumb_url @report.photo.photo.url :thumb
@@ -42,5 +44,5 @@ json.cache! key do
42
44
  json.large_url @report.photo.photo.url :large
43
45
  end
44
46
  end
45
-
47
+
46
48
  end
@@ -1,15 +1,15 @@
1
1
 
2
- json.id @profile.id
2
+ json.id @profile.id.to_s
3
3
  json.name @profile.name
4
4
  json.email @profile.email
5
5
  json.profile_photo_url @profile.profile_photo.photo.url( :thumb ) if @profile.profile_photo
6
6
 
7
- json.n_reports @profile.reports.count
8
- json.n_galleries @profile.galleries.count
9
- json.n_videos @profile.videos.count
10
- json.n_stars @profile.n_stars # @TODO: which one is deprecated?
11
- json.n_unlocks @profile.n_unlocks # @TODO: which one is deprecated?
12
-
7
+ json.n_reports @profile.reports.count
8
+ json.n_galleries @profile.galleries.count
9
+ json.n_videos @profile.videos.count
10
+ json.n_stars @profile.n_stars # @TODO: which one is deprecated?
11
+ json.n_unlocks @profile.n_unlocks # @TODO: which one is deprecated?
12
+ json.is_purchasing @profile.is_purchasing
13
13
  if @profile.current_city
14
14
  json.current_city @profile.current_city
15
15
  end
@@ -1,2 +1,2 @@
1
1
 
2
- json.partial! 'account'
2
+ json.partial! 'ishapi/users/account'
@@ -30,6 +30,7 @@ if video.user_profile
30
30
  json.username video.user_profile.name
31
31
  end
32
32
 
33
+ ## @TODO: this is copy-pasted and should be abstracted.
33
34
  if video.is_premium
34
35
  json.premium_tier video.premium_tier
35
36
  json.is_premium video.premium_tier > 0
data/config/routes.rb CHANGED
@@ -8,16 +8,6 @@ Ishapi::Engine.routes.draw do
8
8
  get 'cities/view/:cityname', :to => 'cities#show'
9
9
  get 'cities/features', :to => 'cities#features'
10
10
 
11
- ## @TODO: remove all co-tailors stuff
12
- =begin
13
- post 'co_tailors/orders', :to => 'orders#create'
14
- post 'co_tailors/order_items', :to => 'order_items#create'
15
- post 'co_tailors/measurements', :to => 'measurements#update'
16
- get 'co_tailors/products/by-kind/:kind', :to => 'products#show'
17
- namespace :co_tailors do
18
- end
19
- =end
20
-
21
11
  get 'events/view/:eventname', :to => 'events#show'
22
12
 
23
13
  get 'galleries', :to => 'galleries#index'
@@ -73,6 +63,7 @@ Ishapi::Engine.routes.draw do
73
63
  get 'users/profile', to: 'users#show' # @TODO: only for testing! accessToken must be hidden
74
64
  match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
75
65
  post 'users/login', to: 'users#login'
66
+ post 'users', to: 'users#create'
76
67
 
77
68
  get 'venues', :to => 'venues#index'
78
69
  get 'venues/view/:venuename', :to => 'venues#show'
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.171
4
+ version: 0.1.8.174
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-27 00:00:00.000000000 Z
11
+ date: 2022-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -268,12 +268,10 @@ files:
268
268
  - app/controllers/ishapi/order_items_controller.rb
269
269
  - app/controllers/ishapi/orders_controller.rb
270
270
  - app/controllers/ishapi/payments_controller.rb
271
- - app/controllers/ishapi/products_controller.rb
272
271
  - app/controllers/ishapi/reports_controller.rb
273
272
  - app/controllers/ishapi/sites_controller.rb
274
273
  - app/controllers/ishapi/stock_watches_controller.rb
275
274
  - app/controllers/ishapi/tags_controller.rb
276
- - app/controllers/ishapi/unrestricted_controller.rb-trash
277
275
  - app/controllers/ishapi/user_profiles_controller.rb
278
276
  - app/controllers/ishapi/users_controller.rb
279
277
  - app/controllers/ishapi/venues_controller.rb
@@ -1,12 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
- module Ishapi
3
- class ProductsController < UnrestrictedController
4
-
5
- def show
6
- @product = ::CoTailors::Product.where( :kind => params[:kind] ).first
7
- authorize! :show, @product
8
- end
9
-
10
- end
11
- end
12
-
@@ -1,25 +0,0 @@
1
- module Ishapi
2
- class UnrestrictedController < ActionController::Base
3
- protect_from_forgery :prepend => true, :with => :exception
4
- layout :false
5
-
6
- before_action :set_current_ability
7
-
8
- check_authorization
9
- skip_before_action :verify_authenticity_token
10
-
11
-
12
- private
13
-
14
-
15
- def set_current_ability
16
- @current_ability ||= ::Ishapi::Ability.new( User.new )
17
- end
18
-
19
- def puts! a, b=''
20
- puts "+++ +++ #{b}"
21
- puts a.inspect
22
- end
23
-
24
- end
25
- end