effective_orders 2.1.17 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -3
  3. data/app/controllers/admin/customers_controller.rb +1 -1
  4. data/app/controllers/admin/order_items_controller.rb +1 -1
  5. data/app/controllers/admin/orders_controller.rb +1 -1
  6. data/app/models/effective/datatables/customers.rb +27 -29
  7. data/app/models/effective/datatables/order_items.rb +75 -77
  8. data/app/models/effective/datatables/orders.rb +64 -66
  9. data/app/views/admin/customers/index.html.haml +4 -7
  10. data/app/views/admin/order_items/index.html.haml +2 -4
  11. data/app/views/admin/orders/_form.html.haml +2 -2
  12. data/app/views/admin/orders/_form_mark_as_paid.html.haml +2 -2
  13. data/app/views/admin/orders/_form_note_internal.html.haml +1 -1
  14. data/app/views/admin/orders/_order_payment_details.html.haml +1 -1
  15. data/app/views/admin/orders/index.html.haml +4 -10
  16. data/app/views/admin/orders/mark_as_paid.html.haml +1 -1
  17. data/app/views/admin/orders/new.html.haml +1 -1
  18. data/app/views/admin/orders/show.html.haml +1 -1
  19. data/app/views/effective/carts/show.html.haml +2 -2
  20. data/app/views/effective/orders/_checkout_step1.html.haml +2 -2
  21. data/app/views/effective/orders/_order_note_fields.html.haml +1 -1
  22. data/app/views/effective/orders/_order_payment_details.html.haml +1 -1
  23. data/app/views/effective/orders/_order_terms_and_conditions_fields.html.haml +1 -1
  24. data/app/views/effective/orders/_order_user_fields.html.haml +1 -1
  25. data/app/views/effective/orders/checkout_step1.html.haml +1 -1
  26. data/app/views/effective/orders/checkout_step2.html.haml +1 -1
  27. data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +1 -1
  28. data/app/views/effective/orders/declined.html.haml +1 -1
  29. data/app/views/effective/orders/index.html.haml +3 -3
  30. data/app/views/effective/orders/my_purchases.html.haml +1 -1
  31. data/app/views/effective/orders/my_sales.html.haml +1 -1
  32. data/app/views/effective/orders/purchased.html.haml +1 -1
  33. data/app/views/effective/orders/show.html.haml +1 -1
  34. data/app/views/effective/subscriptions/index.html.haml +4 -3
  35. data/app/views/effective/subscriptions/new.html.haml +1 -1
  36. data/app/views/effective/subscriptions/show.html.haml +3 -3
  37. data/config/effective_orders.rb +1 -1
  38. data/lib/effective_orders/version.rb +1 -1
  39. data/lib/generators/effective_orders/install_generator.rb +2 -2
  40. data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -5
  41. data/lib/generators/effective_orders/upgrade_from1x_generator.rb +1 -5
  42. data/lib/generators/effective_orders/upgrade_price_column_generator.rb +1 -5
  43. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cb8772c01ec2ba2e8c05602baf9bde31edc56c3
4
- data.tar.gz: 51689a4cb46017b65093206a00af973951eb7bdf
3
+ metadata.gz: 19e07ec1d07242e5f32deffbf1781c2b5581892f
4
+ data.tar.gz: 6d3288fbd94d0a03062cce8c590a89aff3e7bdb8
5
5
  SHA512:
6
- metadata.gz: 2fa6b69a7b6136ef1a4e73375d88c7129312c12585c744f3f1f6609209a023bf97cba4f6b8a918b6f0e16cf5fafc20a19e9e9137753b7b93ca1ecd5e625b83f4
7
- data.tar.gz: d4e2eff6b5909da09d95cb5452a6db1df130d92ca6a26782b83cf4ab4fbe99ef937f05fa55e3833c07e43a25b89d0a3ce838c47f0f0caa963af8c76dae6b8e68
6
+ metadata.gz: 9a6e170de89d924e91182974aab8c24927803eb5ab11600d5ecbf2c31a447ed41b52863abfed0db5a923a439ff593b3df5997338bdfa6959e7b9635e949e4b8d
7
+ data.tar.gz: 8ee0b8ad9be88093640859e682bf1ece228e291192ff3607cb0df8e12a6f3653474f6c021558b239967f02096da5f5e4aba485eafb436784c96b248bfd308d68
data/README.md CHANGED
@@ -1114,9 +1114,6 @@ end
1114
1114
 
1115
1115
  MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
1116
1116
 
1117
- Code and Effect is the product arm of [AgileStyle](http://www.agilestyle.com/), an Edmonton-based shop that specializes in building custom web applications with Ruby on Rails.
1118
-
1119
-
1120
1117
  ## Testing
1121
1118
 
1122
1119
  Run tests by:
@@ -5,7 +5,7 @@ module Admin
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_customers] : EffectiveOrders.layout)
6
6
 
7
7
  def index
8
- @datatable = Effective::Datatables::Customers.new() if defined?(EffectiveDatatables)
8
+ @datatable = Effective::Datatables::Customers.new()
9
9
  @page_title = 'Customers'
10
10
 
11
11
  EffectiveOrders.authorized?(self, :admin, :effective_orders)
@@ -5,7 +5,7 @@ module Admin
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
6
6
 
7
7
  def index
8
- @datatable = Effective::Datatables::OrderItems.new() if defined?(EffectiveDatatables)
8
+ @datatable = Effective::Datatables::OrderItems.new()
9
9
  @page_title = 'Order Items'
10
10
 
11
11
  EffectiveOrders.authorized?(self, :admin, :effective_orders)
@@ -5,7 +5,7 @@ module Admin
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
6
6
 
7
7
  def index
8
- @datatable = Effective::Datatables::Orders.new() if defined?(EffectiveDatatables)
8
+ @datatable = Effective::Datatables::Orders.new()
9
9
  @page_title = 'Orders'
10
10
 
11
11
  authorize_effective_order!
@@ -1,39 +1,37 @@
1
- if defined?(EffectiveDatatables)
2
- module Effective
3
- module Datatables
4
- class Customers < Effective::Datatable
5
- datatable do
6
- default_order :email, :asc
1
+ module Effective
2
+ module Datatables
3
+ class Customers < Effective::Datatable
4
+ datatable do
5
+ default_order :email, :asc
7
6
 
8
- table_column :id, visible: false
9
- table_column(:email, column: 'users.email') { |user| mail_to user.email, user.email }
7
+ table_column :id, visible: false
8
+ table_column(:email, column: 'users.email') { |user| mail_to user.email, user.email }
10
9
 
11
- if EffectiveOrders.stripe_enabled
12
- table_column :stripe_customer_id
13
- table_column :stripe_active_card
14
- end
10
+ if EffectiveOrders.stripe_enabled
11
+ table_column :stripe_customer_id
12
+ table_column :stripe_active_card
13
+ end
15
14
 
16
- if EffectiveOrders.stripe_connect_enabled
17
- table_column :stripe_connect_access_token
18
- end
15
+ if EffectiveOrders.stripe_connect_enabled
16
+ table_column :stripe_connect_access_token
17
+ end
19
18
 
20
- table_column :subscription_types, column: 'subscription_types'
19
+ table_column :subscription_types, column: 'subscription_types'
21
20
 
22
- actions_column partial: 'admin/customers/actions'
23
- end
21
+ actions_column partial: 'admin/customers/actions'
22
+ end
24
23
 
25
- def collection
26
- Effective::Customer.customers.uniq
27
- .joins(:user, :subscriptions)
28
- .select('customers.*, users.email AS email')
29
- .select("array_to_string(array(#{Effective::Subscription.purchased.select('subscriptions.stripe_plan_id').where('subscriptions.customer_id = customers.id').to_sql}), ' ,') AS subscription_types")
30
- .group('customers.id, subscriptions.stripe_plan_id, users.email')
31
- end
24
+ def collection
25
+ Effective::Customer.customers.uniq
26
+ .joins(:user, :subscriptions)
27
+ .select('customers.*, users.email AS email')
28
+ .select("array_to_string(array(#{Effective::Subscription.purchased.select('subscriptions.stripe_plan_id').where('subscriptions.customer_id = customers.id').to_sql}), ' ,') AS subscription_types")
29
+ .group('customers.id, subscriptions.stripe_plan_id, users.email')
30
+ end
32
31
 
33
- def search_column(collection, table_column, search_term)
34
- return collection.where('subscriptions.stripe_plan_id ILIKE ?', "%#{search_term}%") if table_column[:name] == 'subscription_types'
35
- super
36
- end
32
+ def search_column(collection, table_column, search_term)
33
+ return collection.where('subscriptions.stripe_plan_id ILIKE ?', "%#{search_term}%") if table_column[:name] == 'subscription_types'
34
+ super
37
35
  end
38
36
  end
39
37
  end
@@ -1,101 +1,99 @@
1
- if defined?(EffectiveDatatables)
2
- module Effective
3
- module Datatables
4
- class OrderItems < Effective::Datatable
5
- datatable do
6
- default_order :purchased_at, :desc
7
-
8
- table_column(:purchased_at, type: :datetime, column: 'orders.purchased_at') do |order_item|
9
- Time.at(order_item[:purchased_at]).in_time_zone if order_item[:purchased_at].present?
10
- end
1
+ module Effective
2
+ module Datatables
3
+ class OrderItems < Effective::Datatable
4
+ datatable do
5
+ default_order :purchased_at, :desc
6
+
7
+ table_column(:purchased_at, type: :datetime, column: 'orders.purchased_at') do |order_item|
8
+ Time.at(order_item[:purchased_at]).in_time_zone if order_item[:purchased_at].present?
9
+ end
11
10
 
12
- table_column :id, visible: false
13
-
14
- if EffectiveOrders.obfuscate_order_ids
15
- table_column(:order, type: :obfuscated_id, sortable: false) do |order_item|
16
- obfuscated_id = Effective::Order.obfuscate(order_item[:order_id])
17
- link_to(obfuscated_id, (datatables_admin_path? ? effective_orders.admin_order_path(obfuscated_id) : effective_orders.order_path(obfuscated_id)))
18
- end
19
- else
20
- table_column(:order, sortable: false) do |order_item|
21
- link_to(order_item.to_param, (datatables_admin_path? ? effective_orders.admin_order_path(order_item.to_param) : effective_orders.order_path(order_item.to_param)))
22
- end
23
- end
11
+ table_column :id, visible: false
24
12
 
25
- table_column :email, column: 'users.email', label: 'Buyer Email', if: proc { attributes[:user_id].blank? } do |order_item|
26
- link_to order_item[:email], (edit_admin_user_path(order_item[:user_id]) rescue admin_user_path(order_item[:user_id]) rescue '#')
13
+ if EffectiveOrders.obfuscate_order_ids
14
+ table_column(:order, type: :obfuscated_id, sortable: false) do |order_item|
15
+ obfuscated_id = Effective::Order.obfuscate(order_item[:order_id])
16
+ link_to(obfuscated_id, (datatables_admin_path? ? effective_orders.admin_order_path(obfuscated_id) : effective_orders.order_path(obfuscated_id)))
27
17
  end
28
-
29
- if EffectiveOrders.require_billing_address
30
- table_column :buyer_name, sortable: false, label: 'Buyer Name', if: proc { attributes[:user_id].blank? } do |order_item|
31
- (order_item[:buyer_name] || '').split('!!SEP!!').find(&:present?)
32
- end
18
+ else
19
+ table_column(:order, sortable: false) do |order_item|
20
+ link_to(order_item.to_param, (datatables_admin_path? ? effective_orders.admin_order_path(order_item.to_param) : effective_orders.order_path(order_item.to_param)))
33
21
  end
22
+ end
34
23
 
35
- table_column :purchase_state, column: 'orders.purchase_state', filter: { type: :select, values: [%w(abandoned abandoned), [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED], [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED]], selected: EffectiveOrders::PURCHASED } do |order_item|
36
- order_item[:purchase_state] || 'abandoned'
37
- end
24
+ table_column :email, column: 'users.email', label: 'Buyer Email', if: proc { attributes[:user_id].blank? } do |order_item|
25
+ link_to order_item[:email], (edit_admin_user_path(order_item[:user_id]) rescue admin_user_path(order_item[:user_id]) rescue '#')
26
+ end
38
27
 
39
- table_column :title do |order_item|
40
- order_item.quantity == 1 ? order_item.title : "#{order_item.title} (#{order_item.quantity} purchased)"
28
+ if EffectiveOrders.require_billing_address
29
+ table_column :buyer_name, sortable: false, label: 'Buyer Name', if: proc { attributes[:user_id].blank? } do |order_item|
30
+ (order_item[:buyer_name] || '').split('!!SEP!!').find(&:present?)
41
31
  end
32
+ end
42
33
 
43
- table_column(:subtotal) { |order_item| price_to_currency(order_item[:subtotal].to_i) }
44
- table_column(:tax) { |order_item| price_to_currency(order_item[:tax].to_i) }
45
- table_column(:total) { |order_item| price_to_currency(order_item[:total].to_i) }
34
+ table_column :purchase_state, column: 'orders.purchase_state', filter: { type: :select, values: [%w(abandoned abandoned), [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED], [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED]], selected: EffectiveOrders::PURCHASED } do |order_item|
35
+ order_item[:purchase_state] || 'abandoned'
36
+ end
46
37
 
47
- table_column :created_at, visible: false
48
- table_column :updated_at, visible: false
38
+ table_column :title do |order_item|
39
+ order_item.quantity == 1 ? order_item.title : "#{order_item.title} (#{order_item.quantity} purchased)"
49
40
  end
50
41
 
51
- def collection
52
- collection = Effective::OrderItem.unscoped
53
- .joins(order: :user)
54
- .select('order_items.*, orders.*, users.email AS email')
55
- .select("#{query_subtotal} AS subtotal, #{query_tax} AS tax, #{query_total} AS total")
56
- .group('order_items.id, orders.id, users.email')
42
+ table_column(:subtotal) { |order_item| price_to_currency(order_item[:subtotal].to_i) }
43
+ table_column(:tax) { |order_item| price_to_currency(order_item[:tax].to_i) }
44
+ table_column(:total) { |order_item| price_to_currency(order_item[:total].to_i) }
57
45
 
58
- if EffectiveOrders.require_billing_address && defined?(EffectiveAddresses)
59
- addresses_tbl = EffectiveAddresses.addresses_table_name
46
+ table_column :created_at, visible: false
47
+ table_column :updated_at, visible: false
48
+ end
60
49
 
61
- collection = collection
62
- .joins("LEFT JOIN (SELECT addressable_id, string_agg(#{addresses_tbl}.full_name, '!!SEP!!') AS buyer_name FROM #{addresses_tbl} WHERE #{addresses_tbl}.category = 'billing' AND #{addresses_tbl}.addressable_type = 'Effective::Order' GROUP BY #{addresses_tbl}.addressable_id) #{addresses_tbl} ON orders.id = #{addresses_tbl}.addressable_id")
63
- .group("#{addresses_tbl}.buyer_name")
64
- .select("#{addresses_tbl}.buyer_name AS buyer_name")
65
- end
50
+ def collection
51
+ collection = Effective::OrderItem.unscoped
52
+ .joins(order: :user)
53
+ .select('order_items.*, orders.*, users.email AS email')
54
+ .select("#{query_subtotal} AS subtotal, #{query_tax} AS tax, #{query_total} AS total")
55
+ .group('order_items.id, orders.id, users.email')
66
56
 
67
- attributes[:user_id].present? ? collection.where("#{EffectiveOrders.orders_table_name.to_s}.user_id = ?", attributes[:user_id]) : collection
68
- end
57
+ if EffectiveOrders.require_billing_address && defined?(EffectiveAddresses)
58
+ addresses_tbl = EffectiveAddresses.addresses_table_name
69
59
 
70
- def query_subtotal
71
- 'SUM(price * quantity)'
60
+ collection = collection
61
+ .joins("LEFT JOIN (SELECT addressable_id, string_agg(#{addresses_tbl}.full_name, '!!SEP!!') AS buyer_name FROM #{addresses_tbl} WHERE #{addresses_tbl}.category = 'billing' AND #{addresses_tbl}.addressable_type = 'Effective::Order' GROUP BY #{addresses_tbl}.addressable_id) #{addresses_tbl} ON orders.id = #{addresses_tbl}.addressable_id")
62
+ .group("#{addresses_tbl}.buyer_name")
63
+ .select("#{addresses_tbl}.buyer_name AS buyer_name")
72
64
  end
73
65
 
74
- def query_total
75
- 'SUM((price * quantity) + (CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END))'
76
- end
66
+ attributes[:user_id].present? ? collection.where("#{EffectiveOrders.orders_table_name.to_s}.user_id = ?", attributes[:user_id]) : collection
67
+ end
77
68
 
78
- def query_tax
79
- '(CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END)'
80
- end
69
+ def query_subtotal
70
+ 'SUM(price * quantity)'
71
+ end
81
72
 
82
- def search_column(collection, table_column, search_term)
83
- if table_column[:name] == 'order'
84
- collection.where("#{EffectiveOrders.order_items_table_name.to_s}.order_id = ?", Effective::Order.deobfuscate(search_term))
85
- elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
86
- collection.where("#{EffectiveOrders.orders_table_name.to_s}.purchase_state IS NULL")
87
- elsif table_column[:name] == 'subtotal'
88
- collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
89
- elsif table_column[:name] == 'tax'
90
- collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
91
- elsif table_column[:name] == 'total'
92
- collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
93
- else
94
- super
95
- end
96
- end
73
+ def query_total
74
+ 'SUM((price * quantity) + (CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END))'
75
+ end
97
76
 
77
+ def query_tax
78
+ '(CASE tax_exempt WHEN true THEN 0 ELSE ((price * quantity) * tax_rate) END)'
98
79
  end
80
+
81
+ def search_column(collection, table_column, search_term)
82
+ if table_column[:name] == 'order'
83
+ collection.where("#{EffectiveOrders.order_items_table_name.to_s}.order_id = ?", Effective::Order.deobfuscate(search_term))
84
+ elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
85
+ collection.where("#{EffectiveOrders.orders_table_name.to_s}.purchase_state IS NULL")
86
+ elsif table_column[:name] == 'subtotal'
87
+ collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
88
+ elsif table_column[:name] == 'tax'
89
+ collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
90
+ elsif table_column[:name] == 'total'
91
+ collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
92
+ else
93
+ super
94
+ end
95
+ end
96
+
99
97
  end
100
98
  end
101
99
  end
@@ -1,92 +1,90 @@
1
- if defined?(EffectiveDatatables)
2
- module Effective
3
- module Datatables
4
- class Orders < Effective::Datatable
5
- datatable do
6
- default_order :created_at, :desc
1
+ module Effective
2
+ module Datatables
3
+ class Orders < Effective::Datatable
4
+ datatable do
5
+ default_order :created_at, :desc
7
6
 
8
- table_column :purchased_at
7
+ table_column :purchased_at
9
8
 
10
- table_column :id, label: 'ID' do |order|
11
- link_to order.to_param, effective_orders.admin_order_path(order)
9
+ table_column :id, label: 'ID' do |order|
10
+ link_to order.to_param, effective_orders.admin_order_path(order)
11
+ end
12
+
13
+ # Don't display email or buyer_name column if this is for a specific user
14
+ if attributes[:user_id].blank?
15
+ table_column :email, column: 'users.email', label: 'Buyer Email' do |order|
16
+ link_to order.user.email, (edit_admin_user_path(order.user) rescue admin_user_path(order.user) rescue '#')
12
17
  end
13
18
 
14
- # Don't display email or buyer_name column if this is for a specific user
15
- if attributes[:user_id].blank?
16
- table_column :email, column: 'users.email', label: 'Buyer Email' do |order|
17
- link_to order.user.email, (edit_admin_user_path(order.user) rescue admin_user_path(order.user) rescue '#')
19
+ if EffectiveOrders.use_address_full_name
20
+ table_column :buyer_name, column: 'addresses.full_name' do |order|
21
+ order.billing_address.try(:full_name)
18
22
  end
19
23
 
20
- if EffectiveOrders.use_address_full_name
21
- table_column :buyer_name, column: 'addresses.full_name' do |order|
22
- order.billing_address.try(:full_name)
23
- end
24
-
25
- elsif # Not using address full name
26
- table_column :buyer_name, column: 'users.*' do |order|
27
- order.user.to_s
28
- end
24
+ elsif # Not using address full name
25
+ table_column :buyer_name, column: 'users.*' do |order|
26
+ order.user.to_s
29
27
  end
30
28
  end
29
+ end
31
30
 
32
- if EffectiveOrders.require_billing_address
33
- table_column :billing_address
34
- end
35
-
36
- if EffectiveOrders.require_shipping_address
37
- table_column :shipping_address
38
- end
31
+ if EffectiveOrders.require_billing_address
32
+ table_column :billing_address
33
+ end
39
34
 
40
- table_column :purchase_state, label: 'State', filter: { values: purchase_state_filter_values } do |order|
41
- order.purchase_state || 'abandoned'
42
- end
35
+ if EffectiveOrders.require_shipping_address
36
+ table_column :shipping_address
37
+ end
43
38
 
44
- table_column :order_items, column: 'order_items.title', filter: :string
39
+ table_column :purchase_state, label: 'State', filter: { values: purchase_state_filter_values } do |order|
40
+ order.purchase_state || 'abandoned'
41
+ end
45
42
 
46
- table_column :subtotal, as: :price
47
- table_column :tax, as: :price
43
+ table_column :order_items, column: 'order_items.title', filter: :string
48
44
 
49
- table_column :tax_rate, visible: false do |order|
50
- tax_rate_to_percentage(order.tax_rate)
51
- end
45
+ table_column :subtotal, as: :price
46
+ table_column :tax, as: :price
52
47
 
53
- table_column :total, as: :price
48
+ table_column :tax_rate, visible: false do |order|
49
+ tax_rate_to_percentage(order.tax_rate)
50
+ end
54
51
 
55
- table_column :payment_provider, label: 'Provider', visible: false, filter: { values: ['nil'] + (EffectiveOrders.payment_providers + EffectiveOrders.other_payment_providers).sort }
56
- table_column :payment_card, label: 'Card'
52
+ table_column :total, as: :price
57
53
 
58
- table_column :note, visible: false
59
- table_column :note_to_buyer, visible: false
60
- table_column :note_internal, visible: false
54
+ table_column :payment_provider, label: 'Provider', visible: false, filter: { values: ['nil'] + (EffectiveOrders.payment_providers + EffectiveOrders.other_payment_providers).sort }
55
+ table_column :payment_card, label: 'Card'
61
56
 
62
- table_column :created_at, visible: false
63
- table_column :updated_at, visible: false
57
+ table_column :note, visible: false
58
+ table_column :note_to_buyer, visible: false
59
+ table_column :note_internal, visible: false
64
60
 
65
- actions_column partial: 'admin/orders/actions'
66
- end
61
+ table_column :created_at, visible: false
62
+ table_column :updated_at, visible: false
67
63
 
68
- def collection
69
- collection = Effective::Order.unscoped
70
- .joins(:user)
71
- .includes(:addresses)
72
- .includes(:user)
73
- .includes(:order_items)
64
+ actions_column partial: 'admin/orders/actions'
65
+ end
74
66
 
75
- if EffectiveOrders.orders_collection_scope.respond_to?(:call)
76
- collection = EffectiveOrders.orders_collection_scope.call(collection)
77
- end
67
+ def collection
68
+ collection = Effective::Order.unscoped
69
+ .joins(:user)
70
+ .includes(:addresses)
71
+ .includes(:user)
72
+ .includes(:order_items)
78
73
 
79
- attributes[:user_id].present? ? collection.where(user_id: attributes[:user_id]) : collection
74
+ if EffectiveOrders.orders_collection_scope.respond_to?(:call)
75
+ collection = EffectiveOrders.orders_collection_scope.call(collection)
80
76
  end
81
77
 
82
- def purchase_state_filter_values
83
- [
84
- %w(abandoned nil),
85
- [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED],
86
- [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED],
87
- [EffectiveOrders::PENDING, EffectiveOrders::PENDING]
88
- ]
89
- end
78
+ attributes[:user_id].present? ? collection.where(user_id: attributes[:user_id]) : collection
79
+ end
80
+
81
+ def purchase_state_filter_values
82
+ [
83
+ %w(abandoned nil),
84
+ [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED],
85
+ [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED],
86
+ [EffectiveOrders::PENDING, EffectiveOrders::PENDING]
87
+ ]
90
88
  end
91
89
  end
92
90
  end
@@ -1,12 +1,9 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Customers')
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
- %p.text-right= link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
3
+ %p.text-right.effective-admin-actions
4
+ = link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
4
5
 
5
- - if @datatable.nil?
6
- %p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
7
- - elsif @datatable.present?
6
+ - if @datatable.present?
8
7
  = render_datatable @datatable
9
8
  - else
10
9
  %p There are no customers present
11
-
12
- %p.text-right= link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
@@ -1,8 +1,6 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Order Items')
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
- - if @datatable.nil?
4
- %p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
5
- - elsif @datatable.present?
3
+ - if @datatable.present?
6
4
  = render_datatable @datatable
7
5
  - else
8
6
  %p There are no order items present
@@ -8,7 +8,7 @@
8
8
  as: (defined?(EffectiveFormInputs) ? :effective_select : :select),
9
9
  collection: @users || User.all.to_a.sort { |user1, user2| user1.to_s <=> user2.to_s }
10
10
 
11
- %h3 Order Items
11
+ %h2 Order Items
12
12
  .order_items
13
13
  - f.object.order_items.build unless f.object.order_items.present?
14
14
  = f.simple_fields_for :order_items do |order_item|
@@ -23,7 +23,7 @@
23
23
  value: (f.object.send_payment_request_to_buyer.nil? ? EffectiveOrders.mailer[:send_payment_request_to_buyer] : f.object.send_payment_request_to_buyer?)
24
24
 
25
25
  .effective-order-internal-note
26
- %h3 Internal Note
26
+ %h2 Internal Note
27
27
  = f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
28
28
 
29
29
  = render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
@@ -1,5 +1,5 @@
1
1
  = simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_orders.mark_as_paid_admin_order_path(order), method: :post) do |f|
2
- %h3 Payment Details
2
+ %h2 Payment Details
3
3
 
4
4
  - if order.purchased?
5
5
  .alert.alert-warning Warning: This order has already been purchased
@@ -26,7 +26,7 @@
26
26
  value: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.mailer[:send_order_receipts_when_mark_as_paid_by_admin] : f.object.send_mark_as_paid_email_to_buyer?)
27
27
 
28
28
  .effective-order-note-to-buyer
29
- %h3 Note to Buyer
29
+ %h2 Note to Buyer
30
30
  = f.input :note_to_buyer, label: false, hint: 'This is displayed to the buyer on all order receipts.'
31
31
 
32
32
  = render partial: '/admin/orders/order_actions', locals: { order: @order, form: f, f: f }
@@ -1,5 +1,5 @@
1
1
  .effective-order-internal-note-form
2
- %h3 Internal Note
2
+ %h2 Internal Note
3
3
 
4
4
  = simple_form_for [:admin, order], (EffectiveOrders.admin_simple_form_options || {}).merge(url: effective_orders.admin_order_path(order)) do |f|
5
5
  = f.input :note_internal, label: false, hint: 'For internal admin use only. This note will never be displayed to the buyer.'
@@ -1,5 +1,5 @@
1
1
  - if order.payment.present?
2
2
  .effective-order-payment-details
3
- %h3 Payment Provider Details
3
+ %h2 Payment Provider Details
4
4
  = tableize_order_payment(order.payment[:details] || order.payment, class: 'table')
5
5
 
@@ -1,15 +1,9 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Orders')
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
- %p.text-right.effective-orders-page-action= link_to 'New Order', effective_orders.new_admin_order_path, :class => 'btn btn-primary'
3
+ %p.text-right.effective-admin-actions
4
+ = link_to 'New Order', effective_orders.new_admin_order_path, class: 'btn btn-primary'
4
5
 
5
- - if @datatable.nil?
6
- %p Please install #{link_to 'effective_datatables', 'https://github.com/code-and-effect/effective_datatables'} to see this page.
7
- - elsif @datatable.present?
6
+ - if @datatable.present?
8
7
  = render_datatable @datatable
9
8
  - else
10
9
  %p There are no orders present
11
-
12
- - if @datatable.present?
13
- %p.text-right= link_to 'New Order', effective_orders.new_admin_order_path, :class => 'btn btn-primary'
14
-
15
-
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Mark as Paid')
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
3
  %p Mark the following order as paid:
4
4
 
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@page_title || 'New Order')
1
+ %h1.effective-admin-heading= @page_title
2
2
 
3
3
  = render partial: 'form', locals: { order: @order }
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@order.purchased? ? 'Receipt' : 'Order')
1
+ %h1.effective-admin-heading= (@order.purchased? ? 'Receipt' : 'Order')
2
2
 
3
3
  = render partial: 'effective/orders/order', locals: {order: @order}
4
4
 
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'My Cart')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  - if @cart.empty?
4
4
  %p Your cart is empty.
@@ -10,7 +10,7 @@
10
10
  = render partial: '/effective/carts/cart_actions', locals: { cart: @cart }
11
11
 
12
12
  - if @pending_orders.present?
13
- %h3 Pending Orders
13
+ %h2 Pending Orders
14
14
  = render_orders(@pending_orders)
15
15
 
16
16
  - if EffectiveOrders.show_order_history_button
@@ -17,14 +17,14 @@
17
17
  .row
18
18
  - if EffectiveOrders.require_billing_address
19
19
  %div{class: "col-sm-#{12 / num_addresses}"}
20
- %h3 Billing Address
20
+ %h2 Billing Address
21
21
  = effective_address_fields(f, :billing_address)
22
22
  - if f.object.user.respond_to?(:billing_address=)
23
23
  = f.input :save_billing_address, as: :boolean, label: 'Save as my default billing address', required: false
24
24
 
25
25
  - if EffectiveOrders.require_shipping_address
26
26
  %div{class: "col-sm-#{12 / num_addresses}"}
27
- %h3 Shipping Address
27
+ %h2 Shipping Address
28
28
  = effective_address_fields(f, :shipping_address)
29
29
  - if f.object.user.respond_to?(:shipping_address=)
30
30
  = f.input :save_shipping_address, as: :boolean, label: 'Save as my default shipping address', required: false
@@ -1,4 +1,4 @@
1
- %h3 Note
1
+ %h2 Note
2
2
  - if EffectiveOrders.collect_note_message.present?
3
3
  %p= EffectiveOrders.collect_note_message.html_safe
4
4
 
@@ -1,6 +1,6 @@
1
1
  - if order.purchased?
2
2
  .effective-order-payment-details
3
- %h3 Payment Details
3
+ %h2 Payment Details
4
4
  %table.table
5
5
  %tbody
6
6
  %tr
@@ -1,4 +1,4 @@
1
- %h3 Terms and Conditions
1
+ %h2 Terms and Conditions
2
2
 
3
3
  - terms = EffectiveOrders.terms_and_conditions_label
4
4
 
@@ -1,4 +1,4 @@
1
- %h3 User Information
1
+ %h2 User Information
2
2
  = form.simple_fields_for :user, user do |fa|
3
3
  - if (EffectiveOrders.collect_user_fields || []).include?(:salutation) && fa.object.respond_to?(:salutation)
4
4
  - if defined?(fa.object.class::SALUTATIONS)
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Checkout')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  = render_checkout_step1(@order)
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Checkout')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  = render_checkout_step2(@order)
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Payment Required')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  - if EffectiveOrders.cheque[:success_message].present?
4
4
  %p.effective-orders-page-content
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Payment Declined')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  %p= flash[:danger]
4
4
 
@@ -1,12 +1,12 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Orders')
1
+ %h1.effective-heading= @page_title
2
2
 
3
- %h3 Pending Orders
3
+ %h2 Pending Orders
4
4
  - if @pending_orders.present?
5
5
  = render_orders(@pending_orders)
6
6
  - else
7
7
  %p You have no pending orders.
8
8
 
9
- %h3 Purchased Orders
9
+ %h2 Purchased Orders
10
10
  - if @orders.present?
11
11
  = render_orders(@orders)
12
12
  - else
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Order History')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  = render_order_history(@orders)
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Sales History')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  %table.table
4
4
  %thead
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Thank You')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  %p.effective-orders-page-content
4
4
  You have successfully purchased the following:
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@page_title || 'Order')
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  = render @order
@@ -1,4 +1,7 @@
1
- %h2.effective-orders-page-title My Subscriptions
1
+ %h1.effective-heading= @page_title
2
+
3
+ %p.text-right.effective-actions
4
+ = link_to 'New Subscription', effective_orders.new_subscription_path, class: 'btn btn-primary'
2
5
 
3
6
  - if @subscriptions.present?
4
7
  %p You have the following subscriptions:
@@ -17,5 +20,3 @@
17
20
 
18
21
  - else
19
22
  %p You have no subscriptions
20
-
21
- %p.text-right= link_to 'New Subscription', effective_orders.new_subscription_path
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title New Subscription
1
+ %h1.effective-heading= @page_title
2
2
 
3
3
  - if @plans.present?
4
4
  = simple_form_for(@subscription, (EffectiveOrders.simple_form_options || {}).merge(:url => effective_orders.subscriptions_path, :method => :post)) do |f|
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title
1
+ %h1.effective-heading
2
2
  = @plan.name
3
3
  Subscription
4
4
  details
@@ -24,7 +24,7 @@
24
24
  %th Current Period End
25
25
  %td= Time.zone.at(@stripe_subscription.current_period_end).strftime("%d-%b-%Y")
26
26
 
27
- %h3= "#{@plan.interval.chomp('ly')}ly Invoices"
27
+ %h2= "#{@plan.interval.chomp('ly')}ly Invoices"
28
28
 
29
29
  %table.table
30
30
  %thead
@@ -44,6 +44,6 @@
44
44
  = Time.zone.at(invoice.lines.first.period.end).strftime("%d-%b-%Y")
45
45
  %td= price_to_currency(invoice.total)
46
46
 
47
- %h3 Cancel Subscription
47
+ %h2 Cancel Subscription
48
48
 
49
49
  = link_to 'Unsubscribe', effective_orders.subscription_path(@plan.id), :data => {:method => :delete, :confirm => 'This will cancel your subscription. Are you sure? This cannot be undone.', :disable_with => 'Unsubscribing...'}
@@ -30,7 +30,7 @@ EffectiveOrders.setup do |config|
30
30
  #
31
31
  # Or disable the check completely:
32
32
  # config.authorization_method = false
33
- config.authorization_method = Proc.new { |controller, action, resource| true }
33
+ config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
34
34
 
35
35
  # Skip automatically mounting the EffectiveOrders engine
36
36
  config.skip_mount_engine = false
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '2.1.17'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -3,7 +3,7 @@ module EffectiveOrders
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  include Rails::Generators::Migration
5
5
 
6
- desc "Creates an EffectiveOrders initializer in your application."
6
+ desc 'Creates an EffectiveOrders initializer in your application.'
7
7
 
8
8
  source_root File.expand_path('../../templates', __FILE__)
9
9
 
@@ -16,7 +16,7 @@ module EffectiveOrders
16
16
  end
17
17
 
18
18
  def install_effective_addresses
19
- run "rails generate effective_addresses:install"
19
+ run 'rails generate effective_addresses:install'
20
20
  end
21
21
 
22
22
  def copy_initializer
@@ -24,11 +24,7 @@ module EffectiveOrders
24
24
  @subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s
25
25
  @products_table_name = ':' + EffectiveOrders.products_table_name.to_s
26
26
 
27
- migration_template '../../../db/upgrade/02_upgrade_effective_orders_from03x.rb.erb', 'db/migrate/upgrade_effective_orders_from03x.rb'
28
- end
29
-
30
- def show_readme
31
- readme "README" if behavior == :invoke
27
+ migration_template ('../' * 3) + 'db/upgrade/02_upgrade_effective_orders_from03x.rb.erb', 'db/migrate/upgrade_effective_orders_from03x.rb'
32
28
  end
33
29
  end
34
30
  end
@@ -20,11 +20,7 @@ module EffectiveOrders
20
20
  @subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s
21
21
  @products_table_name = ':' + EffectiveOrders.products_table_name.to_s
22
22
 
23
- migration_template '../../../db/upgrade/03_upgrade_effective_orders_from1x.rb.erb', 'db/migrate/upgrade_effective_orders_from1x.rb'
24
- end
25
-
26
- def show_readme
27
- readme 'README' if behavior == :invoke
23
+ migration_template ('../' * 3) + 'db/upgrade/03_upgrade_effective_orders_from1x.rb.erb', 'db/migrate/upgrade_effective_orders_from1x.rb'
28
24
  end
29
25
  end
30
26
  end
@@ -23,11 +23,7 @@ module EffectiveOrders
23
23
  @table = table.to_s.downcase
24
24
  @column = column.to_s.downcase
25
25
 
26
- migration_template '../../../db/upgrade/upgrade_price_column_on_table.rb.erb', "db/migrate/upgrade_price_column_on_#{table}.rb"
27
- end
28
-
29
- def show_readme
30
- readme "README" if behavior == :invoke
26
+ migration_template ('../' * 3) + 'db/upgrade/upgrade_price_column_on_table.rb.erb', "db/migrate/upgrade_price_column_on_#{table}.rb"
31
27
  end
32
28
  end
33
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.17
4
+ version: 2.2.0
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: 2016-10-26 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.6.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: effective_datatables
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.0.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.0.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: stripe-ruby-mock
127
141
  requirement: !ruby/object:Gem::Requirement