effective_products 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/effective/{ring_payments_controller.rb → ring_wizards_controller.rb} +4 -4
  3. data/app/datatables/admin/effective_rings_datatable.rb +4 -5
  4. data/app/datatables/{effective_ring_payments_datatable.rb → effective_ring_wizards_datatable.rb} +5 -5
  5. data/app/models/concerns/{effective_products_ring_payment.rb → effective_products_ring_wizard.rb} +7 -7
  6. data/app/models/effective/ring.rb +3 -13
  7. data/app/models/effective/ring_wizard.rb +7 -0
  8. data/app/views/admin/rings/_ring.html.haml +23 -15
  9. data/app/views/effective/{ring_payments → ring_wizards}/_content.html.haml +0 -0
  10. data/app/views/effective/ring_wizards/_dashboard.html.haml +27 -0
  11. data/app/views/effective/{ring_payments → ring_wizards}/_layout.html.haml +0 -0
  12. data/app/views/effective/ring_wizards/_orders.html.haml +4 -0
  13. data/app/views/effective/ring_wizards/_ring.html.haml +33 -0
  14. data/app/views/effective/ring_wizards/_ring_fields.html.haml +57 -0
  15. data/app/views/effective/ring_wizards/_ring_wizard.html.haml +8 -0
  16. data/app/views/effective/ring_wizards/_summary.html.haml +31 -0
  17. data/app/views/effective/{ring_payments → ring_wizards}/billing.html.haml +1 -1
  18. data/app/views/effective/{ring_payments → ring_wizards}/checkout.html.haml +1 -1
  19. data/app/views/effective/{ring_payments → ring_wizards}/ring.html.haml +4 -4
  20. data/app/views/effective/{ring_payments → ring_wizards}/start.html.haml +1 -1
  21. data/app/views/effective/{ring_payments → ring_wizards}/submitted.html.haml +3 -3
  22. data/app/views/effective/{ring_payments → ring_wizards}/summary.html.haml +2 -2
  23. data/config/effective_products.rb +4 -4
  24. data/config/routes.rb +3 -3
  25. data/db/migrate/01_create_effective_products.rb.erb +49 -1
  26. data/lib/effective_products/engine.rb +1 -1
  27. data/lib/effective_products/version.rb +1 -1
  28. data/lib/effective_products.rb +6 -6
  29. metadata +20 -20
  30. data/app/models/effective/ring_payment.rb +0 -7
  31. data/app/views/effective/ring_payments/_dashboard.html.haml +0 -27
  32. data/app/views/effective/ring_payments/_orders.html.haml +0 -4
  33. data/app/views/effective/ring_payments/_ring.html.haml +0 -29
  34. data/app/views/effective/ring_payments/_ring_fields.html.haml +0 -4
  35. data/app/views/effective/ring_payments/_ring_payment.html.haml +0 -8
  36. data/app/views/effective/ring_payments/_summary.html.haml +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2992b6b0b12c9492acc501695ca38ffd7a8bd12afbd3c428eaf7c2be16f62cfb
4
- data.tar.gz: c40613e452d37c8b98617a7d13274b5c5968a7b4ea235a1581938826cfd447fa
3
+ metadata.gz: dd6de56034ed84b15b02ab52785db58b37b0839e67a0db8cf31b77da8f4db148
4
+ data.tar.gz: e7a59c34d1c681a582c7c7c510ad9cc8c8f911e7bfbe339864678bca3f4db4d7
5
5
  SHA512:
6
- metadata.gz: 8528fc8d11c0e4d71d635e6a05afb2e455425a35439637638b5d074da5538e2e0fa7e68b28e569c71c9fc918acd2665f89595b519df7a15dbd0d36a3b69dd274
7
- data.tar.gz: 6cf09696ebbe1d0e9b534c128130647b2c73d9599d9961b082d0f7d96cc40f7a89b206ee6f8e54f969ce4678cdff3cf273ed5a380791f4733aa7bdc8e70a1987
6
+ metadata.gz: 4383a40c636b788b989b22a8dedbc8d7afac6be72313ec737d3fe3ea1457365054194f99739651e3d61cacfa5a412e3aaa0d7068c39bfa3d41819446a226119f
7
+ data.tar.gz: b33a258e854dfdd4211edfb7143105d1c6af606cd8274886c548e65e414919a0d41e651cbd07e8399e497e2b06e9137f695cc053e43acf4509b663b01149f1de
@@ -1,10 +1,10 @@
1
1
  module Effective
2
- class RingPaymentsController < ApplicationController
2
+ class RingWizardsController < ApplicationController
3
3
  before_action(:authenticate_user!) if defined?(Devise)
4
4
 
5
5
  include Effective::WizardController
6
6
 
7
- resource_scope -> { EffectiveProducts.RingPayment.deep.where(owner: current_user) }
7
+ resource_scope -> { EffectiveProducts.RingWizard.deep.where(owner: current_user) }
8
8
 
9
9
  # Allow only 1 in-progress application at a time
10
10
  before_action(only: [:new, :show], unless: -> { resource&.done? }) do
@@ -12,7 +12,7 @@ module Effective
12
12
 
13
13
  if existing.present?
14
14
  flash[:success] = "You have been redirected to your existing in progress payment"
15
- redirect_to effective_products.ring_payment_build_path(existing, existing.next_step)
15
+ redirect_to effective_products.ring_wizard_build_path(existing, existing.next_step)
16
16
  end
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module Effective
23
23
  private
24
24
 
25
25
  def permitted_params
26
- model = (params.key?(:effective_ring_payment) ? :effective_ring_payment : :ring_payment)
26
+ model = (params.key?(:effective_ring_wizard) ? :effective_ring_wizard : :ring_wizard)
27
27
  params.require(model).permit!.except(:status, :status_steps, :wizard_steps, :submitted_at)
28
28
  end
29
29
 
@@ -16,11 +16,10 @@ module Admin
16
16
  col :created_at, as: :date
17
17
  col :owner, search: :string
18
18
 
19
- col :first_name
20
- col :last_name
21
-
22
- col :email
23
- col :phone
19
+ col(:first_name) { |ring| ring.owner.first_name }
20
+ col(:last_name) { |ring| ring.owner.last_name }
21
+ col(:email) { |ring| ring.owner.email }
22
+ col(:phone) { |ring| ring.owner.phone }
24
23
 
25
24
  col :member_number, label: 'Member #' do |ring|
26
25
  ring.owner.try(:membership).try(:number)
@@ -1,5 +1,5 @@
1
1
  # Dashboard Ring Payments
2
- class EffectiveRingPaymentsDatatable < Effective::Datatable
2
+ class EffectiveRingWizardsDatatable < Effective::Datatable
3
3
  datatable do
4
4
  order :created_at
5
5
 
@@ -20,17 +20,17 @@ class EffectiveRingPaymentsDatatable < Effective::Datatable
20
20
 
21
21
  actions_col(actions: []) do |resource|
22
22
  if resource.draft?
23
- dropdown_link_to('Continue', effective_products.ring_payment_build_path(resource, reource.next_step), 'data-turbolinks' => false)
24
- dropdown_link_to('Delete', effective_products.ring_payment_path(resource), 'data-confirm': "Really delete #{resource}?", 'data-method': :delete)
23
+ dropdown_link_to('Continue', effective_products.ring_wizard_build_path(resource, reource.next_step), 'data-turbolinks' => false)
24
+ dropdown_link_to('Delete', effective_products.ring_wizard_path(resource), 'data-confirm': "Really delete #{resource}?", 'data-method': :delete)
25
25
  else
26
- dropdown_link_to('Show', effective_products.ring_payment_path(resource))
26
+ dropdown_link_to('Show', effective_products.ring_wizard_path(resource))
27
27
  end
28
28
  end
29
29
 
30
30
  end
31
31
 
32
32
  collection do
33
- EffectiveProducts.RingPayment.deep.done.where(owner: current_user)
33
+ EffectiveProducts.RingWizard.deep.done.where(owner: current_user)
34
34
  end
35
35
 
36
36
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # EffectiveProductsRingPayment
3
+ # EffectiveProductsRingWizard
4
4
  #
5
- # Mark your owner model with effective_products_ring_payment to get all the includes
5
+ # Mark your owner model with effective_products_ring_wizard to get all the includes
6
6
 
7
- module EffectiveProductsRingPayment
7
+ module EffectiveProductsRingWizard
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  module Base
11
- def effective_products_ring_payment
12
- include ::EffectiveProductsRingPayment
11
+ def effective_products_ring_wizard
12
+ include ::EffectiveProductsRingWizard
13
13
  end
14
14
  end
15
15
 
16
16
  module ClassMethods
17
- def effective_products_ring_payment?; true; end
17
+ def effective_products_ring_wizard?; true; end
18
18
 
19
19
  def all_wizard_steps
20
20
  const_get(:WIZARD_STEPS).keys
@@ -52,7 +52,7 @@ module EffectiveProductsRingPayment
52
52
  accepts_nested_attributes_for :owner
53
53
 
54
54
  # Effective Namespace
55
- has_many :rings, -> { order(:id) }, class_name: 'Effective::Ring', inverse_of: :ring_payment, dependent: :destroy
55
+ has_many :rings, -> { order(:id) }, class_name: 'Effective::Ring', inverse_of: :ring_wizard, dependent: :destroy
56
56
  accepts_nested_attributes_for :rings, reject_if: :all_blank, allow_destroy: true
57
57
 
58
58
  has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order', dependent: :nullify
@@ -14,15 +14,10 @@ module Effective
14
14
  # This ring is charged to an owner
15
15
  belongs_to :owner, polymorphic: true
16
16
 
17
- # Through the ring_payment
18
- belongs_to :ring_payment, polymorphic: true, optional: true
17
+ # Through the ring_wizard
18
+ belongs_to :ring_wizard, polymorphic: true, optional: true
19
19
 
20
20
  effective_resource do
21
- first_name :string
22
- last_name :string
23
- phone :string
24
- email :string
25
-
26
21
  size :integer
27
22
  metal :string
28
23
 
@@ -40,11 +35,6 @@ module Effective
40
35
  scope :ready_to_issue, -> { purchased.where(issued_at: nil) }
41
36
  scope :issued, -> { where.not(issued_at: nil) }
42
37
 
43
- validates :first_name, presence: true
44
- validates :last_name, presence: true
45
- validates :phone, presence: true
46
- validates :email, presence: true, email: true
47
-
48
38
  validates :metal, presence: true, inclusion: { in: METALS }
49
39
 
50
40
  validates :size, presence: true
@@ -65,7 +55,7 @@ module Effective
65
55
 
66
56
  # This is the Admin Save and Mark Paid action
67
57
  def mark_paid!
68
- raise('expected a blank ring payment') if ring_payment.present?
58
+ raise('expected a blank ring payment') if ring_wizard.present?
69
59
 
70
60
  save!
71
61
 
@@ -0,0 +1,7 @@
1
+ module Effective
2
+ class RingWizard < ActiveRecord::Base
3
+ self.table_name = EffectiveProducts.ring_wizards_table_name.to_s
4
+
5
+ effective_products_ring_wizard
6
+ end
7
+ end
@@ -11,30 +11,38 @@
11
11
  %td
12
12
  - if ring.purchased_order.present?
13
13
  = link_to(ring.purchased_order, effective_orders.admin_order_path(ring.purchased_order))
14
+
14
15
  %tr
15
- %th First Name
16
- %td= ring.first_name
17
- %tr
18
- %th Last Name
19
- %td= ring.last_name
20
- %tr
21
- %th Phone
22
- %td= ring.phone
23
- %tr
24
- %th Email
25
- %td= ring.email
26
- %tr
27
- %th Member Number
28
- %td= ring.owner.try(:membership).try(:number) || '-'
16
+ %th Contact
17
+ %td
18
+ - owner = ring.owner
19
+
20
+ = owner.to_s
21
+
22
+ - if owner.try(:email).present?
23
+ %br
24
+ = mail_to(owner.email)
25
+
26
+ - if owner.try(:phone).present?
27
+ %br
28
+ = owner.phone
29
+
30
+ - if owner.try(:membership).try(:number).present?
31
+ %br
32
+ Member Number #{owner.membership.number}
33
+
29
34
  %tr
30
35
  %th Address
31
36
  %td= ring.shipping_address.to_html
37
+
32
38
  %tr
33
39
  %th Size
34
40
  %td= ring.size
41
+
35
42
  %tr
36
43
  %th Metal
37
44
  %td= ring.metal
45
+
38
46
  %tr
39
47
  %th Issued At
40
- %td= ring.issued_at
48
+ %td= ring.issued_at&.strftime('%F') || 'Not Issued'
@@ -0,0 +1,27 @@
1
+ -# In progress payments
2
+ - existing = EffectiveProducts.RingWizard.in_progress.for(current_user).first
3
+ - datatable = EffectiveResources.best('EffectiveRingWizardsDatatable').new(self, namespace: :effective)
4
+
5
+ - if existing.present?
6
+ %h2 In Progress Ring Payments
7
+
8
+ %p Your payment for Professional Ring is incomplete
9
+
10
+ %p
11
+ Please
12
+ = link_to("Continue payment for #{existing}", effective_products.ring_wizard_build_path(existing, existing.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
13
+ or you can
14
+ = link_to('Abandon registration', effective_products.ring_wizard_path(existing), 'data-confirm': "Really delete #{existing}?", 'data-method': :delete, class: 'btn btn-danger')
15
+ to start over.
16
+
17
+ %hr
18
+
19
+ %h2 Ring Payments
20
+
21
+ - if datatable.present?
22
+ = render_simple_datatable(datatable)
23
+ - else
24
+ %p You have no past ring payments. When you do, we'll show them here.
25
+
26
+ - if existing.blank?
27
+ %p= link_to 'Order a Professional Ring', effective_products.new_ring_wizard_path, class: 'btn btn-primary'
@@ -0,0 +1,4 @@
1
+ - if ring_wizard.submit_order&.purchased?
2
+ .card.mb-4
3
+ .card-body
4
+ = render(ring_wizard.submit_order)
@@ -0,0 +1,33 @@
1
+ = card('Ring') do
2
+ - ring = ring_wizard.ring
3
+ - owner = ring_wizard.owner
4
+
5
+ %table.table.table-sm
6
+ %tbody
7
+ %tr
8
+ %th Owner
9
+ %td
10
+ = owner.to_s
11
+ - if owner.try(:email).present?
12
+ %br
13
+ = mail_to(owner.email)
14
+
15
+ - if owner.try(:phone).present?
16
+ %br
17
+ = owner.phone
18
+
19
+ - if owner.try(:membership).try(:number).present?
20
+ %br
21
+ Member Number #{owner.membership.number}
22
+
23
+ %tr
24
+ %th Address
25
+ %td= ring.shipping_address.to_html
26
+
27
+ %tr
28
+ %th Metal
29
+ %td= ring.metal
30
+
31
+ %tr
32
+ %th Size
33
+ %td Size #{ring.size}
@@ -0,0 +1,57 @@
1
+
2
+ %h2 Member Information
3
+
4
+ - owner = f.object.owner
5
+
6
+ %p
7
+ = owner.to_s
8
+
9
+ - if owner.try(:email).present?
10
+ %br
11
+ = mail_to(owner.email)
12
+
13
+ - if owner.try(:phone).present?
14
+ %br
15
+ = owner.phone
16
+
17
+ - if owner.try(:membership).try(:number).present?
18
+ %br
19
+ Member Number #{owner.membership.number}
20
+
21
+ %h2 Ring Information
22
+ %p
23
+ The 14k Yellow Gold and Sterling Silver rings will have the association's letters as well as your membership number engraved inside the band.
24
+ Titanium rings do not come engraved.
25
+
26
+ %p Please choose your desired metal and ring size:
27
+
28
+ %table.table
29
+ %thead
30
+ %th Ring Size
31
+ %th Composition
32
+ %th.order_price Cost
33
+ %tbody
34
+ %tr
35
+ %td 3-8
36
+ %td 14k Yellow Gold
37
+ %td.order_price $425.00 + GST
38
+ %tr
39
+ %td 3-8
40
+ %td Sterling Silver
41
+ %td.order_price $175.00 + GST
42
+ %tr
43
+ %td 3-13
44
+ %td Titanium
45
+ %td.order_price $50.00 + GST
46
+
47
+ %ul
48
+ %li 14k Yellow Gold and Sterling Silver rings are available in sizes 3 - 8.
49
+ %li Titanium rings are available in sizes 3 - 13.
50
+
51
+ %p Please select a ring metal and size:
52
+
53
+ = f.select :metal, Effective::Ring::METALS
54
+ = f.select :size, Effective::Ring::TITANIUM_SIZES
55
+
56
+ %h2 Shipping Information
57
+ = effective_address_fields(f, :shipping)
@@ -0,0 +1,8 @@
1
+ .effective-ring-payment
2
+ - blacklist = ring_wizard.class.required_wizard_steps + [:summary]
3
+ - steps = ring_wizard.required_steps - blacklist
4
+
5
+ = render "effective/ring_wizards/summary", ring_wizard: ring_wizard
6
+
7
+ - steps.select { |step| ring_wizard.has_completed_step?(step) }.each do |partial|
8
+ = render "effective/ring_wizards/#{partial}", ring_wizard: ring_wizard, step: partial
@@ -0,0 +1,31 @@
1
+ = card('Ring Payment') do
2
+ - ring = ring_wizard.ring
3
+
4
+ %table.table.table-sm
5
+ %tbody
6
+ - if request.path.start_with?('/admin')
7
+ %tr
8
+ %th Owner
9
+ %td
10
+ - url = (polymorphic_admin_path(ring_wizard.owner) rescue "/admin/users/#{ring_wizard.owner.to_param}/edit")
11
+ = link_to(ring_wizard.owner, url)
12
+ - else
13
+ %tr
14
+ %th Owner
15
+ %td= ring_wizard.owner
16
+
17
+ - if ring_wizard.orders.present?
18
+ %tr
19
+ %th Order
20
+ %td
21
+ - ring_wizard.orders.each do |order|
22
+ = link_to(order, effective_orders.order_path(order))
23
+
24
+ - if ring_wizard.was_submitted?
25
+ %tr
26
+ %th Submitted
27
+ %td= ring_wizard.submitted_at.strftime('%F')
28
+
29
+ %tr
30
+ %th Issued
31
+ %td= ring.issued_at&.strftime('%F') || 'Not Issued'
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
4
  - raise('expected owner to respond to billing_address') unless resource.owner.respond_to?(:billing_address)
5
5
 
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
4
  .card
5
5
  .card-body
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
4
  .card
5
5
  .card-body
@@ -7,12 +7,12 @@
7
7
  = f.hidden_field :id
8
8
 
9
9
  = f.fields_for :rings, (f.object.ring || f.object.build_ring) do |fr|
10
- = fr.hidden_field :ring_payment_id
11
- = fr.hidden_field :ring_payment_type
10
+ = fr.hidden_field :ring_wizard_id
11
+ = fr.hidden_field :ring_wizard_type
12
12
 
13
13
  = fr.hidden_field :owner_id
14
14
  = fr.hidden_field :owner_type
15
15
 
16
- = render('effective/ring_payments/ring_fields', f: fr)
16
+ = render('effective/ring_wizards/ring_fields', f: fr)
17
17
 
18
18
  = f.save 'Save and Continue'
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
4
  .card
5
5
  .card-body
@@ -1,5 +1,5 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
4
  - raise('expected a submitted resource') unless resource.was_submitted?
5
5
  - raise('expected a purchased resource submit_order') unless resource.submit_order&.purchased?
@@ -9,7 +9,7 @@
9
9
 
10
10
  = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary mb-4'
11
11
 
12
- = render 'effective/ring_payments/ring_payment', ring_payment: resource
13
- = render 'effective/ring_payments/orders', ring_payment: resource
12
+ = render 'effective/ring_wizards/ring_wizard', ring_wizard: resource
13
+ = render 'effective/ring_wizards/orders', ring_wizard: resource
14
14
 
15
15
  = link_to 'Return to Dashboard', root_path, class: 'btn btn-lg btn-primary'
@@ -1,7 +1,7 @@
1
1
  = render 'layout' do
2
- = render 'effective/ring_payments/content', resource: resource
2
+ = render 'effective/ring_wizards/content', resource: resource
3
3
 
4
- = render 'effective/ring_payments/ring_payment', ring_payment: resource
4
+ = render 'effective/ring_wizards/ring_wizard', ring_wizard: resource
5
5
 
6
6
  = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
7
7
  = f.hidden_field :id
@@ -1,16 +1,16 @@
1
1
  EffectiveProducts.setup do |config|
2
2
  config.rings_table_name = :rings
3
- config.ring_payments_table_name = :ring_payments
3
+ config.ring_wizards_table_name = :ring_wizards
4
4
  config.stamps_table_name = :stamps
5
- config.stamp_payments_table_name = :stamp_payments
5
+ config.stamp_wizards_table_name = :stamp_wizards
6
6
 
7
7
  # Layout Settings
8
8
  # Configure the Layout per controller, or all at once
9
9
  # config.layout = { application: 'application', admin: 'admin' }
10
10
 
11
11
  # Payment Wizard Settings
12
- # config.ring_payments_class_name = 'Effective::RingPayment'
13
- # config.stamp_payments_class_name = 'Effective::StampPayment'
12
+ # config.ring_wizards_class_name = 'Effective::RingWizard'
13
+ # config.stamp_wizards_class_name = 'Effective::StampWizard'
14
14
 
15
15
  # Use effective roles. Not sure what this does yet.
16
16
  config.use_effective_roles = true
data/config/routes.rb CHANGED
@@ -7,13 +7,13 @@ end
7
7
  EffectiveProducts::Engine.routes.draw do
8
8
  # Public routes
9
9
  scope module: 'effective' do
10
- resources :ring_payments, only: [:new, :show, :destroy] do
11
- resources :build, controller: :ring_payments, only: [:show, :update]
10
+ resources :ring_wizards, name: :ring_wizard, only: [:new, :show, :destroy] do
11
+ resources :build, controller: :ring_wizards, only: [:show, :update]
12
12
  end
13
13
  end
14
14
 
15
15
  namespace :admin do
16
- resources :ring_payments, except: [:new, :create, :show]
16
+ resources :ring_wizards, except: [:new, :create, :show]
17
17
 
18
18
  resources :rings, only: [:index, :show] do
19
19
  post :mark_as_issued, on: :member
@@ -1,4 +1,52 @@
1
- class CreateEffectiveProducts < ActiveRecord::Migration[6.0]
1
+ class CreateEffectiveProducts < ActiveRecord::Migration[6.1]
2
2
  def change
3
+ create_table :rings do |t|
4
+ t.integer :owner_id
5
+ t.string :owner_type
6
+
7
+ t.integer :ring_wizard_id
8
+ t.string :ring_wizard_type
9
+
10
+ t.integer :size
11
+ t.string :metal
12
+
13
+ t.datetime :issued_at
14
+
15
+ # Acts as purchasable
16
+ t.integer :purchased_order_id
17
+ t.integer :price
18
+ t.boolean :tax_exempt, default: false
19
+ t.string :qb_item_name
20
+
21
+ t.timestamps
22
+ end
23
+
24
+ create_table :ring_wizards do |t|
25
+ t.string :token
26
+
27
+ t.integer :owner_id
28
+ t.string :owner_type
29
+
30
+ t.integer :user_id
31
+ t.string :user_type
32
+
33
+ # Acts as Statused
34
+ t.string :status
35
+ t.text :status_steps
36
+
37
+ # Acts as Wizard
38
+ t.text :wizard_steps
39
+
40
+ # Dates
41
+ t.datetime :submitted_at
42
+
43
+ t.datetime :updated_at
44
+ t.datetime :created_at
45
+ end
46
+
47
+ add_index :ring_wizards, [:owner_id, :owner_type]
48
+ add_index :ring_wizards, :status
49
+ add_index :ring_wizards, :token
50
+
3
51
  end
4
52
  end
@@ -10,7 +10,7 @@ module EffectiveProducts
10
10
  # Include acts_as_addressable concern and allow any ActiveRecord object to call it
11
11
  initializer 'effective_products.active_record' do |app|
12
12
  ActiveSupport.on_load :active_record do
13
- ActiveRecord::Base.extend(EffectiveProductsRingPayment::Base)
13
+ ActiveRecord::Base.extend(EffectiveProductsRingWizard::Base)
14
14
  end
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveProducts
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -7,20 +7,20 @@ module EffectiveProducts
7
7
 
8
8
  def self.config_keys
9
9
  [
10
- :rings_table_name, :ring_payments_table_name, :ring_payment_class_name,
11
- :stamps_table_name, :stamp_payments_table_name, :stamp_payment_class_name,
10
+ :rings_table_name, :ring_wizards_table_name, :ring_wizard_class_name,
11
+ :stamps_table_name, :stamp_wizards_table_name, :stamp_wizard_class_name,
12
12
  :layout, :use_effective_roles
13
13
  ]
14
14
  end
15
15
 
16
16
  include EffectiveGem
17
17
 
18
- def self.RingPayment
19
- ring_payment_class_name&.constantize || Effective::RingPayment
18
+ def self.RingWizard
19
+ ring_wizard_class_name&.constantize || Effective::RingWizard
20
20
  end
21
21
 
22
- def self.StampPayment
23
- stamp_payment_class_name&.constantize || Effective::StampPayment
22
+ def self.StampWizard
23
+ stamp_wizard_class_name&.constantize || Effective::StampWizard
24
24
  end
25
25
 
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_products
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-27 00:00:00.000000000 Z
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -222,28 +222,28 @@ files:
222
222
  - app/assets/stylesheets/effective_products.scss
223
223
  - app/assets/stylesheets/effective_products/base.scss
224
224
  - app/controllers/admin/rings_controller.rb
225
- - app/controllers/effective/ring_payments_controller.rb
225
+ - app/controllers/effective/ring_wizards_controller.rb
226
226
  - app/datatables/admin/effective_rings_datatable.rb
227
- - app/datatables/effective_ring_payments_datatable.rb
227
+ - app/datatables/effective_ring_wizards_datatable.rb
228
228
  - app/helpers/effective_products_helper.rb
229
- - app/models/concerns/effective_products_ring_payment.rb
229
+ - app/models/concerns/effective_products_ring_wizard.rb
230
230
  - app/models/effective/ring.rb
231
- - app/models/effective/ring_payment.rb
231
+ - app/models/effective/ring_wizard.rb
232
232
  - app/views/admin/rings/_ring.html.haml
233
- - app/views/effective/ring_payments/_content.html.haml
234
- - app/views/effective/ring_payments/_dashboard.html.haml
235
- - app/views/effective/ring_payments/_layout.html.haml
236
- - app/views/effective/ring_payments/_orders.html.haml
237
- - app/views/effective/ring_payments/_ring.html.haml
238
- - app/views/effective/ring_payments/_ring_fields.html.haml
239
- - app/views/effective/ring_payments/_ring_payment.html.haml
240
- - app/views/effective/ring_payments/_summary.html.haml
241
- - app/views/effective/ring_payments/billing.html.haml
242
- - app/views/effective/ring_payments/checkout.html.haml
243
- - app/views/effective/ring_payments/ring.html.haml
244
- - app/views/effective/ring_payments/start.html.haml
245
- - app/views/effective/ring_payments/submitted.html.haml
246
- - app/views/effective/ring_payments/summary.html.haml
233
+ - app/views/effective/ring_wizards/_content.html.haml
234
+ - app/views/effective/ring_wizards/_dashboard.html.haml
235
+ - app/views/effective/ring_wizards/_layout.html.haml
236
+ - app/views/effective/ring_wizards/_orders.html.haml
237
+ - app/views/effective/ring_wizards/_ring.html.haml
238
+ - app/views/effective/ring_wizards/_ring_fields.html.haml
239
+ - app/views/effective/ring_wizards/_ring_wizard.html.haml
240
+ - app/views/effective/ring_wizards/_summary.html.haml
241
+ - app/views/effective/ring_wizards/billing.html.haml
242
+ - app/views/effective/ring_wizards/checkout.html.haml
243
+ - app/views/effective/ring_wizards/ring.html.haml
244
+ - app/views/effective/ring_wizards/start.html.haml
245
+ - app/views/effective/ring_wizards/submitted.html.haml
246
+ - app/views/effective/ring_wizards/summary.html.haml
247
247
  - app/views/effective/rings/_fields.html.haml
248
248
  - config/effective_products.rb
249
249
  - config/routes.rb
@@ -1,7 +0,0 @@
1
- module Effective
2
- class RingPayment < ActiveRecord::Base
3
- self.table_name = EffectiveProducts.ring_payments_table_name.to_s
4
-
5
- effective_products_ring_payment
6
- end
7
- end
@@ -1,27 +0,0 @@
1
- -# In progress payments
2
- - existing = EffectiveProducts.RingPayment.in_progress.for(current_user).first
3
- - datatable = EffectiveResources.best('EffectiveRingPaymentsDatatable').new(self, namespace: :effective)
4
-
5
- - if existing.present?
6
- %h2 In Progress Ring Payments
7
-
8
- %p Your payment for Professional Ring is incomplete
9
-
10
- %p
11
- Please
12
- = link_to("Continue payment for #{existing}", effective_products.ring_payment_build_path(existing, existing.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
13
- or you can
14
- = link_to('Abandon registration', effective_products.ring_payment_path(existing), 'data-confirm': "Really delete #{existing}?", 'data-method': :delete, class: 'btn btn-danger')
15
- to start over.
16
-
17
- %hr
18
-
19
- %h2 Ring Payments
20
-
21
- - if datatable.present?
22
- = render_simple_datatable(datatable)
23
- - else
24
- %p You have no past ring payments. When you do, we'll show them here.
25
-
26
- - if existing.blank?
27
- %p= link_to 'Order a Professional Ring', effective_products.new_ring_payment_path, class: 'btn btn-primary'
@@ -1,4 +0,0 @@
1
- - if ring_payment.submit_order&.purchased?
2
- .card.mb-4
3
- .card-body
4
- = render(ring_payment.submit_order)
@@ -1,29 +0,0 @@
1
- = card('Ring') do
2
- - ring = ring_payment.ring
3
-
4
- %table.table.table-sm
5
- %tbody
6
- %tr
7
- %th Contact Info
8
- %td
9
- #{ring.first_name} #{ring.last_name}
10
- %br
11
- = mail_to(ring.email)
12
- %br
13
- = ring.phone
14
-
15
- %tr
16
- %th Address
17
- %td= ring.shipping_address.to_html
18
-
19
- %tr
20
- %th Member Number
21
- %td= ring_payment.owner.membership&.number || 'None'
22
-
23
- %tr
24
- %th Metal
25
- %td= ring.metal
26
-
27
- %tr
28
- %th Size
29
- %td Size #{ring.size}
@@ -1,4 +0,0 @@
1
- = f.text_field :first_name
2
- = f.text_field :last_name
3
- = f.email_field :email
4
- = f.phone_field :phone
@@ -1,8 +0,0 @@
1
- .effective-ring-payment
2
- - blacklist = ring_payment.class.required_wizard_steps + [:summary]
3
- - steps = ring_payment.required_steps - blacklist
4
-
5
- = render "effective/ring_payments/summary", ring_payment: ring_payment
6
-
7
- - steps.select { |step| ring_payment.has_completed_step?(step) }.each do |partial|
8
- = render "effective/ring_payments/#{partial}", ring_payment: ring_payment, step: partial
@@ -1,31 +0,0 @@
1
- = card('Ring Payment') do
2
- - ring = ring_payment.ring
3
-
4
- %table.table.table-sm
5
- %tbody
6
- - if request.path.start_with?('/admin')
7
- %tr
8
- %th Ordered by
9
- %td
10
- - url = (polymorphic_admin_path(ring_payment.owner) rescue "/admin/users/#{ring_payment.owner.to_param}/edit")
11
- = link_to(ring_payment.owner, url)
12
- - else
13
- %tr
14
- %th Ordered by
15
- %td= ring_payment.owner
16
-
17
- - if ring_payment.orders.present?
18
- %tr
19
- %th Order
20
- %td
21
- - ring_payment.orders.each do |order|
22
- = link_to(order, effective_orders.order_path(order))
23
-
24
- - if ring_payment.was_submitted?
25
- %tr
26
- %th Submitted
27
- %td= ring_payment.submitted_at.strftime('%F')
28
-
29
- %tr
30
- %th Issued
31
- %td= ring.issued_at&.strftime('%F') || 'Not Issued'