ish_manager 0.1.8.503 → 0.1.8.504

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: b7465feb8b71a19de0c55e39cbf14d4016792bdcd20f5c0d10ab90397defcffb
4
- data.tar.gz: 700d28696374331c9e7c8f3b1f87e74a13392c350a81e89588a4fdb48dfbb0bd
3
+ metadata.gz: 5bf2d01a70b7522f7e27afa1e25a7ac42cc95e5e7da3c3eeef5eaf32b454bcc3
4
+ data.tar.gz: 72f5c516ce6d697ce8e036f825aa97dae89a38a8a7c4209518c454980d679dac
5
5
  SHA512:
6
- metadata.gz: 29c2cd6c9c46744212e9f23b1b4e7890bd72da84783445270284c79c3b3d1ae06b91297c26d17695325be998daf30da7865162615274fc290533f2149843f209
7
- data.tar.gz: c4350008f57978f1e09b13ebc0340b8953c01735c9a28b1d9e351b5c1e66bcc5fbf5261dd68e89b9c128c1d0260180becf271954e9664d1263cf9b935696d525
6
+ metadata.gz: 30aaaae64eb60915a5bfb9f775e2d6c00dff588414d646157bccac3d4617a2f7a6cea952185c7ae1d6f97df4ee2700d443fbd9c0266aa0d2a51fad1eea8f4fcd
7
+ data.tar.gz: e801605b0c81d7c6a0e1eaa4164e224242660a754c9ecc6982c749bf0f9314bce74a5eeb41e68f5bc434bfd9277b5eb559fdcc0ae5a86c66abf40dc73f41272a
@@ -4,6 +4,37 @@
4
4
 
5
5
  class IshManager::PricesController < IshManager::ApplicationController
6
6
 
7
+ def create
8
+ @price = Wco::Price.new params[:price].permit( :amount_cents, :interval, :product_id )
9
+ puts! @price, '@price'
10
+ authorize! :create, @price
11
+ if !params[:price][:interval].present?
12
+ @price.interval = nil
13
+ end
14
+ @product = Wco::Product.find @price.product_id
15
+ stripe_product = Stripe::Product.retrieve( @product.product_id )
16
+ price_hash = {
17
+ product: stripe_product.id,
18
+ unit_amount: @price.amount_cents,
19
+ currency: 'usd',
20
+ }
21
+ if @price.interval.present?
22
+ price_hash[:recurring] = { interval: @price.interval }
23
+ end
24
+ stripe_price = Stripe::Price.create( price_hash )
25
+ # puts! stripe_price, 'stripe_price'
26
+
27
+ flash_notice 'Created stripe price.'
28
+ @price.product = @product
29
+ @price.price_id = stripe_price[:id]
30
+ if @price.save
31
+ flash_notice @price
32
+ else
33
+ flash_alert @price
34
+ end
35
+ redirect_to controller: :products, action: :index
36
+ end
37
+
7
38
  def update
8
39
 
9
40
  # if !params[:price][:interval].present?
@@ -5,15 +5,12 @@ class IshManager::ProductsController < IshManager::ApplicationController
5
5
 
6
6
  # Alphabetized : )
7
7
 
8
+
9
+
8
10
  def create
9
11
  @product = Wco::Product.new params[:product].permit( :name )
10
- @price = Wco::Price.new params[:price].permit( :amount_cents, :interval )
11
12
  authorize! :create, @product
12
13
 
13
- if !params[:price][:interval].present?
14
- @price.interval = nil
15
- end
16
-
17
14
  stripe_product = Stripe::Product.create({ name: @product.name })
18
15
  # puts! stripe_product, 'stripe_product'
19
16
  flash_notice 'Created stripe product.'
@@ -24,26 +21,6 @@ class IshManager::ProductsController < IshManager::ApplicationController
24
21
  else
25
22
  flash_alert "Cannot create wco product: #{@product.errors.full_messages.join(', ')}."
26
23
  end
27
-
28
- price_hash = {
29
- product: stripe_product.id,
30
- unit_amount: @price.amount_cents,
31
- currency: 'usd',
32
- }
33
- if @price.interval.present?
34
- price_hash[:recurring] = { interval: @price.interval }
35
- end
36
- stripe_price = Stripe::Price.create( price_hash )
37
- # puts! stripe_price, 'stripe_price'
38
- flash_notice 'Created stripe price.'
39
- @price.product = @product
40
- @price.price_id = stripe_price[:id]
41
- if @price.save
42
- flash_notice @price
43
- else
44
- flash_alert @price
45
- end
46
-
47
24
  redirect_to action: :index
48
25
  end
49
26
 
@@ -23,8 +23,8 @@
23
23
  -# = f.select :email, options_for_select([[nil,nil]] + @leadset.employees.map { |i| [ i.email, i.email ] } )
24
24
 
25
25
  .input-row
26
- %label item
27
- = select_tag 'invoice[items][][product_id]', options_for_select( @products_list ), class: 'products'
26
+ %label item (product)
27
+ = select_tag 'invoice[items][][product_id]', options_for_select( @products_list ), class: 'products select2'
28
28
 
29
29
  %label price
30
30
  = select_tag 'invoice[items][][price_id]'
@@ -15,12 +15,11 @@
15
15
  = render 'ish_manager/leads/index', leads: @employees
16
16
  %hr
17
17
 
18
- .row
19
- .col-md-6
20
- = render 'ish_manager/serverhosts/index', serverhosts: @leadset.serverhosts
21
-
22
- .col-md-6
23
- = render 'ish_manager/appliances/index', appliances: @leadset.appliances
18
+ -# .row
19
+ -# .col-md-6
20
+ -# = render 'ish_manager/serverhosts/index', serverhosts: @leadset.serverhosts
21
+ -# .col-md-6
22
+ -# = render 'ish_manager/appliances/index', appliances: @leadset.appliances
24
23
 
25
24
  .row
26
25
  .col-md-6
@@ -0,0 +1,10 @@
1
+
2
+ - url = price.new_record? ? prices_path : price_path( price )
3
+
4
+ .products--prices-form.inline-block
5
+ = form_for price, as: :price, url: url do |f|
6
+ = hidden_field_tag 'price[product_id]', price.product_id
7
+
8
+ %label amount cents
9
+ = f.number_field :amount_cents
10
+ = f.submit '>'
@@ -8,21 +8,23 @@
8
8
  %label Name
9
9
  = text_field_tag 'product[name]'
10
10
 
11
- .form-field
12
- %label Price in cents
13
- = text_field_tag 'price[amount_cents]'
14
-
15
- .form-field
16
- %label Recurring?
17
- = select_tag 'price[interval]', options_for_select(Wco::Price::INTERVALS)
11
+ -# .form-field
12
+ -# %label Price in cents
13
+ -# = text_field_tag 'price[amount_cents]'
18
14
 
19
15
  -# .form-field
20
- -# %label Stripe product_id
21
- -# = f.text_field :product_id
16
+ -# %label Recurring?
17
+ -# = select_tag 'price[interval]', options_for_select(Wco::Price::INTERVALS)
18
+
19
+ .form-field
20
+ %label Stripe product_id
21
+ -# = f.text_field :product_id
22
+ = product.product_id
22
23
 
23
24
  -# .form-field
24
25
  -# %label Stripe price_id
25
- -# = f.text_field :price_id
26
+ -# -# = f.text_field :price_id
27
+ -# = product.price_id
26
28
 
27
29
  .actions
28
30
  = f.submit 'Submit'
@@ -20,6 +20,9 @@
20
20
  - else
21
21
  = product.name
22
22
  %ul
23
+ %li
24
+ New price:
25
+ = render 'ish_manager/prices/form', price: Wco::Price.new({ product: product[:wco_product] })
23
26
  - product[:prices].each do |price_id, price|
24
27
  %li
25
28
  %span.gray= price.id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.503
4
+ version: 0.1.8.504
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -826,6 +826,7 @@ files:
826
826
  - app/views/ish_manager/photos/new.haml
827
827
  - app/views/ish_manager/photos/show.haml
828
828
  - app/views/ish_manager/photos/without_gallery.haml
829
+ - app/views/ish_manager/prices/_form.haml
829
830
  - app/views/ish_manager/products/_form.haml
830
831
  - app/views/ish_manager/products/_index_list.haml
831
832
  - app/views/ish_manager/products/_index_table.haml