caboose-cms 0.9.156 → 0.9.157
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/caboose/products_controller.rb +26 -0
- data/app/controllers/caboose/users_controller.rb +24 -0
- data/app/models/caboose/export.rb +131 -0
- data/app/models/caboose/schema.rb +8 -0
- data/app/views/caboose/products/admin_index.html.erb +12 -0
- data/app/views/caboose/users/admin_index.html.erb +12 -0
- data/lib/caboose/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f5a7e9e214441b71ce612eb074dfa401fa024a4
|
4
|
+
data.tar.gz: 73da71240fc3557622a2359b720cab2c7bf8a2a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11553d99e7aae3dc810a28abb19f46ce9e5004e9efbc1668f51113bc3f86c7f57826ec150e950edc591b8bdc014434ad045fc1c1542dfa53ce23f241eb059f58
|
7
|
+
data.tar.gz: 43ea2e64b89c1bc18593c04e7ad86a09d7d0619e3c8e35ef572160afd889939ea8aae567eda9b4bd7f513c0d87edef4efa6a587c98f7700059eab3515177e218
|
@@ -304,6 +304,32 @@ module Caboose
|
|
304
304
|
p = Product.find(params[:id])
|
305
305
|
render :json => p
|
306
306
|
end
|
307
|
+
|
308
|
+
|
309
|
+
# @route GET /admin/products/exports/:id/json
|
310
|
+
def admin_export_single
|
311
|
+
return unless (user_is_allowed_to 'edit', 'products')
|
312
|
+
e = Caboose::Export.where(:id => params[:id]).first
|
313
|
+
render :json => e
|
314
|
+
end
|
315
|
+
|
316
|
+
# @route POST /admin/products/export
|
317
|
+
def admin_export
|
318
|
+
return unless (user_is_allowed_to 'edit', 'products')
|
319
|
+
resp = Caboose::StdClass.new
|
320
|
+
e = Caboose::Export.create(
|
321
|
+
:kind => 'products',
|
322
|
+
:date_created => DateTime.now.utc,
|
323
|
+
:params => params.to_json,
|
324
|
+
:status => 'pending'
|
325
|
+
)
|
326
|
+
e.delay(:queue => 'caboose_general', :priority => 8).product_process if Rails.env.production?
|
327
|
+
e.product_process if Rails.env.development?
|
328
|
+
resp.new_id = e.id
|
329
|
+
resp.success = true
|
330
|
+
render :json => resp
|
331
|
+
end
|
332
|
+
|
307
333
|
|
308
334
|
# @route GET /admin/products/:id
|
309
335
|
# @route GET /admin/products/:id/general
|
@@ -95,6 +95,30 @@ module Caboose
|
|
95
95
|
@all_roles = Role.tree(@site.id)
|
96
96
|
@roles = Role.roles_with_user(@edituser.id)
|
97
97
|
end
|
98
|
+
|
99
|
+
# @route GET /admin/users/exports/:id/json
|
100
|
+
def admin_export_single
|
101
|
+
return unless (user_is_allowed_to 'edit', 'users')
|
102
|
+
e = Caboose::Export.where(:id => params[:id]).first
|
103
|
+
render :json => e
|
104
|
+
end
|
105
|
+
|
106
|
+
# @route POST /admin/users/export
|
107
|
+
def admin_export
|
108
|
+
return unless (user_is_allowed_to 'edit', 'users')
|
109
|
+
resp = Caboose::StdClass.new
|
110
|
+
e = Caboose::Export.create(
|
111
|
+
:kind => 'users',
|
112
|
+
:date_created => DateTime.now.utc,
|
113
|
+
:params => params.to_json,
|
114
|
+
:status => 'pending'
|
115
|
+
)
|
116
|
+
e.delay(:queue => 'caboose_general', :priority => 8).user_process if Rails.env.production?
|
117
|
+
e.user_process if Rails.env.development?
|
118
|
+
resp.new_id = e.id
|
119
|
+
resp.success = true
|
120
|
+
render :json => resp
|
121
|
+
end
|
98
122
|
|
99
123
|
# @route GET /admin/users/:id/payment-method
|
100
124
|
def admin_edit_payment_method
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'aws'
|
2
|
+
|
3
|
+
module Caboose
|
4
|
+
class Export < ActiveRecord::Base
|
5
|
+
self.table_name = 'exports'
|
6
|
+
|
7
|
+
attr_accessible :id ,
|
8
|
+
:kind,
|
9
|
+
:date_created,
|
10
|
+
:date_processed,
|
11
|
+
:params,
|
12
|
+
:status
|
13
|
+
|
14
|
+
STATUS_PENDING = 'pending'
|
15
|
+
STATUS_PROCESSING = 'processing'
|
16
|
+
STATUS_FINISHED = 'finished'
|
17
|
+
|
18
|
+
def product_process
|
19
|
+
self.kind = 'products'
|
20
|
+
self.status = 'processing'
|
21
|
+
self.save
|
22
|
+
pager = Caboose::Pager.new(JSON.parse(self.params), {
|
23
|
+
'site_id' => params['site_id'],
|
24
|
+
'vendor_name' => '',
|
25
|
+
'search_like' => '',
|
26
|
+
'category_id' => '',
|
27
|
+
'category_name' => '',
|
28
|
+
'vendor_id' => '',
|
29
|
+
'vendor_status' => '',
|
30
|
+
'price_gte' => '',
|
31
|
+
'price_lte' => '',
|
32
|
+
'variant_status' => '',
|
33
|
+
'price' => params['filters'] && params['filters']['missing_prices'] ? 0 : ''
|
34
|
+
}, {
|
35
|
+
'model' => 'Caboose::Product',
|
36
|
+
'sort' => 'title',
|
37
|
+
'desc' => false,
|
38
|
+
'base_url' => '/admin/products',
|
39
|
+
'items_per_page' => 25,
|
40
|
+
'use_url_params' => false,
|
41
|
+
|
42
|
+
'abbreviations' => {
|
43
|
+
'search_like' => 'store_products.title_concat_vendor_name_like'
|
44
|
+
},
|
45
|
+
|
46
|
+
'includes' => {
|
47
|
+
'category_id' => [ 'categories' , 'id' ],
|
48
|
+
'category_name' => [ 'categories' , 'name' ],
|
49
|
+
'vendor_id' => [ 'vendor' , 'id' ],
|
50
|
+
'vendor_name' => [ 'vendor' , 'name' ],
|
51
|
+
'vendor_status' => [ 'vendor' , 'status' ],
|
52
|
+
'price_gte' => [ 'variants' , 'price' ],
|
53
|
+
'price_lte' => [ 'variants' , 'price' ],
|
54
|
+
'price' => [ 'variants' , 'price' ],
|
55
|
+
'variant_status' => [ 'variants' , 'status' ]
|
56
|
+
}
|
57
|
+
})
|
58
|
+
str = ''
|
59
|
+
headers = ['ID','Title','Caption','Status','Vendor','URL Handle','Description','Variant Status','Variant Alternate ID','Variant SKU','Variant Price','Variant Quantity']
|
60
|
+
str = CSV.generate_line(headers, :quote_char => '"')
|
61
|
+
pager.items.each do |a|
|
62
|
+
var = a.most_popular_variant
|
63
|
+
arr = [
|
64
|
+
a.id.to_s,
|
65
|
+
(a.title ? a.title : ''),
|
66
|
+
(a.caption ? a.caption : ''),
|
67
|
+
(a.status ? a.status : ''),
|
68
|
+
(a.vendor ? a.vendor.name : ''),
|
69
|
+
(a.handle ? a.handle : ''),
|
70
|
+
(a.description ? a.description : ''),
|
71
|
+
(var ? var.status : ''),
|
72
|
+
(var ? var.alternate_id : ''),
|
73
|
+
(var ? var.sku : ''),
|
74
|
+
(var ? var.price : ''),
|
75
|
+
(var ? var.quantity : '')
|
76
|
+
]
|
77
|
+
str += CSV.generate_line(arr, :quote_char => '"')
|
78
|
+
end
|
79
|
+
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
80
|
+
AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
|
81
|
+
bucket = AWS::S3::Bucket.new(config['bucket'])
|
82
|
+
file = bucket.objects["assets/product_exports/#{self.id}.csv"]
|
83
|
+
file.write(str, :content_type => "text/csv", :content_disposition => 'attachment; filename=products.csv')
|
84
|
+
self.date_processed = DateTime.now.utc
|
85
|
+
self.status = 'finished'
|
86
|
+
self.save
|
87
|
+
end
|
88
|
+
|
89
|
+
def user_process
|
90
|
+
self.kind = 'users'
|
91
|
+
self.status = 'processing'
|
92
|
+
self.save
|
93
|
+
pager = Caboose::Pager.new(JSON.parse(self.params), {
|
94
|
+
'site_id' => params['site_id'],
|
95
|
+
'first_name_like' => '',
|
96
|
+
'last_name_like' => '',
|
97
|
+
'username_like' => '',
|
98
|
+
'email_like' => '',
|
99
|
+
},{
|
100
|
+
'model' => 'Caboose::User',
|
101
|
+
'sort' => 'last_name, first_name',
|
102
|
+
'desc' => false,
|
103
|
+
'base_url' => '/admin/users',
|
104
|
+
'use_url_params' => false
|
105
|
+
})
|
106
|
+
str = ''
|
107
|
+
headers = ['ID','First Name','Last Name','Username','Email','Phone']
|
108
|
+
str = CSV.generate_line(headers, :quote_char => '"')
|
109
|
+
pager.items.each do |a|
|
110
|
+
arr = [
|
111
|
+
a.id.to_s,
|
112
|
+
(a.first_name ? a.first_name : ''),
|
113
|
+
(a.last_name ? a.last_name : ''),
|
114
|
+
(a.username ? a.username : ''),
|
115
|
+
(a.email ? a.email : ''),
|
116
|
+
(a.phone ? a.phone : '')
|
117
|
+
]
|
118
|
+
str += CSV.generate_line(arr, :quote_char => '"')
|
119
|
+
end
|
120
|
+
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
|
121
|
+
AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
|
122
|
+
bucket = AWS::S3::Bucket.new(config['bucket'])
|
123
|
+
file = bucket.objects["assets/user_exports/#{self.id}.csv"]
|
124
|
+
file.write(str, :content_type => "text/csv", :content_disposition => 'attachment; filename=users.csv')
|
125
|
+
self.date_processed = DateTime.now.utc
|
126
|
+
self.status = 'finished'
|
127
|
+
self.save
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
@@ -305,6 +305,14 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
305
305
|
[ :force_ssl , :boolean, { :default => false }],
|
306
306
|
[ :forward_to_uri , :string ]
|
307
307
|
],
|
308
|
+
Caboose::Export => [
|
309
|
+
[ :id, :integer ],
|
310
|
+
[ :kind, :string ],
|
311
|
+
[ :date_created, :datetime ],
|
312
|
+
[ :date_processed, :datetime ],
|
313
|
+
[ :params, :text ],
|
314
|
+
[ :status, :string ]
|
315
|
+
],
|
308
316
|
Caboose::Font => [
|
309
317
|
[ :site_id , :integer ],
|
310
318
|
[ :name , :string ],
|
@@ -51,6 +51,18 @@ $(document).ready(function() {
|
|
51
51
|
allow_duplicate: false,
|
52
52
|
allow_advanced_edit: true,
|
53
53
|
after_add: 'redirect',
|
54
|
+
allow_export: true,
|
55
|
+
exports: [
|
56
|
+
{
|
57
|
+
name: 'All Fields',
|
58
|
+
url: "/admin/products/export",
|
59
|
+
type: 'post',
|
60
|
+
wait_for_processing: true,
|
61
|
+
status_url: function(resp) { return "/admin/products/exports/" + resp.new_id + "/json"; },
|
62
|
+
ready: function(resp) { return resp.status == 'finished'; },
|
63
|
+
final_url: function(resp) { return "https://cabooseit.s3.amazonaws.com/assets/product_exports/" + resp.id + ".csv"; }
|
64
|
+
},
|
65
|
+
],
|
54
66
|
fields: [
|
55
67
|
{ show: true , name: 'id' , nice_name: 'ID' , sort: 'id' , type: 'text' , value: function(p) { return p.id }, width: 500, editable: false },
|
56
68
|
{ show: true , name: 'image' , nice_name: 'Image' , sort: 'id' , type: 'image' , value: tiny_product_image, width: 500, editable: false },
|
@@ -16,6 +16,18 @@ $(document).ready(function() {
|
|
16
16
|
allow_bulk_delete: true,
|
17
17
|
allow_duplicate: false,
|
18
18
|
allow_advanced_edit: true,
|
19
|
+
allow_export: true,
|
20
|
+
exports: [
|
21
|
+
{
|
22
|
+
name: 'All Fields',
|
23
|
+
url: "/admin/users/export",
|
24
|
+
type: 'post',
|
25
|
+
wait_for_processing: true,
|
26
|
+
status_url: function(resp) { return "/admin/users/exports/" + resp.new_id + "/json"; },
|
27
|
+
ready: function(resp) { return resp.status == 'finished'; },
|
28
|
+
final_url: function(resp) { return "https://cabooseit.s3.amazonaws.com/assets/user_exports/" + resp.id + ".csv"; }
|
29
|
+
},
|
30
|
+
],
|
19
31
|
fields: [
|
20
32
|
{ show: true , bulk_edit: true , name: 'first_name' , nice_name: 'First name' , sort: 'first_name' , type: 'text' , value: function(u) { return u.first_name }, width: 100 },
|
21
33
|
{ show: true , bulk_edit: true , name: 'last_name' , nice_name: 'Last name' , sort: 'last_name' , type: 'text' , value: function(u) { return u.last_name }, width: 100 },
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.157
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
@@ -797,6 +797,7 @@ files:
|
|
797
797
|
- app/models/caboose/domain_constraint.rb
|
798
798
|
- app/models/caboose/event_custom_field.rb
|
799
799
|
- app/models/caboose/event_custom_field_value.rb
|
800
|
+
- app/models/caboose/export.rb
|
800
801
|
- app/models/caboose/font.rb
|
801
802
|
- app/models/caboose/font_family.rb
|
802
803
|
- app/models/caboose/font_variant.rb
|