ishapi 0.1.8.169 → 0.1.8.173
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 +1 -1
- data/app/controllers/ishapi/cities_controller.rb +2 -2
- data/app/controllers/ishapi/payments_controller.rb +20 -11
- data/app/controllers/ishapi/users_controller.rb +16 -10
- data/app/helpers/ishapi/application_helper.rb +5 -0
- data/app/models/ishapi/ability.rb +0 -2
- data/app/views/ishapi/maps/show.jbuilder +2 -2
- data/app/views/ishapi/markers/_index.jbuilder +15 -2
- data/app/views/ishapi/newsitems/_index.jbuilder +2 -3
- data/app/views/ishapi/reports/show.jbuilder +6 -4
- data/app/views/ishapi/users/_account.jbuilder +7 -8
- data/app/views/ishapi/users/account.jbuilder +1 -1
- data/app/views/ishapi/users/login.jbuilder +2 -2
- data/app/views/ishapi/videos/_show.jbuilder +1 -0
- data/config/routes.rb +1 -10
- metadata +2 -5
- data/app/controllers/ishapi/products_controller.rb +0 -12
- data/app/controllers/ishapi/unrestricted_controller.rb +0 -25
- data/app/helpers/ishapi/articles_helper.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fd21e0b9c2e8b3e23e8990bdb1111a3099aaeabebfa21ccaf2875c1ef1440a9
|
4
|
+
data.tar.gz: d9f728856e1417d2e9517e11ce55c5437a12e57259b6cdce9d1c635aab3bedd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a62f4b13841087c81b7ab0f8ea07abe99e4437a72adc7221849c6edef37fcb87599ba43545df66f272acf14c25de18cfc16805f62ea503b8cda99c71339675
|
7
|
+
data.tar.gz: 2af4362118d044097aa3291b18c828321887f8ec8a19d0e06a622e18965727f2f37be57d4360e7151059ddb36d168a1990c751fde8d99cb1945bbce0a694ce80
|
@@ -42,7 +42,7 @@ class Ishapi::ApplicationController < ActionController::Base
|
|
42
42
|
rescue JWT::ExpiredSignature, JWT::DecodeError => e
|
43
43
|
# flash[:notice] = 'You are not logged in, or you have been logged out.'
|
44
44
|
# puts! 'You are not logged in, or you have been logged out.'
|
45
|
-
@current_user = User.new
|
45
|
+
@current_user = User.new({ profile: Ish::UserProfile.new })
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require_dependency "ishapi/application_controller"
|
2
2
|
|
3
3
|
module Ishapi
|
4
|
-
class CitiesController <
|
4
|
+
class CitiesController < Ishapi::ApplicationController
|
5
5
|
protect_from_forgery :prepend => true, :with => :exception
|
6
6
|
layout :false
|
7
|
-
|
7
|
+
|
8
8
|
check_authorization
|
9
9
|
skip_before_action :verify_authenticity_token
|
10
10
|
before_action :set_current_ability
|
@@ -4,6 +4,8 @@ module Ishapi
|
|
4
4
|
|
5
5
|
before_action :check_profile, only: %i| create2 unlock |
|
6
6
|
|
7
|
+
# alphabetized : )
|
8
|
+
|
7
9
|
##
|
8
10
|
## this is for invoices on wasya.co, isn't it?
|
9
11
|
## 20200712
|
@@ -41,14 +43,16 @@ module Ishapi
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
## This is for guyd _vp_
|
46
|
+
## This is for guyd _vp_ 2020-07-21
|
47
|
+
## It's been a while! _vp_ 2022-03-01
|
45
48
|
def create2
|
46
49
|
authorize! :create, ::Ish::Payment
|
50
|
+
current_user.profile.update_attributes({ is_purchasing: true })
|
47
51
|
|
48
52
|
begin
|
49
53
|
amount_cents = 503 # @TODO: change
|
50
54
|
|
51
|
-
::Stripe.api_key = STRIPE_SK
|
55
|
+
::Stripe.api_key = ::STRIPE_SK
|
52
56
|
intent = Stripe::PaymentIntent.create({
|
53
57
|
amount: amount_cents,
|
54
58
|
currency: 'usd',
|
@@ -57,18 +61,20 @@ module Ishapi
|
|
57
61
|
|
58
62
|
payment = Ish::Payment.create!(
|
59
63
|
client_secret: intent.client_secret,
|
60
|
-
email:
|
64
|
+
email: current_user.email,
|
61
65
|
payment_intent_id: intent.id,
|
62
|
-
profile_id:
|
66
|
+
profile_id: current_user.profile.id )
|
63
67
|
|
64
68
|
render json: { client_secret: intent.client_secret }
|
65
69
|
rescue Mongoid::Errors::DocumentNotFound => e
|
66
|
-
puts! e, '
|
70
|
+
puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
|
67
71
|
render :status => 404, :json => e
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
75
|
+
##
|
71
76
|
## webhook
|
77
|
+
##
|
72
78
|
def stripe_confirm
|
73
79
|
authorize! :open_permission, ::Ishapi
|
74
80
|
payload = request.body.read
|
@@ -76,7 +82,7 @@ module Ishapi
|
|
76
82
|
begin
|
77
83
|
event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
|
78
84
|
rescue StandardError => e
|
79
|
-
puts! e, '
|
85
|
+
puts! e, 'could not #stripe_confirm'
|
80
86
|
render status: 400, json: { status: :not_ok }
|
81
87
|
return
|
82
88
|
end
|
@@ -85,8 +91,11 @@ module Ishapi
|
|
85
91
|
|
86
92
|
payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
|
87
93
|
if payment && payment_intent['status'] == 'succeeded'
|
94
|
+
|
88
95
|
payment.update_attributes( status: :confirmed )
|
89
|
-
|
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
|
90
99
|
end
|
91
100
|
|
92
101
|
render status: 200, json: { status: :ok }
|
@@ -96,18 +105,18 @@ module Ishapi
|
|
96
105
|
authorize! :unlock, ::Ish::Payment
|
97
106
|
item = Object::const_get(params['kind']).find params['id']
|
98
107
|
|
99
|
-
puts! params, 'unlocking...'
|
100
|
-
|
101
108
|
existing = Purchase.where( user_profile: @current_user.profile, item: item ).first
|
102
109
|
if existing
|
103
110
|
render status: 200, json: { status: :ok, message: 'already purchased' }
|
104
111
|
return
|
105
112
|
end
|
106
113
|
|
107
|
-
@current_user.profile.
|
114
|
+
@current_user.profile.inc( n_unlocks: -item.premium_tier )
|
115
|
+
|
108
116
|
purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_user.profile, )
|
109
117
|
|
110
|
-
|
118
|
+
@profile = @current_user.profile
|
119
|
+
render 'ishapi/users/account'
|
111
120
|
end
|
112
121
|
|
113
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 }
|
@@ -25,6 +39,7 @@ module Ishapi
|
|
25
39
|
|
26
40
|
def login
|
27
41
|
@current_user = User.where( email: params[:email] ).first
|
42
|
+
|
28
43
|
if !@current_user
|
29
44
|
render json: { status: :not_ok }, status: 401
|
30
45
|
return
|
@@ -35,15 +50,6 @@ module Ishapi
|
|
35
50
|
# send the jwt to client
|
36
51
|
@jwt_token = encode(user_id: @current_user.id.to_s)
|
37
52
|
@profile = @current_user.profile
|
38
|
-
|
39
|
-
=begin
|
40
|
-
render json: {
|
41
|
-
email: @current_user.email,
|
42
|
-
jwt_token: @jwt_token,
|
43
|
-
n_unlocks: @current_user.profile.n_unlocks,
|
44
|
-
}
|
45
|
-
=end
|
46
|
-
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
@@ -15,7 +15,7 @@ json.cache! this_key do
|
|
15
15
|
json.description @map.description
|
16
16
|
json.w @map.w
|
17
17
|
json.h @map.h
|
18
|
-
json.img_path @map.image.image.url(:original)
|
18
|
+
json.img_path @map.image ? @map.image.image.url(:original) : image_missing
|
19
19
|
json.updated_at @map.updated_at
|
20
20
|
json.rated @map.rated
|
21
21
|
|
@@ -32,7 +32,7 @@ json.cache! this_key do
|
|
32
32
|
json.partial! 'ishapi/markers/index', markers: @markers
|
33
33
|
else
|
34
34
|
## I removed json parsing from here! _vp_ 2021-10-14
|
35
|
-
## I added json parsing here
|
35
|
+
## I added json parsing here, and is seems right. _vp_ 2021-10-19
|
36
36
|
json.config JSON.parse @map.config
|
37
37
|
json.labels JSON.parse @map.labels
|
38
38
|
json.partial! 'ishapi/markers/index', markers: @markers
|
@@ -12,9 +12,22 @@ json.markers do
|
|
12
12
|
json.h marker.h
|
13
13
|
json.centerOffsetX marker.centerOffsetX
|
14
14
|
json.centerOffsetY marker.centerOffsetY
|
15
|
-
json.img_path marker.image.image.url(:original)
|
16
|
-
json.title_img_path marker.title_image.image.url(:thumb)
|
15
|
+
json.img_path marker.image ? marker.image.image.url(:original) : image_missing
|
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
|
+
|
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
|
+
|
19
32
|
end
|
20
33
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
# ishapi / newsitems / _index
|
3
3
|
#
|
4
4
|
|
5
|
-
puts! newsitems, 'newsitems idx'
|
6
|
-
|
7
5
|
json.n_newsitems newsitems.count
|
8
6
|
json.newsitems do
|
9
7
|
json.array! newsitems do |item|
|
@@ -41,7 +39,8 @@ json.newsitems do
|
|
41
39
|
json.id item.report_id.to_s
|
42
40
|
json.item_type item.report.class.name
|
43
41
|
json.name item.report.name
|
44
|
-
json.reportname item.report.slug
|
42
|
+
json.reportname item.report.slug # @TODO: @deprecated, remove
|
43
|
+
json.slug item.report.slug
|
45
44
|
json.subhead item.report.subhead
|
46
45
|
json.username item.report.user_profile.name if item.report.user_profile
|
47
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,16 +1,15 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
json.id @profile.id.to_s
|
3
3
|
json.name @profile.name
|
4
|
-
json.username @profile.username
|
5
4
|
json.email @profile.email
|
6
5
|
json.profile_photo_url @profile.profile_photo.photo.url( :thumb ) if @profile.profile_photo
|
7
6
|
|
8
|
-
json.n_reports
|
9
|
-
json.n_galleries
|
10
|
-
json.n_videos
|
11
|
-
json.n_stars
|
12
|
-
json.n_unlocks
|
13
|
-
|
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
|
14
13
|
if @profile.current_city
|
15
14
|
json.current_city @profile.current_city
|
16
15
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
json.partial! 'account'
|
2
|
+
json.partial! 'ishapi/users/account'
|
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.
|
4
|
+
version: 0.1.8.173
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -268,18 +268,15 @@ 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
|
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
|
280
278
|
- app/controllers/ishapi/videos_controller.rb
|
281
279
|
- app/helpers/ishapi/application_helper.rb
|
282
|
-
- app/helpers/ishapi/articles_helper.rb
|
283
280
|
- app/jobs/ishapi/application_job.rb
|
284
281
|
- app/mailers/ishapi/application_mailer.rb
|
285
282
|
- app/models/ishapi/ability.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
|