effective_orders 1.5.2 → 1.5.3

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/active_admin/effective_orders.rb +19 -28
  3. data/app/controllers/effective/carts_controller.rb +0 -1
  4. data/app/controllers/effective/orders_controller.rb +0 -1
  5. data/app/models/concerns/acts_as_purchasable.rb +4 -0
  6. data/app/models/effective/order.rb +16 -0
  7. data/app/views/admin/customers/index.html.haml +1 -1
  8. data/app/views/admin/order_items/index.html.haml +1 -1
  9. data/app/views/admin/orders/index.html.haml +1 -1
  10. data/app/views/admin/orders/show.html.haml +3 -2
  11. data/app/views/effective/carts/show.html.haml +1 -1
  12. data/app/views/effective/orders/_order.html.haml +3 -0
  13. data/app/views/effective/orders/_order_actions.html.haml +4 -3
  14. data/app/views/effective/orders/_order_header.html.haml +20 -19
  15. data/app/views/effective/orders/_order_payment_details.html.haml +7 -9
  16. data/app/views/effective/orders/_order_shipping.html.haml +20 -19
  17. data/app/views/effective/orders/checkout.html.haml +1 -1
  18. data/app/views/effective/orders/declined.html.haml +1 -1
  19. data/app/views/effective/orders/my_purchases.html.haml +1 -1
  20. data/app/views/effective/orders/my_sales.html.haml +1 -1
  21. data/app/views/effective/orders/new.html.haml +1 -1
  22. data/app/views/effective/orders/purchased.html.haml +1 -1
  23. data/app/views/effective/orders/show.html.haml +1 -3
  24. data/app/views/effective/subscriptions/index.html.haml +1 -1
  25. data/app/views/effective/subscriptions/new.html.haml +1 -1
  26. data/app/views/effective/subscriptions/show.html.haml +1 -1
  27. data/lib/effective_orders/engine.rb +7 -3
  28. data/lib/effective_orders/version.rb +1 -1
  29. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68837d038f48f9503cb95b4975a88a85bf2bb5f4
4
- data.tar.gz: dab5e51afb7ea037856bea992fea9ea0c9b8da73
3
+ metadata.gz: 1c08f993d24d281ba8e17af297fc43eda2d25425
4
+ data.tar.gz: 405e69619e74b45eeb3808dc31403e681666ed5d
5
5
  SHA512:
6
- metadata.gz: 1edcf64fe4df807a613887574d172fc86a713c03448ce9bf75d4dd82c63bce49154c7b44c056977d916a39493d1b04076d4323bed4e400716b92f485392c7f59
7
- data.tar.gz: 6038dfad385dd638b9419bda5d851cd39f497a16d661111d8c8829b53cc80f8e3c0f0ae2f3d8ddfbf465d6d8fe7bb9f2692c9879ffbffb6e8d9e43e00aef5293
6
+ metadata.gz: 456c396d95df8356f5db6a1985b0814955cda265c04162540ba9ac6dae48aa7b575183137ec00ae84445127d351b1673f7abc3441cd6cc0f3ebb4bd159a8bfd6
7
+ data.tar.gz: b1e31fdf1558cdf2160be96e1b289595e8f341fd2a244f35f4302061d88027d81ae2fa1828002384c89e285e9af65d4831c6ee3562b28a854f931990a8f21000
@@ -18,7 +18,7 @@ if defined?(ActiveAdmin)
18
18
  include EffectiveOrdersHelper
19
19
 
20
20
  def scoped_collection
21
- end_of_association_chain.includes(:user).includes(:order_items => :purchasable)
21
+ end_of_association_chain.includes(:user).includes(order_items: :purchasable)
22
22
  end
23
23
  end
24
24
 
@@ -33,7 +33,8 @@ if defined?(ActiveAdmin)
33
33
  end
34
34
 
35
35
  column 'Buyer', :sortable => :user_id do |order|
36
- link_to order.user, (admin_user_path(order.user) rescue '#')
36
+ user_path = [EffectiveOrders.active_admin_namespace.presence, 'user_path'].compact.join('_')
37
+ link_to order.user, (public_send(user_path, order.user) rescue '#')
37
38
  end
38
39
 
39
40
  column 'Summary' do |order|
@@ -41,51 +42,41 @@ if defined?(ActiveAdmin)
41
42
  end
42
43
 
43
44
  column :purchased_at
45
+ column :purchase_method
44
46
 
45
47
  column do |order|
46
- links = link_to('View', effective_orders.order_path(order), class: 'member_link view_link')
47
-
48
- if authorized?(:manage, Effective::Order) # This is the Admin level check
49
- details_path = ['details', EffectiveOrders.active_admin_namespace.presence, 'order_path'].compact.join('_')
50
- links += link_to('Details', public_send(details_path, order))
51
- end
52
-
53
- links
48
+ link_to('View Receipt', effective_orders.order_path(order), class: 'member_link view_link') if order.purchased?
54
49
  end
55
- end
56
50
 
57
- member_action :details do
58
- @order = Effective::Order.find(params[:id])
59
- @page_title = "Order ##{@order.to_param} Details"
60
-
61
- render file: 'admin/orders/show'
62
51
  end
63
52
 
64
53
  collection_action :export_csv do
65
54
  @orders = Effective::Order.purchased.includes(:addresses)
66
55
 
67
56
  col_headers = []
68
- col_headers << "Order ID"
57
+ col_headers << "Order"
58
+ col_headers << "Purchased at"
59
+ col_headers << "Email"
69
60
  col_headers << "Full Name"
70
- col_headers << "Purchased"
71
61
  col_headers << "Subtotal"
72
62
  col_headers << "Tax"
73
63
  col_headers << "Total"
64
+ col_headers << 'Purchase method'
74
65
 
75
66
  csv_string = CSV.generate do |csv|
76
67
  csv << col_headers
77
68
 
78
69
  @orders.each do |order|
79
- row = []
80
-
81
- row << order.to_param
82
- row << (order.billing_address.try(:full_name) || order.user.to_s)
83
- row << order.purchased_at.strftime("%Y-%m-%d %H:%M:%S %z")
84
- row << (order.subtotal / 100.0).round(2)
85
- row << (order.tax / 100.0).round(2)
86
- row << (order.total / 100.0).round(2)
87
-
88
- csv << row
70
+ csv << [
71
+ order.to_param,
72
+ order.purchased_at.strftime("%Y-%m-%d %H:%M:%S %z"),
73
+ order.user.try(:email),
74
+ (order.billing_address.try(:full_name) || order.user.to_s),
75
+ (order.subtotal / 100.0).round(2),
76
+ (order.tax / 100.0).round(2),
77
+ (order.total / 100.0).round(2),
78
+ order.purchase_method
79
+ ]
89
80
  end
90
81
  end
91
82
 
@@ -1,7 +1,6 @@
1
1
  module Effective
2
2
  class CartsController < ApplicationController
3
3
  include EffectiveCartsHelper
4
- acts_as_active_admin_controller('carts') if EffectiveOrders.use_active_admin?
5
4
 
6
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:carts] : EffectiveOrders.layout)
7
6
 
@@ -1,7 +1,6 @@
1
1
  module Effective
2
2
  class OrdersController < ApplicationController
3
3
  include EffectiveCartsHelper
4
- acts_as_active_admin_controller('orders') if EffectiveOrders.use_active_admin?
5
4
 
6
5
  include Providers::Moneris if EffectiveOrders.moneris_enabled
7
6
  include Providers::Paypal if EffectiveOrders.paypal_enabled
@@ -103,6 +103,10 @@ module ActsAsPurchasable
103
103
  orders.select { |order| order.purchased? }
104
104
  end
105
105
 
106
+ def purchased_order
107
+ purchased_orders.first
108
+ end
109
+
106
110
  def quantity_enabled?
107
111
  self.respond_to?(:quantity_enabled) ? quantity_enabled == true : false
108
112
  end
@@ -238,6 +238,22 @@ module Effective
238
238
  end
239
239
  end
240
240
 
241
+ def purchase_method
242
+ if purchased?(:stripe_connect)
243
+ 'Stripe Connect'
244
+ elsif purchased?(:stripe)
245
+ 'Stripe'
246
+ elsif purchased?(:moneris)
247
+ 'Moneris'
248
+ elsif purchased?(:paypal)
249
+ 'PayPal'
250
+ elsif purchased?
251
+ 'Online'
252
+ else
253
+ 'None'
254
+ end
255
+ end
256
+
241
257
  def purchased?(provider = nil)
242
258
  return false if (purchase_state != EffectiveOrders::PURCHASED)
243
259
  return true if provider == nil
@@ -1,4 +1,4 @@
1
- %h2 Customers
1
+ %h2.effective-orders-page-title Customers
2
2
 
3
3
  %p.text-right= link_to 'Stripe Dashboard: Customers', 'https://manage.stripe.com/customers', :class => 'btn btn-primary'
4
4
 
@@ -1,4 +1,4 @@
1
- %h2 Order Items
1
+ %h2.effective-orders-page-title Order Items
2
2
 
3
3
  - if @datatable.nil?
4
4
  %p
@@ -1,4 +1,4 @@
1
- %h2 Orders
1
+ %h2.effective-orders-page-title Orders
2
2
 
3
3
  - if @datatable.nil?
4
4
  %p
@@ -1,2 +1,3 @@
1
- = render :partial => 'effective/orders/order', :locals => {:order => @order}
2
- = render :partial => 'effective/orders/order_payment_details', :locals => {:order => @order}
1
+ %h2.effective-orders-page-title= (@order.purchased? ? 'Receipt' : 'Order')
2
+
3
+ = render @order
@@ -1,4 +1,4 @@
1
- %h2 Shopping Cart
1
+ %h2.effective-orders-page-title Shopping Cart
2
2
 
3
3
  - if @cart.empty?
4
4
  %p Your cart is empty.
@@ -5,3 +5,6 @@
5
5
  = render partial: 'effective/orders/order_header', locals: {order: order}
6
6
  = render partial: 'effective/orders/order_shipping', locals: {order: order}
7
7
  = render partial: 'effective/orders/order_items', locals: {order: order}
8
+
9
+ - if (EffectiveOrders.authorized?(controller, :manage, Effective::Order) rescue false)
10
+ = render partial: 'effective/orders/order_payment_details', locals: {order: order}
@@ -1,4 +1,5 @@
1
1
  - if order.purchased?
2
- %p.pull-right
3
- = link_to 'Print', '#', :class => 'btn btn-default print-button', 'data-role' => 'print-button', :onClick => "window.print(); false;"
4
- = link_to 'Resend Receipt', effective_orders.resend_buyer_receipt_path(order), :data => {'confirm' => 'This action will email you a copy of the original email receipt. Send receipt now?', 'disable_with' => 'Resending...'}, :class => 'btn btn-default'
2
+ .effective-order-actions.pull-right
3
+ %p
4
+ = link_to 'Print', '#', :class => 'btn btn-default print-button', 'data-role' => 'print-button', :onClick => "window.print(); false;"
5
+ = link_to 'Resend Receipt', effective_orders.resend_buyer_receipt_path(order), :data => {'confirm' => 'This action will email you a copy of the original email receipt. Send receipt now?', 'disable_with' => 'Resending...'}, :class => 'btn btn-default'
@@ -1,21 +1,22 @@
1
- %h3 Acme Industries Inc.
2
- .row
3
- .col-sm-6
4
- %p= mail_to EffectiveOrders.mailer[:admin_email] || 'info@acmeindustries.com'
5
- %p
6
- 1234 Fake Street
7
- %br
8
- Edmonton, AB, T5H 4A5
9
- %br
10
- %small Customize me by overriding '/app/views/effective/orders/_order_header.html.haml'
1
+ .effective-order-header
2
+ %h3 Acme Industries Inc.
3
+ .row
4
+ .col-sm-6
5
+ %p= mail_to EffectiveOrders.mailer[:admin_email] || 'info@acmeindustries.com'
6
+ %p
7
+ 1234 Fake Street
8
+ %br
9
+ Edmonton, AB, T5H 4A5
10
+ %br
11
+ %small Customize me by overriding '/app/views/effective/orders/_order_header.html.haml'
11
12
 
12
- .col-sm-6
13
- - if order.purchased?
14
- %p Receipt: ##{order.to_param}
15
- - elsif order.persisted?
16
- %p Order: ##{order.to_param}
13
+ .col-sm-6
14
+ - if order.purchased?
15
+ %p Receipt: ##{order.to_param}
16
+ - elsif order.persisted?
17
+ %p Order: ##{order.to_param}
17
18
 
18
- - if order.purchased?
19
- %p Purchased at: #{order.purchased_at.strftime("%Y-%m-%d %H:%M")}
20
- - else
21
- %p Date: #{Time.zone.now.strftime("%Y-%m-%d %H:%M")}
19
+ - if order.purchased?
20
+ %p Purchased at: #{order.purchased_at.strftime("%Y-%m-%d %H:%M")}
21
+ - else
22
+ %p Date: #{Time.zone.now.strftime("%Y-%m-%d %H:%M")}
@@ -1,12 +1,10 @@
1
- %h4 Payment Details
2
-
3
1
  - if order.payment.present?
4
- - if order.purchased?
5
- %p This order was purchased with the following details:
6
- - elsif order.declined?
7
- %p This order was declined with the following details:
2
+ .effective-order-payment-details
3
+ %h4 Payment Details
8
4
 
9
- = tableize_hash(order.payment)
5
+ - if order.purchased?
6
+ %p This order was purchased with the following details:
7
+ - elsif order.declined?
8
+ %p This order was declined with the following details:
10
9
 
11
- - else
12
- %p No payment details present
10
+ = tableize_hash(order.payment)
@@ -1,21 +1,22 @@
1
- %table.table{:style => 'width: 600px;margin-bottom:25px;'}
2
- %thead
3
- %tr
4
- %th{:style => 'text-align: left;'}= "#{order.purchased? ? 'Sold to' : 'Bill to'}"
5
- - if order.shipping_address.present? && !order.shipping_address.empty?
6
- %th{:style => 'text-align: left;'} Ship to
1
+ .effective-order-shipping
2
+ %table.table{:style => 'width: 600px;margin-bottom:25px;'}
3
+ %thead
4
+ %tr
5
+ %th{:style => 'text-align: left;'}= "#{order.purchased? ? 'Sold to' : 'Bill to'}"
6
+ - if order.shipping_address.present? && !order.shipping_address.empty?
7
+ %th{:style => 'text-align: left;'} Ship to
7
8
 
8
- %tbody
9
- %tr
10
- %td{:style => 'text-align: left;'}
11
- - if order.billing_address.present? && !order.billing_address.empty?
12
- = render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => order.user.email}
13
- - else
14
- = order.billing_name
15
- %br
16
- = mail_to(order.user.email)
17
- %br
18
-
19
- - if order.shipping_address.present? && !order.shipping_address.empty?
9
+ %tbody
10
+ %tr
20
11
  %td{:style => 'text-align: left;'}
21
- = render :partial => 'effective/addresses/address', :locals => {:address => order.shipping_address}
12
+ - if order.billing_address.present? && !order.billing_address.empty?
13
+ = render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => order.user.email}
14
+ - else
15
+ = order.billing_name
16
+ %br
17
+ = mail_to(order.user.email)
18
+ %br
19
+
20
+ - if order.shipping_address.present? && !order.shipping_address.empty?
21
+ %td{:style => 'text-align: left;'}
22
+ = render :partial => 'effective/addresses/address', :locals => {:address => order.shipping_address}
@@ -1,3 +1,3 @@
1
- %h2 Checkout
1
+ %h2.effective-orders-page-title Checkout
2
2
 
3
3
  = render_checkout(@order)
@@ -1,4 +1,4 @@
1
- %h2 Payment Declined
1
+ %h2.effective-orders-page-title Payment Declined
2
2
 
3
3
  %p Your #{link_to_current_cart(label: 'Shopping Cart')} items have been saved. Please try again.
4
4
 
@@ -1,3 +1,3 @@
1
- %h2 Order History
1
+ %h2.effective-orders-page-title Order History
2
2
 
3
3
  = render_order_history(@orders)
@@ -1,4 +1,4 @@
1
- %h2 My Sales
1
+ %h2.effective-orders-page-title My Sales
2
2
 
3
3
  %table.table
4
4
  %thead
@@ -1,4 +1,4 @@
1
- %h2 Checkout
1
+ %h2.effective-orders-page-title Checkout
2
2
 
3
3
  = render_checkout(@order)
4
4
 
@@ -1,4 +1,4 @@
1
- %h2 Thank You
1
+ %h2.effective-orders-page-title Thank You
2
2
 
3
3
  %p You have successfully purchased the following:
4
4
 
@@ -1,5 +1,3 @@
1
- %h2= (@order.purchased? ? 'Receipt' : 'Order')
1
+ %h2.effective-orders-page-title= (@order.purchased? ? 'Receipt' : 'Order')
2
2
 
3
3
  = render @order
4
-
5
-
@@ -1,4 +1,4 @@
1
- %h2 My Subscriptions
1
+ %h2.effective-orders-page-title My Subscriptions
2
2
 
3
3
  - if @subscriptions.present?
4
4
  %p You have the following subscriptions:
@@ -1,4 +1,4 @@
1
- %h2 New Subscription
1
+ %h2.effective-orders-page-title New Subscription
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
1
+ %h2.effective-orders-page-title
2
2
  = @plan.name
3
3
  Subscription
4
4
  details
@@ -44,12 +44,16 @@ module EffectiveOrders
44
44
  initializer 'effective_orders.active_admin' do
45
45
  if EffectiveOrders.use_active_admin?
46
46
  require 'activeadmin'
47
+ ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
47
48
 
48
- ActiveSupport.on_load :action_controller do
49
- ApplicationController.extend(ActsAsActiveAdminController::ActionController)
49
+ Rails.application.config.to_prepare do
50
+ ActiveSupport.on_load :action_controller do
51
+ ApplicationController.extend(ActsAsActiveAdminController::ActionController)
52
+ Effective::OrdersController.send(:acts_as_active_admin_controller, 'orders')
53
+ Effective::CartsController.send(:acts_as_active_admin_controller, 'carts')
54
+ end
50
55
  end
51
56
 
52
- ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
53
57
  end
54
58
  end
55
59
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '1.5.2'.freeze
2
+ VERSION = '1.5.3'.freeze
3
3
  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: 1.5.2
4
+ version: 1.5.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: 2015-10-20 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails