effective_orders 2.1.15 → 2.1.16
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/README.md +14 -5
- data/app/controllers/admin/customers_controller.rb +1 -1
- data/app/controllers/admin/order_items_controller.rb +1 -1
- data/app/controllers/admin/orders_controller.rb +1 -1
- data/app/controllers/effective/orders_controller.rb +10 -2
- data/app/controllers/effective/providers/ccbill.rb +5 -1
- data/app/controllers/effective/providers/moneris.rb +5 -1
- data/app/controllers/effective/providers/paypal.rb +5 -1
- data/app/controllers/effective/providers/stripe_connect.rb +5 -1
- data/app/controllers/effective/subscriptions_controller.rb +2 -2
- data/app/models/effective/order.rb +14 -5
- data/app/views/admin/orders/_order_actions.html.haml +0 -2
- data/config/effective_orders.rb +1 -1
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/effective_orders/install_generator.rb +4 -0
- data/lib/tasks/effective_orders_tasks.rake +28 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c64d51c4326b5857b31313d877c0058c0c9b64e1
|
4
|
+
data.tar.gz: 926b603e981b5da23d2b13ffec658b4818180ab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d9c2b16a7977b527613b415ced35c1749e1ef256f183175f3ff6135f1f296750e64d36c7611831d236d8231bd5472608662469dbad85814d2c6e43b6beda3d8
|
7
|
+
data.tar.gz: 7a4a1957c65e0bcc72251903d1b1f8b62318bc0cbd461b31a3d8835840e8a283aa2bdc39f2870dfdd15ba0180a57dc7ec345d2cbf3c300ab71ae4f2a24e2edd0
|
data/README.md
CHANGED
@@ -12,11 +12,7 @@ Has Order History, My Purchases, My Sales and Admin screens.
|
|
12
12
|
|
13
13
|
## Getting Started
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
```console
|
18
|
-
ruby -v
|
19
|
-
```
|
15
|
+
Please first install the [effective_addresses](https://github.com/code-and-effect/effective_addresses) and [effective_datatables](https://github.com/code-and-effect/effective_datatables) gems.
|
20
16
|
|
21
17
|
Add to your Gemfile:
|
22
18
|
|
@@ -645,6 +641,19 @@ and then in the view:
|
|
645
641
|
render_datatable @datatable
|
646
642
|
```
|
647
643
|
|
644
|
+
## Rake Tasks
|
645
|
+
|
646
|
+
### Overwrite order item titles
|
647
|
+
|
648
|
+
When an order is purchased, the `title()` of each `acts_as_purchasable` object is saved to the database.
|
649
|
+
|
650
|
+
If you change the output of `acts_as_purchasable`.`title`, any existing order items will remain unchanged.
|
651
|
+
|
652
|
+
Run this script to overwrite all saved order item titles with the current `acts_as_purchasable`.`title`.
|
653
|
+
|
654
|
+
```ruby
|
655
|
+
rake effective_orders:overwrite_order_item_titles
|
656
|
+
```
|
648
657
|
|
649
658
|
## Testing in Development
|
650
659
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class CustomersController < ApplicationController
|
3
|
-
|
3
|
+
respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
|
4
4
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_customers] : EffectiveOrders.layout)
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class OrderItemsController < ApplicationController
|
3
|
-
|
3
|
+
respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
|
4
4
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Admin
|
2
2
|
class OrdersController < ApplicationController
|
3
|
-
|
3
|
+
respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
|
4
4
|
|
5
5
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
|
6
6
|
|
@@ -16,10 +16,18 @@ module Effective
|
|
16
16
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:orders] : EffectiveOrders.layout)
|
17
17
|
|
18
18
|
if defined?(Devise)
|
19
|
-
|
19
|
+
if respond_to?(:before_action)
|
20
|
+
before_action :authenticate_user!, except: [:paypal_postback, :ccbill_postback]
|
21
|
+
else
|
22
|
+
before_filter :authenticate_user!, except: [:paypal_postback, :ccbill_postback]
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
|
-
|
26
|
+
if respond_to?(:before_action)
|
27
|
+
before_action :set_page_title, except: [:show]
|
28
|
+
else
|
29
|
+
before_filter :set_page_title, except: [:show]
|
30
|
+
end
|
23
31
|
|
24
32
|
# This is the entry point for the "Checkout" buttons
|
25
33
|
def new
|
@@ -4,7 +4,11 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
if respond_to?(:skip_before_action)
|
8
|
+
skip_before_action :verify_authenticity_token, only: [:ccbill_postback]
|
9
|
+
else
|
10
|
+
skip_before_filter :verify_authenticity_token, only: [:ccbill_postback]
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def ccbill_postback
|
@@ -4,7 +4,11 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
if respond_to?(:prepend_before_action)
|
8
|
+
prepend_before_action :find_authenticity_token_from_moneris, only: [:moneris_postback]
|
9
|
+
else
|
10
|
+
prepend_before_filter :find_authenticity_token_from_moneris, only: [:moneris_postback]
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def moneris_postback
|
@@ -4,7 +4,11 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
if respond_to?(:skip_before_action)
|
8
|
+
skip_before_action :verify_authenticity_token, :only => [:paypal_postback]
|
9
|
+
else
|
10
|
+
skip_before_filter :verify_authenticity_token, :only => [:paypal_postback]
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def paypal_postback
|
@@ -4,7 +4,11 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
7
|
+
if respond_to?(:prepend_before_action)
|
8
|
+
prepend_before_action :set_stripe_connect_state_params, :only => [:stripe_connect_redirect_uri]
|
9
|
+
else
|
10
|
+
prepend_before_filter :set_stripe_connect_state_params, :only => [:stripe_connect_redirect_uri]
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
# So this is the postback after Stripe does its oAuth authentication
|
@@ -5,8 +5,8 @@ module Effective
|
|
5
5
|
|
6
6
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:subscriptions] : EffectiveOrders.layout)
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
|
9
|
+
respond_to?(:before_action) ? before_action(:assign_customer) : before_filter(:assign_customer)
|
10
10
|
|
11
11
|
# This is a 'My Subscriptions' page
|
12
12
|
def index
|
@@ -274,23 +274,23 @@ module Effective
|
|
274
274
|
end
|
275
275
|
|
276
276
|
def save_billing_address?
|
277
|
-
|
277
|
+
truthy?(self.save_billing_address)
|
278
278
|
end
|
279
279
|
|
280
280
|
def save_shipping_address?
|
281
|
-
|
281
|
+
truthy?(self.save_shipping_address)
|
282
282
|
end
|
283
283
|
|
284
284
|
def send_payment_request_to_buyer?
|
285
|
-
|
285
|
+
truthy?(self.send_payment_request_to_buyer)
|
286
286
|
end
|
287
287
|
|
288
288
|
def send_mark_as_paid_email_to_buyer?
|
289
|
-
|
289
|
+
truthy?(self.send_mark_as_paid_email_to_buyer)
|
290
290
|
end
|
291
291
|
|
292
292
|
def skip_buyer_validations?
|
293
|
-
|
293
|
+
truthy?(self.skip_buyer_validations)
|
294
294
|
end
|
295
295
|
|
296
296
|
def billing_name
|
@@ -457,5 +457,14 @@ module Effective
|
|
457
457
|
return false
|
458
458
|
end
|
459
459
|
end
|
460
|
+
|
461
|
+
def truthy?(value)
|
462
|
+
if defined?(::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES) # Rails <5
|
463
|
+
::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(value)
|
464
|
+
else
|
465
|
+
ActiveRecord::Type::Boolean.new.cast(value)
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
460
469
|
end
|
461
470
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
%p.text-right
|
2
2
|
= form.button :submit, 'Save', data: { disable_with: 'Saving...' }
|
3
3
|
= form.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
|
4
|
-
- unless params[:action] == 'mark_as_paid'
|
5
|
-
= form.button :submit, 'Save and Mark as Paid', data: { disable_with: 'Saving...' }
|
6
4
|
= link_to 'Cancel', effective_orders.admin_orders_path
|
data/config/effective_orders.rb
CHANGED
@@ -45,7 +45,7 @@ EffectiveOrders.setup do |config|
|
|
45
45
|
config.active_admin_namespace = :admin # Passed internally to ActiveAdmin.register
|
46
46
|
|
47
47
|
# Use effective_obfuscation gem to change order.id into a seemingly random 10-digit number
|
48
|
-
config.obfuscate_order_ids =
|
48
|
+
config.obfuscate_order_ids = false
|
49
49
|
|
50
50
|
# Silence the price deprecation warnings
|
51
51
|
config.silence_deprecation_warnings = false
|
@@ -15,6 +15,10 @@ module EffectiveOrders
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def install_effective_addresses
|
19
|
+
run "rails generate effective_addresses:install"
|
20
|
+
end
|
21
|
+
|
18
22
|
def copy_initializer
|
19
23
|
template ('../' * 3) + 'config/effective_orders.rb', 'config/initializers/effective_orders.rb'
|
20
24
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
namespace :effective_orders do
|
2
|
+
desc 'Overwrite all order item titles with current acts_as_purchasable object title'
|
3
|
+
task overwrite_order_item_titles: :environment do
|
4
|
+
puts 'WARNING: this task will overwrite all existing order items with new titles. Proceed? (y/n)'
|
5
|
+
(puts 'Aborted' and exit) unless STDIN.gets.chomp.downcase == 'y'
|
6
|
+
|
7
|
+
Effective::OrderItem.transaction do
|
8
|
+
begin
|
9
|
+
|
10
|
+
Effective::OrderItem.includes(:purchasable).find_each do |order_item|
|
11
|
+
new_title = order_item.purchasable.title
|
12
|
+
|
13
|
+
unless new_title
|
14
|
+
raise "acts_as_purchasable object #{order_item.purchasable_type.try(:classify)}<#{order_item.purchasable_id}>.title() from Effective::OrderItem<#{order_item.id}> cannot be nil."
|
15
|
+
end
|
16
|
+
|
17
|
+
order_item.update_column(:title, new_title) # This intentionally skips validation
|
18
|
+
end
|
19
|
+
|
20
|
+
puts 'Successfully updated all order item titles.'
|
21
|
+
rescue => e
|
22
|
+
puts "An error has occurred: #{e.message}"
|
23
|
+
puts "(effective_orders) Rollback. No order item titles have been changed."
|
24
|
+
raise ActiveRecord::Rollback
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
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.
|
4
|
+
version: 2.1.16
|
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-07
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- lib/generators/effective_orders/upgrade_from1x_generator.rb
|
385
385
|
- lib/generators/effective_orders/upgrade_price_column_generator.rb
|
386
386
|
- lib/generators/templates/effective_orders_mailer_preview.rb
|
387
|
+
- lib/tasks/effective_orders_tasks.rake
|
387
388
|
- spec/controllers/admin/orders_controller_spec.rb
|
388
389
|
- spec/controllers/carts_controller_spec.rb
|
389
390
|
- spec/controllers/ccbill_orders_controller_spec.rb
|