ish_manager 0.1.8.457 → 0.1.8.458
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/ish_manager/subscriptions_controller.rb +49 -25
- data/app/controllers/ish_manager/user_profiles_controller.rb +7 -0
- data/app/views/ish_manager/products/index.haml +2 -2
- data/app/views/ish_manager/subscriptions/index.haml +5 -1
- data/app/views/ish_manager/user_profiles/_form.haml +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42443ac595bb611c6e4dcd495212dea118197ce3d5cd736c4ffc13ff7672915f
|
4
|
+
data.tar.gz: 20b76203f7e205e0421a856bd832e5ae98e061552c59aeb33b76ba994663c736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a07f1df419c2fce93601e0b35f48233f414ffc2a7f18d78019afa9d875a1417e5db42ba24d96be2aea66cc05a9ce472b25b0ba98cbe9d9ca3b6d6f34960bdb
|
7
|
+
data.tar.gz: 1cf8ed0befe718c28f386243798a4465e90a44abda909794a41842b32abf13d7c2383abee35fa47f5960b62406edef4bc382942da9bdeb3601d95064cf3878a4
|
@@ -3,47 +3,69 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
3
3
|
|
4
4
|
before_action :set_lists
|
5
5
|
|
6
|
-
|
6
|
+
## Alphabetized : )
|
7
7
|
|
8
8
|
def create
|
9
|
-
authorize! :create, Wco::Subscription
|
10
9
|
@subscription = Wco::Subscription.new params[:subscription].permit!
|
11
|
-
|
10
|
+
authorize! :create, @subscription
|
11
|
+
|
12
|
+
payment_methods = Stripe::Customer.list_payment_methods( params[:subscription][:customer_id] ).data
|
13
|
+
# puts! payment_methods, 'payment_methods'
|
14
|
+
|
15
|
+
params = {
|
12
16
|
customer: params[:subscription][:customer_id],
|
17
|
+
default_payment_method: payment_methods[0][:id],
|
13
18
|
items: [
|
14
19
|
{ price: params[:subscription][:price_id] },
|
15
20
|
],
|
16
|
-
}
|
17
|
-
puts!
|
18
|
-
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
}
|
22
|
+
puts! params, 'params'
|
23
|
+
@stripe_subscription = Stripe::Subscription.create( params )
|
24
|
+
# puts! @stripe_subscription, '@stripe_subscription'
|
25
|
+
|
26
|
+
|
27
|
+
flag = @subscription.save
|
28
|
+
if flag
|
29
|
+
flash[:notice] = 'Created the subscription.'
|
30
|
+
redirect_to action: :show, id: @subscription.id
|
31
|
+
else
|
32
|
+
flash[:alert] = "Cannot create the subscription: #{@subscription.errors.full_messages.join(', ')}."
|
33
|
+
render action: :new
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
37
|
def index
|
30
38
|
authorize! :index, Wco::Subscription
|
31
39
|
|
32
|
-
@stripe_customers
|
40
|
+
@stripe_customers = Stripe::Customer.list().data
|
33
41
|
@stripe_subscriptions = Stripe::Subscription.list().data
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
@customers = {}
|
44
|
+
customer_ids = @stripe_customers.map &:id
|
45
|
+
@leadsets = Leadset.where( :customer_id.in => customer_ids )
|
46
|
+
@leadsets.each do |i|
|
47
|
+
@customers[i[:customer_id]] ||= {}
|
48
|
+
@customers[i[:customer_id]][:leadsets] ||= []
|
49
|
+
@customers[i[:customer_id]][:leadsets].push( i )
|
50
|
+
end
|
51
|
+
@profiles = Ish::UserProfile.where( :customer_id.in => customer_ids )
|
52
|
+
@profiles.each do |i|
|
53
|
+
@customers[i[:customer_id]] ||= {}
|
54
|
+
@customers[i[:customer_id]][:profiles] ||= []
|
55
|
+
@customers[i[:customer_id]][:profiles].push( i )
|
56
|
+
end
|
38
57
|
|
39
|
-
|
40
|
-
authorize! :show, Wco::Subscription
|
41
|
-
@subscription = Wco::Subscription.find params[:id]
|
58
|
+
# puts! @customers, '@customers'
|
42
59
|
end
|
43
60
|
|
44
61
|
def new
|
45
|
-
authorize! :new, Wco::Subscription
|
46
62
|
@subscription = Wco::Subscription.new
|
63
|
+
authorize! :new, @subscription
|
64
|
+
end
|
65
|
+
|
66
|
+
def show
|
67
|
+
@subscription = Wco::Subscription.find params[:id]
|
68
|
+
authorize! :show, @subscription
|
47
69
|
end
|
48
70
|
|
49
71
|
##
|
@@ -53,9 +75,11 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
|
|
53
75
|
|
54
76
|
def set_lists
|
55
77
|
super
|
56
|
-
@products_list
|
57
|
-
|
58
|
-
|
78
|
+
@products_list = Wco::Product.list
|
79
|
+
leadsets = Leadset.where( "customer_id IS NOT NULL" ).map { |i| [ "leadset // #{i.company_url}", i.customer_id ] }
|
80
|
+
profiles = ::Ish::UserProfile.where( :customer_id.ne => nil ).map { |i| [ "profile ++ #{i.email}", i.customer_id ] }
|
81
|
+
@customer_ids_list = leadsets + profiles
|
82
|
+
@price_ids_list = Wco::Product.all.map { |i| [ i.name, i.price_id ] }
|
59
83
|
end
|
60
84
|
|
61
85
|
end
|
@@ -57,6 +57,13 @@ class IshManager::UserProfilesController < IshManager::ApplicationController
|
|
57
57
|
@profile.profile_photo = photo
|
58
58
|
end
|
59
59
|
|
60
|
+
puts! params[:profile][:customer_id].present?, 'params[:profile][:customer_id].present?'
|
61
|
+
if !params[:profile][:customer_id].present? || params[:delete_customer_id]
|
62
|
+
params[:profile][:customer_id] = nil
|
63
|
+
end
|
64
|
+
|
65
|
+
puts! params[:profile], 'ze params'
|
66
|
+
|
60
67
|
flag = @profile.update_attributes params[:profile].permit!
|
61
68
|
|
62
69
|
if flag
|
@@ -28,5 +28,9 @@
|
|
28
28
|
%li plan: $#{sub[:plan][:amount].to_f/100}/#{sub[:plan][:interval]}
|
29
29
|
%li product: #{sub[:plan][:product]}
|
30
30
|
%li customer: #{sub[:customer]}
|
31
|
-
-# %li=
|
31
|
+
-# %li= @customers.inspect
|
32
|
+
- if @customers[sub[:customer]] && @customers[sub[:customer]][:leadsets]
|
33
|
+
%li leadsets: #{ @customers[sub[:customer]][:leadsets]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
|
34
|
+
- if @customers[sub[:customer]] && @customers[sub[:customer]][:profiles]
|
35
|
+
%li profiles: #{ @customers[sub[:customer]][:profiles]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
|
32
36
|
|
@@ -30,10 +30,19 @@
|
|
30
30
|
.input-field
|
31
31
|
= f.label :fb_access_token
|
32
32
|
= f.text_field :fb_access_token
|
33
|
+
|
33
34
|
.input-field
|
34
35
|
= f.label :fb_long_access_token
|
35
36
|
= f.text_field :fb_long_access_token
|
36
37
|
|
38
|
+
.input-field
|
39
|
+
= f.label :customer_id
|
40
|
+
= f.text_field :customer_id
|
41
|
+
%label [X]
|
42
|
+
= check_box_tag :delete_customer_id
|
43
|
+
|
44
|
+
|
45
|
+
|
37
46
|
= f.submit 'Save', :class => %w(button)
|
38
47
|
|
39
48
|
|