effective_orders 1.4.8 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/acts_as_active_admin_controller.rb +58 -0
- data/app/controllers/effective/carts_controller.rb +1 -1
- data/app/controllers/effective/orders_controller.rb +1 -1
- data/lib/effective_orders/engine.rb +5 -7
- data/lib/effective_orders/version.rb +1 -1
- metadata +2 -3
- data/app/controllers/effective/active_admin_helpers/carts.rb +0 -47
- data/app/controllers/effective/active_admin_helpers/orders.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1a47576086e85e24dc44de2c8c6e2c6bc78e074
|
4
|
+
data.tar.gz: 2eda2b07e901a0a0af711768a2d0e6210fac5791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4597fbb04b3808a5de5cd7e6f3e6034c5b1405491b1705dfd96cedf9d3dbedd8909d3ce8ba2f11b6fd6f3ffa262dc8e70a6a71f6284622bd85e3a7db4f815e43
|
7
|
+
data.tar.gz: f8e2772c836c2becb559ba5a4659a23311dc156d48f0d7730e94687c26488f94b99c8f28626323073b465d6d115a073f317584e507fe728634613122b080b679
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ActsAsActiveAdminController
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ActionController
|
5
|
+
def acts_as_active_admin_controller(key)
|
6
|
+
@active_admin_resource_element_lookup_key = key
|
7
|
+
include ::ActsAsActiveAdminController
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
included do
|
12
|
+
include ::ActiveAdmin::BaseController::Menu
|
13
|
+
include ::ActiveAdmin::BaseController::Authorization
|
14
|
+
|
15
|
+
helper ::ActiveAdmin::ViewHelpers
|
16
|
+
helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
|
17
|
+
|
18
|
+
resource_key = @active_admin_resource_element_lookup_key.to_s
|
19
|
+
self.send(:define_method, :active_admin_resource_element_key) { resource_key }
|
20
|
+
|
21
|
+
resource_ivar = '@' + resource_key.singularize
|
22
|
+
self.send(:define_method, :resource) { instance_variable_get(resource_ivar) }
|
23
|
+
|
24
|
+
resource_path = "effective_orders.#{resource_key.singularize}_path"
|
25
|
+
|
26
|
+
if resource_path == 'effective_orders.cart_path'
|
27
|
+
self.send(:define_method, :resource_path) { |resource| effective_orders.cart_path }
|
28
|
+
else
|
29
|
+
self.send(:define_method, :resource_path) { |resource| public_send(resource_path, resource) }
|
30
|
+
end
|
31
|
+
|
32
|
+
helper_method :resource, :resource_path
|
33
|
+
end
|
34
|
+
|
35
|
+
module ClassMethods
|
36
|
+
end
|
37
|
+
|
38
|
+
def active_admin_namespace
|
39
|
+
::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
40
|
+
end
|
41
|
+
|
42
|
+
def active_admin_config
|
43
|
+
active_admin_namespace.resources[active_admin_resource_key]
|
44
|
+
end
|
45
|
+
|
46
|
+
def active_admin_resource_key
|
47
|
+
@active_admin_resource_key ||= begin
|
48
|
+
namespace = ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
49
|
+
namespace.resources.keys.find { |resource| resource.element == active_admin_resource_element_key }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def current_active_admin_user
|
54
|
+
send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Effective
|
2
2
|
class CartsController < ApplicationController
|
3
3
|
include EffectiveCartsHelper
|
4
|
-
|
4
|
+
acts_as_active_admin_controller('carts') if EffectiveOrders.use_active_admin
|
5
5
|
|
6
6
|
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:carts] : EffectiveOrders.layout)
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Effective
|
2
2
|
class OrdersController < ApplicationController
|
3
3
|
include EffectiveCartsHelper
|
4
|
-
|
4
|
+
acts_as_active_admin_controller('orders') if EffectiveOrders.use_active_admin
|
5
5
|
|
6
6
|
include Providers::Moneris if EffectiveOrders.moneris_enabled
|
7
7
|
include Providers::Paypal if EffectiveOrders.paypal_enabled
|
@@ -7,6 +7,10 @@ module EffectiveOrders
|
|
7
7
|
# Include Helpers to base application
|
8
8
|
initializer 'effective_orders.action_controller' do |app|
|
9
9
|
ActiveSupport.on_load :action_controller do
|
10
|
+
if EffectiveOrders.use_active_admin
|
11
|
+
ActionController::Base.extend(ActsAsActiveAdminController::ActionController)
|
12
|
+
end
|
13
|
+
|
10
14
|
helper EffectiveOrdersHelper
|
11
15
|
helper EffectiveCartsHelper
|
12
16
|
helper EffectivePaypalHelper if EffectiveOrders.paypal_enabled
|
@@ -45,13 +49,7 @@ module EffectiveOrders
|
|
45
49
|
initializer 'effective_orders.active_admin' do
|
46
50
|
if EffectiveOrders.use_active_admin
|
47
51
|
require 'activeadmin'
|
48
|
-
|
49
|
-
|
50
|
-
ActiveAdmin::Event.subscribe ActiveAdmin::Application::BeforeLoadEvent do
|
51
|
-
puts "SUBSCRIBED ACTIVEADMIN EVENT"
|
52
|
-
::ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
|
53
|
-
end
|
54
|
-
|
52
|
+
::ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -327,8 +327,7 @@ files:
|
|
327
327
|
- app/controllers/admin/customers_controller.rb
|
328
328
|
- app/controllers/admin/order_items_controller.rb
|
329
329
|
- app/controllers/admin/orders_controller.rb
|
330
|
-
- app/controllers/
|
331
|
-
- app/controllers/effective/active_admin_helpers/orders.rb
|
330
|
+
- app/controllers/concerns/acts_as_active_admin_controller.rb
|
332
331
|
- app/controllers/effective/carts_controller.rb
|
333
332
|
- app/controllers/effective/orders_controller.rb
|
334
333
|
- app/controllers/effective/providers/moneris.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Effective
|
2
|
-
module ActiveAdminHelpers
|
3
|
-
module Carts
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
include ::ActiveAdmin::BaseController::Menu
|
8
|
-
include ::ActiveAdmin::BaseController::Authorization
|
9
|
-
|
10
|
-
helper ::ActiveAdmin::ViewHelpers
|
11
|
-
helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
|
12
|
-
helper_method :resource, :resource_path
|
13
|
-
end
|
14
|
-
|
15
|
-
module ClassMethods
|
16
|
-
end
|
17
|
-
|
18
|
-
def resource
|
19
|
-
instance_variable_get(@cart)
|
20
|
-
end
|
21
|
-
|
22
|
-
def resource_path(resource)
|
23
|
-
effective_orders.cart_path
|
24
|
-
end
|
25
|
-
|
26
|
-
def active_admin_namespace
|
27
|
-
::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
28
|
-
end
|
29
|
-
|
30
|
-
def active_admin_config
|
31
|
-
active_admin_namespace.resources[active_admin_resource_key]
|
32
|
-
end
|
33
|
-
|
34
|
-
def active_admin_resource_key
|
35
|
-
@active_admin_resource_key ||= begin
|
36
|
-
namespace = ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
37
|
-
namespace.resources.keys.find { |resource| resource.element == 'carts' }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def current_active_admin_user
|
42
|
-
send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Effective
|
2
|
-
module ActiveAdminHelpers
|
3
|
-
module Orders
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
include ::ActiveAdmin::BaseController::Menu
|
8
|
-
include ::ActiveAdmin::BaseController::Authorization
|
9
|
-
|
10
|
-
helper ::ActiveAdmin::ViewHelpers
|
11
|
-
helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
|
12
|
-
helper_method :resource, :resource_path
|
13
|
-
end
|
14
|
-
|
15
|
-
module ClassMethods
|
16
|
-
end
|
17
|
-
|
18
|
-
def resource
|
19
|
-
instance_variable_get(@order)
|
20
|
-
end
|
21
|
-
|
22
|
-
def resource_path(resource)
|
23
|
-
effective_orders.order_path(resource)
|
24
|
-
end
|
25
|
-
|
26
|
-
def active_admin_namespace
|
27
|
-
::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
28
|
-
end
|
29
|
-
|
30
|
-
def active_admin_config
|
31
|
-
active_admin_namespace.resources[active_admin_resource_key]
|
32
|
-
end
|
33
|
-
|
34
|
-
def active_admin_resource_key
|
35
|
-
@active_admin_resource_key ||= begin
|
36
|
-
namespace = ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
|
37
|
-
namespace.resources.keys.find { |resource| resource.element == 'orders' }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def current_active_admin_user
|
42
|
-
send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|