effective_orders 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active_admin/effective_carts.rb +14 -0
- data/active_admin/effective_orders.rb +95 -0
- data/lib/effective_orders/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f4d410052692513e6d97431511392a842f90fd
|
4
|
+
data.tar.gz: 0b76a1f812247ea785443054d58b490b63ba8cf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c19301b8f074a34edd09e605b659ec43e1e5e9a0f51543f9dee0b8766eb395f58f7f3b12b435f498c4c5af2746924700db652e82b90e9aeefcb5d000bc424a
|
7
|
+
data.tar.gz: 8fa3a64a12f9d8ff24c354ba17373c048381d60c4b0af744b7a9803a630b0963099fe55ce5ec8e0709ad2c4473bcec7676ce5ace06e65643e879319f9b82f55a
|
@@ -0,0 +1,14 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
ActiveAdmin.register Effective::Cart, namespace: EffectiveOrders.active_admin_namespace, as: 'Carts' do
|
3
|
+
menu label: 'My Cart', if: proc { (authorized?(:manage, Effective::Cart.new(user: current_user)) rescue false) }
|
4
|
+
|
5
|
+
actions :index
|
6
|
+
|
7
|
+
controller do
|
8
|
+
def index
|
9
|
+
redirect_to(effective_orders.cart_path)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
require 'csv'
|
3
|
+
|
4
|
+
ActiveAdmin.register Effective::Order, namespace: EffectiveOrders.active_admin_namespace, as: 'Orders' do
|
5
|
+
menu label: 'Orders', if: proc { (authorized?(:manage, Effective::Order.new(user: current_user)) rescue false) }
|
6
|
+
|
7
|
+
actions :index
|
8
|
+
|
9
|
+
filter :id, label: 'Order Number'
|
10
|
+
filter :user
|
11
|
+
filter :created_at, label: 'Order Date'
|
12
|
+
filter :payment
|
13
|
+
|
14
|
+
scope :purchased, default: true do |objs| objs.purchased end
|
15
|
+
scope :all
|
16
|
+
|
17
|
+
controller do
|
18
|
+
include EffectiveOrdersHelper
|
19
|
+
|
20
|
+
def scoped_collection
|
21
|
+
end_of_association_chain.includes(:user).includes(:order_items => :purchasable)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
sidebar :export, :only => :index do
|
26
|
+
export_csv_path = ['export_csv', EffectiveOrders.active_admin_namespace.presence, 'orders_path'].compact.join('_')
|
27
|
+
link_to "Export Orders to .csv", public_send(export_csv_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
index :download_links => false do
|
31
|
+
column 'Order', :sortable => :id do |order|
|
32
|
+
link_to "##{order.to_param}", effective_orders.order_path(order)
|
33
|
+
end
|
34
|
+
|
35
|
+
column 'Buyer', :sortable => :user_id do |order|
|
36
|
+
link_to order.user, (admin_user_path(order.user) rescue '#')
|
37
|
+
end
|
38
|
+
|
39
|
+
column 'Summary' do |order|
|
40
|
+
order_summary(order)
|
41
|
+
end
|
42
|
+
|
43
|
+
column :purchased_at
|
44
|
+
|
45
|
+
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
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
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
|
+
end
|
63
|
+
|
64
|
+
collection_action :export_csv do
|
65
|
+
@orders = Effective::Order.purchased
|
66
|
+
|
67
|
+
col_headers = []
|
68
|
+
col_headers << "Order ID"
|
69
|
+
col_headers << "Full Name"
|
70
|
+
col_headers << "Purchased"
|
71
|
+
col_headers << "Subtotal"
|
72
|
+
col_headers << "Tax"
|
73
|
+
col_headers << "Total"
|
74
|
+
|
75
|
+
csv_string = CSV.generate do |csv|
|
76
|
+
csv << col_headers
|
77
|
+
|
78
|
+
@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 << "%.2f" % order.subtotal
|
85
|
+
row << "%.2f" % order.tax
|
86
|
+
row << "%.2f" % order.total
|
87
|
+
|
88
|
+
csv << row
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
send_data(csv_string, :type => 'text/csv; charset=utf-8; header=present', :filename => "orders-export.csv")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
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.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -315,6 +315,8 @@ files:
|
|
315
315
|
- MIT-LICENSE
|
316
316
|
- README.md
|
317
317
|
- Rakefile
|
318
|
+
- active_admin/effective_carts.rb
|
319
|
+
- active_admin/effective_orders.rb
|
318
320
|
- app/assets/images/effective_orders/stripe_connect.png
|
319
321
|
- app/assets/javascripts/effective_orders.js
|
320
322
|
- app/assets/javascripts/effective_orders/shipping_address_toggle.js.coffee
|