caboose-cms 0.5.64 → 0.5.66
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin.js +1 -1
- data/app/assets/javascripts/caboose/admin_edit_order.js +724 -0
- data/app/assets/javascripts/caboose/cart2.js +4 -4
- data/app/assets/javascripts/caboose/model/index_table.js +122 -80
- data/app/assets/stylesheets/caboose/admin_main.css +8 -0
- data/app/controllers/caboose/application_controller.rb +1 -1
- data/app/controllers/caboose/block_type_sources_controller.rb +1 -1
- data/app/controllers/caboose/block_types_controller.rb +1 -1
- data/app/controllers/caboose/calendars_controller.rb +1 -1
- data/app/controllers/caboose/cart_controller.rb +8 -1
- data/app/controllers/caboose/checkout_controller.rb +17 -9
- data/app/controllers/caboose/line_items_controller.rb +135 -0
- data/app/controllers/caboose/order_packages_controller.rb +304 -0
- data/app/controllers/caboose/orders_controller.rb +31 -74
- data/app/controllers/caboose/pages_controller.rb +2 -1
- data/app/controllers/caboose/product_images_controller.rb +11 -0
- data/app/controllers/caboose/products_controller.rb +25 -8
- data/app/controllers/caboose/shipping_addresses_controller.rb +46 -0
- data/app/controllers/caboose/shipping_packages_controller.rb +125 -54
- data/app/controllers/caboose/sites_controller.rb +2 -79
- data/app/controllers/caboose/smtp_controller.rb +52 -0
- data/app/controllers/caboose/store_controller.rb +94 -0
- data/app/controllers/caboose/vendors_controller.rb +25 -4
- data/app/models/caboose/address.rb +1 -3
- data/app/models/caboose/caboose_plugin.rb +1 -1
- data/app/models/caboose/category.rb +18 -0
- data/app/models/caboose/core_plugin.rb +21 -19
- data/app/models/caboose/order.rb +12 -7
- data/app/models/caboose/order_package.rb +5 -2
- data/app/models/caboose/order_transaction.rb +25 -0
- data/app/models/caboose/page.rb +1 -1
- data/app/models/caboose/schema.rb +50 -22
- data/app/models/caboose/shipping_calculator.rb +26 -30
- data/app/models/caboose/shipping_package.rb +45 -5
- data/app/models/caboose/store_config.rb +18 -6
- data/app/models/caboose/tax_calculator.rb +6 -5
- data/app/views/caboose/blocks/admin_edit.html.erb +1 -1
- data/app/views/caboose/line_items/admin_new.html.erb +100 -0
- data/app/views/caboose/orders/admin_edit.html.erb +21 -247
- data/app/views/caboose/orders/admin_edit_old.html.erb +155 -0
- data/app/views/caboose/orders/admin_new.html.erb +8 -23
- data/app/views/caboose/products/#Untitled-1# +0 -0
- data/app/views/caboose/products/admin_edit_images.html.erb +20 -4
- data/app/views/caboose/products/admin_index.html.erb +9 -3
- data/app/views/caboose/products/admin_sort.html.erb +138 -142
- data/app/views/caboose/roles/index.html.erb +1 -1
- data/app/views/caboose/shipping_packages/admin_edit.html.erb +52 -137
- data/app/views/caboose/shipping_packages/admin_index.html.erb +56 -19
- data/app/views/caboose/sites/_admin_header.html.erb +3 -5
- data/app/views/caboose/sites/admin_edit.html.erb +5 -3
- data/app/views/caboose/smtp/admin_edit.html.erb +41 -0
- data/app/views/caboose/station/index.html.erb +1 -1
- data/app/views/caboose/store/admin_edit.html.erb +96 -0
- data/app/views/caboose/vendors/admin_edit.html.erb +7 -3
- data/app/views/layouts/caboose/_station.html.erb +1 -1
- data/config/routes.rb +67 -25
- data/lib/caboose/engine.rb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +28 -5
- data/app/views/caboose/shipping_packages/admin_new.html.erb +0 -33
- data/app/views/caboose/sites/admin_edit_smtp_config.html.erb +0 -51
- data/app/views/caboose/sites/admin_edit_store_config.html.erb +0 -77
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Caboose
|
4
|
+
class SmtpController < ApplicationController
|
5
|
+
layout 'caboose/admin'
|
6
|
+
|
7
|
+
# GET /admin/smtp
|
8
|
+
def admin_edit
|
9
|
+
return if !user_is_allowed('smtp', 'edit')
|
10
|
+
@smtp_config = @site.smtp_config
|
11
|
+
@smtp_config = SmtpConfig.create(:site_id => @site.id) if @smtp_config.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
# PUT /admin/smtp
|
15
|
+
def admin_update
|
16
|
+
return if !user_is_allowed('sites', 'edit')
|
17
|
+
|
18
|
+
resp = StdClass.new
|
19
|
+
sc = @site.smtp_config
|
20
|
+
sc = SmtpConfig.create(:site_id => @site.id) if sc.nil?
|
21
|
+
|
22
|
+
save = true
|
23
|
+
params.each do |name,value|
|
24
|
+
case name
|
25
|
+
when 'site_id' then sc.site_id = value
|
26
|
+
when 'address' then sc.address = value
|
27
|
+
when 'port' then sc.port = value
|
28
|
+
when 'domain' then sc.domain = value
|
29
|
+
when 'user_name' then sc.user_name = value
|
30
|
+
when 'password' then sc.password = value
|
31
|
+
when 'authentication' then sc.authentication = value
|
32
|
+
when 'enable_starttls_auto' then sc.enable_starttls_auto = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
resp.success = save && sc.save
|
37
|
+
render :json => resp
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET /admin/smtp/auth-options
|
41
|
+
def auth_options
|
42
|
+
return if !user_is_allowed('smtp', 'view')
|
43
|
+
options = [
|
44
|
+
{ 'value' => SmtpConfig::AUTH_PLAIN , 'text' => SmtpConfig::AUTH_PLAIN },
|
45
|
+
{ 'value' => SmtpConfig::AUTH_LOGIN , 'text' => SmtpConfig::AUTH_LOGIN },
|
46
|
+
{ 'value' => SmtpConfig::AUTH_MD5 , 'text' => SmtpConfig::AUTH_MD5 }
|
47
|
+
]
|
48
|
+
render :json => options
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Caboose
|
4
|
+
class StoreController < ApplicationController
|
5
|
+
layout 'caboose/admin'
|
6
|
+
|
7
|
+
# GET /admin/store
|
8
|
+
def admin_edit
|
9
|
+
return if !user_is_allowed('sites', 'edit')
|
10
|
+
@store_config = @site.store_config
|
11
|
+
@store_config = StoreConfig.create(:site_id => @site.id) if @store_config.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
# PUT /admin/store
|
15
|
+
def admin_update
|
16
|
+
return if !user_is_allowed('sites', 'edit')
|
17
|
+
|
18
|
+
resp = StdClass.new
|
19
|
+
sc = @site.store_config
|
20
|
+
sc = StoreConfig.create(:site_id => @site.id) if sc.nil?
|
21
|
+
|
22
|
+
save = true
|
23
|
+
params.each do |name,value|
|
24
|
+
case name
|
25
|
+
when 'site_id' then sc.site_id = value
|
26
|
+
when 'pp_name' then sc.pp_name = value
|
27
|
+
when 'pp_username' then sc.pp_username = value
|
28
|
+
when 'pp_password' then sc.pp_password = value
|
29
|
+
when 'ups_username' then sc.ups_username = value
|
30
|
+
when 'ups_password' then sc.ups_password = value
|
31
|
+
when 'ups_key' then sc.ups_key = value
|
32
|
+
when 'ups_origin_account' then sc.ups_origin_account = value
|
33
|
+
when 'usps_username' then sc.usps_username = value
|
34
|
+
when 'usps_secret_key' then sc.usps_secret_key = value
|
35
|
+
when 'usps_publishable_key' then sc.usps_publishable_key = value
|
36
|
+
when 'fedex_username' then sc.fedex_username = value
|
37
|
+
when 'fedex_password' then sc.fedex_password = value
|
38
|
+
when 'fedex_key' then sc.fedex_key = value
|
39
|
+
when 'fedex_account' then sc.fedex_account = value
|
40
|
+
when 'origin_country' then sc.origin_country = value
|
41
|
+
when 'origin_state' then sc.origin_state = value
|
42
|
+
when 'origin_city' then sc.origin_city = value
|
43
|
+
when 'origin_zip' then sc.origin_zip = value
|
44
|
+
when 'fulfillment_email' then sc.fulfillment_email = value
|
45
|
+
when 'shipping_email' then sc.shipping_email = value
|
46
|
+
when 'handling_percentage' then sc.handling_percentage = value
|
47
|
+
when 'calculate_packages' then sc.calculate_packages = value
|
48
|
+
when 'shipping_rates_function' then sc.shipping_rates_function = value
|
49
|
+
when 'length_unit' then sc.length_unit = value
|
50
|
+
when 'weight_unit' then sc.weight_unit = value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
resp.success = save && sc.save
|
55
|
+
render :json => resp
|
56
|
+
end
|
57
|
+
|
58
|
+
# GET /admin/store/payment-processor-options
|
59
|
+
def payment_processor_options
|
60
|
+
return if !user_is_allowed('sites', 'view')
|
61
|
+
options = [
|
62
|
+
{ 'value' => 'authorize.net' , 'text' => 'Authorize.net' },
|
63
|
+
{ 'value' => 'stripe' , 'text' => 'Stripe' }
|
64
|
+
]
|
65
|
+
render :json => options
|
66
|
+
end
|
67
|
+
|
68
|
+
# GET /admin/store/length-unit-options
|
69
|
+
def length_unit_options
|
70
|
+
return if !user_is_allowed('sites', 'view')
|
71
|
+
options = [
|
72
|
+
{ 'value' => 'in' , 'text' => 'Inches (in)' },
|
73
|
+
{ 'value' => 'ft' , 'text' => 'Feet (ft)' },
|
74
|
+
{ 'value' => 'mm' , 'text' => 'Millimeter (mm)' },
|
75
|
+
{ 'value' => 'cm' , 'text' => 'Centimeter (cm)' },
|
76
|
+
{ 'value' => 'm' , 'text' => 'Meter (m)' }
|
77
|
+
]
|
78
|
+
render :json => options
|
79
|
+
end
|
80
|
+
|
81
|
+
# GET /admin/store/weight-unit-options
|
82
|
+
def weight_unit_options
|
83
|
+
return if !user_is_allowed('sites', 'view')
|
84
|
+
options = [
|
85
|
+
{ 'value' => 'oz' , 'text' => 'Ounces (oz)' },
|
86
|
+
{ 'value' => 'lb' , 'text' => 'Pounds (lb)' },
|
87
|
+
{ 'value' => 'g' , 'text' => 'Grams (g)' },
|
88
|
+
{ 'value' => 'kg' , 'text' => 'Kilograms (kg)' }
|
89
|
+
]
|
90
|
+
render :json => options
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -3,6 +3,8 @@ module Caboose
|
|
3
3
|
|
4
4
|
# GET /admin/vendors
|
5
5
|
def admin_index
|
6
|
+
return if !user_is_allowed('vendors', 'view')
|
7
|
+
|
6
8
|
@pager = Caboose::Pager.new(params, {
|
7
9
|
'site_id' => @site.id,
|
8
10
|
'name_like' => ''
|
@@ -22,32 +24,51 @@ module Caboose
|
|
22
24
|
|
23
25
|
# GET /admin/vendors/:id
|
24
26
|
def admin_edit
|
27
|
+
return if !user_is_allowed('vendors', 'edit')
|
25
28
|
@vendor = Vendor.find(params[:id])
|
26
29
|
render :layout => 'caboose/admin'
|
27
30
|
end
|
28
31
|
|
29
32
|
# PUT /admin/vendors/:id/update
|
30
33
|
def admin_update
|
34
|
+
return if !user_is_allowed('vendors', 'edit')
|
31
35
|
vendor = Vendor.find(params[:id])
|
32
36
|
|
33
37
|
params.each do |name, value|
|
34
38
|
case name
|
35
|
-
when 'site_id'
|
36
|
-
when 'name'
|
37
|
-
when 'status'
|
39
|
+
when 'site_id' then vendor.site_id = value
|
40
|
+
when 'name' then vendor.name = value
|
41
|
+
when 'status' then vendor.status = value
|
42
|
+
when 'featured' then vendor.featured = value
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
46
|
render :json => { :success => vendor.save }
|
42
47
|
end
|
43
48
|
|
49
|
+
# POST /admin/vendors/:id/update/image
|
50
|
+
def admin_update_image
|
51
|
+
return if !user_is_allowed('vendors', 'edit')
|
52
|
+
|
53
|
+
vendor = Vendor.find(params[:id])
|
54
|
+
vendor.image = params[:image]
|
55
|
+
vendor.save
|
56
|
+
|
57
|
+
resp = StdClass.new
|
58
|
+
resp.attributes = { :image => { :value => vendor.image.url(:thumb) }}
|
59
|
+
resp.success = vendor.save
|
60
|
+
end
|
61
|
+
|
44
62
|
# GET /admin/vendors/new
|
45
63
|
def admin_new
|
64
|
+
return if !user_is_allowed('vendors', 'add')
|
46
65
|
render :layout => 'caboose/admin'
|
47
66
|
end
|
48
67
|
|
49
68
|
# POST /admin/vendors
|
50
69
|
def admin_add
|
70
|
+
return if !user_is_allowed('vendors', 'add')
|
71
|
+
|
51
72
|
render :json => { :success => false, :message => 'Must define a name' } and return if params[:name].nil? || params[:name].empty?
|
52
73
|
|
53
74
|
vendor = Vendor.new(
|
@@ -59,7 +80,7 @@ module Caboose
|
|
59
80
|
end
|
60
81
|
|
61
82
|
# DELETE /admin/vendors/:id
|
62
|
-
def admin_delete
|
83
|
+
def admin_delete
|
63
84
|
return if !user_is_allowed('vendors', 'delete')
|
64
85
|
v = Vendor.find(params[:id])
|
65
86
|
v.destroy
|
@@ -18,9 +18,7 @@ module Caboose
|
|
18
18
|
:country,
|
19
19
|
:country_code,
|
20
20
|
:phone
|
21
|
-
|
22
|
-
validates :first_name, :last_name, :address1, :city, :state, :zip, :presence => true
|
23
|
-
validates :zip, :format => { :with => /^\d{5}(-\d{4})?$/, :message => 'Invalid zip code' }
|
21
|
+
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
@@ -90,5 +90,23 @@ module Caboose
|
|
90
90
|
ancestors << self
|
91
91
|
return ancestors
|
92
92
|
end
|
93
|
+
|
94
|
+
def self.options(site_id)
|
95
|
+
cat = Category.where("site_id = ? and parent_id is null", site_id).first
|
96
|
+
if cat.nil?
|
97
|
+
cat = Category.create(:site_id => site_id, :name => 'All Products', :url => '/')
|
98
|
+
end
|
99
|
+
arr = self.options_helper(cat, '')
|
100
|
+
return arr
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.options_helper(cat, prefix)
|
104
|
+
return [] if cat.nil?
|
105
|
+
arr = [{ :value => cat.id, :text => "#{prefix}#{cat.name}" }]
|
106
|
+
cat.children.each do |c|
|
107
|
+
arr = arr + self.options_helper(c, "#{prefix} - ")
|
108
|
+
end
|
109
|
+
return arr
|
110
|
+
end
|
93
111
|
end
|
94
112
|
end
|
@@ -1,37 +1,39 @@
|
|
1
1
|
class Caboose::CorePlugin < Caboose::CaboosePlugin
|
2
2
|
|
3
|
-
def self.admin_nav(nav, user, page)
|
3
|
+
def self.admin_nav(nav, user, page, site)
|
4
4
|
return nav if user.nil?
|
5
5
|
|
6
6
|
nav << { 'id' => 'logout' , 'text' => 'Logout' , 'href' => '/logout' , 'modal' => false }
|
7
7
|
nav << { 'id' => 'my-account' , 'text' => 'My Account' , 'href' => '/my-account' , 'modal' => true }
|
8
8
|
|
9
|
-
item = { 'id' => 'core', 'text' => 'Settings', 'children' => [] }
|
10
|
-
item['children'] << { 'id' => '
|
11
|
-
item['children'] << { 'id' => 'roles' , 'text' => 'Roles' , 'href' => '/admin/roles' , 'modal' => false } if user.is_allowed('roles' , 'view')
|
12
|
-
item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
|
13
|
-
item['children'] << { 'id' => 'sites' , 'text' => 'Sites' , 'href' => '/admin/sites' , 'modal' => false } if user.is_allowed('sites' , 'view')
|
14
|
-
item['children'] << { 'id' => 'blocktypes' , 'text' => 'AB Test Variants' , 'href' => '/admin/ab-variants' , 'modal' => false } if user.is_allowed('abvariants' , 'view')
|
15
|
-
item['children'] << { 'id' => 'variables' , 'text' => 'Variables' , 'href' => '/admin/settings' , 'modal' => false } if user.is_allowed('settings' , 'view')
|
9
|
+
item = { 'id' => 'core', 'text' => 'Settings', 'children' => [] }
|
10
|
+
item['children'] << { 'id' => 'blocktypes' , 'text' => 'AB Test Variants' , 'href' => '/admin/ab-variants' , 'modal' => false } if user.is_allowed('abvariants' , 'view')
|
16
11
|
item['children'] << { 'id' => 'blocktypes' , 'text' => 'Block Types' , 'href' => '/admin/block-types' , 'modal' => false } if user.is_allowed('blocktypes' , 'view')
|
17
|
-
item['children'] << { 'id' => 'redirects' , 'text' => 'Permanent Redirects' , 'href' => '/admin/redirects' , 'modal' => false } if user.is_allowed('redirects' , 'view')
|
12
|
+
item['children'] << { 'id' => 'redirects' , 'text' => 'Permanent Redirects' , 'href' => '/admin/redirects' , 'modal' => false } if user.is_allowed('redirects' , 'view')
|
13
|
+
item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
|
14
|
+
item['children'] << { 'id' => 'roles' , 'text' => 'Roles' , 'href' => '/admin/roles' , 'modal' => false } if user.is_allowed('roles' , 'view')
|
15
|
+
item['children'] << { 'id' => 'sites' , 'text' => 'Sites' , 'href' => '/admin/sites' , 'modal' => false } if user.is_allowed('sites' , 'view') if site.name == 'application'
|
16
|
+
item['children'] << { 'id' => 'smtp' , 'text' => 'SMTP (Mail)' , 'href' => '/admin/smtp' , 'modal' => false } if user.is_allowed('smtp' , 'view')
|
17
|
+
item['children'] << { 'id' => 'store' , 'text' => 'Store' , 'href' => '/admin/store' , 'modal' => false } if user.is_allowed('store' , 'view')
|
18
|
+
item['children'] << { 'id' => 'users' , 'text' => 'Users' , 'href' => '/admin/users' , 'modal' => false } if user.is_allowed('users' , 'view')
|
19
|
+
item['children'] << { 'id' => 'variables' , 'text' => 'Variables' , 'href' => '/admin/settings' , 'modal' => false } if user.is_allowed('settings' , 'view')
|
18
20
|
nav << item if item['children'].count > 0
|
19
21
|
|
20
22
|
item = { 'id' => 'content', 'text' => 'Content', 'children' => [] }
|
21
23
|
item['children'] << { 'id' => 'pages' , 'text' => 'Pages' , 'href' => '/admin/pages' , 'modal' => false } if user.is_allowed('pages' , 'view')
|
22
24
|
item['children'] << { 'id' => 'posts' , 'text' => 'Posts' , 'href' => '/admin/posts' , 'modal' => false } if user.is_allowed('posts' , 'view')
|
25
|
+
item['children'] << { 'id' => 'calendars' , 'text' => 'Calendars' , 'href' => '/admin/calendars' , 'modal' => false } if user.is_allowed('calendars' , 'view')
|
23
26
|
nav << item if item['children'].count > 0
|
24
27
|
|
25
|
-
|
26
|
-
'id'
|
27
|
-
'text'
|
28
|
-
'children' =>
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
nav << item if item['children'].count > 0
|
28
|
+
if site.use_store
|
29
|
+
item = { 'id' => 'store', 'text' => 'Store', 'children' => [] }
|
30
|
+
item['children'] << { 'id' => 'categories' , 'href' => '/admin/categories' , 'text' => 'Categories' , 'modal' => false } if user.is_allowed('categories' , 'view')
|
31
|
+
item['children'] << { 'id' => 'orders' , 'href' => '/admin/orders' , 'text' => 'Orders' , 'modal' => false } if user.is_allowed('orders' , 'view')
|
32
|
+
item['children'] << { 'id' => 'products' , 'href' => '/admin/products' , 'text' => 'Products' , 'modal' => false } if user.is_allowed('products' , 'view')
|
33
|
+
item['children'] << { 'id' => 'shippingpackages' , 'href' => '/admin/shipping-packages' , 'text' => 'Shipping Packages' , 'modal' => false } if user.is_allowed('shippingpackages' , 'view')
|
34
|
+
item['children'] << { 'id' => 'vendors' , 'href' => '/admin/vendors' , 'text' => 'Vendors' , 'modal' => false } if user.is_allowed('vendors' , 'view')
|
35
|
+
nav << item if item['children'].count > 0
|
36
|
+
end
|
35
37
|
|
36
38
|
return nav
|
37
39
|
end
|
data/app/models/caboose/order.rb
CHANGED
@@ -14,7 +14,8 @@ module Caboose
|
|
14
14
|
has_many :discounts, :through => :order_discounts
|
15
15
|
has_many :order_discounts
|
16
16
|
has_many :line_items, :after_add => :line_item_added, :after_remove => :line_item_removed, :order => :id
|
17
|
-
has_many :
|
17
|
+
has_many :order_packages, :class_name => 'Caboose::OrderPackage'
|
18
|
+
has_many :order_transactions
|
18
19
|
|
19
20
|
attr_accessible :id,
|
20
21
|
:site_id,
|
@@ -100,14 +101,18 @@ module Caboose
|
|
100
101
|
# Methods
|
101
102
|
#
|
102
103
|
|
103
|
-
def
|
104
|
-
self.
|
105
|
-
:line_items => self.line_items,
|
106
|
-
:shipping_address => self.shipping_address,
|
107
|
-
:billing_address => self.billing_address
|
108
|
-
})
|
104
|
+
def packages
|
105
|
+
self.order_packages
|
109
106
|
end
|
110
107
|
|
108
|
+
#def as_json(options={})
|
109
|
+
# self.attributes.merge({
|
110
|
+
# :line_items => self.line_items,
|
111
|
+
# :shipping_address => self.shipping_address,
|
112
|
+
# :billing_address => self.billing_address
|
113
|
+
# })
|
114
|
+
#end
|
115
|
+
|
111
116
|
def decrement_quantities
|
112
117
|
return false if self.decremented
|
113
118
|
|
@@ -4,12 +4,15 @@ module Caboose
|
|
4
4
|
|
5
5
|
belongs_to :order
|
6
6
|
belongs_to :shipping_package
|
7
|
+
belongs_to :shipping_method
|
7
8
|
has_many :line_items
|
8
9
|
attr_accessible :id,
|
9
10
|
:order_id,
|
11
|
+
:shipping_method_id,
|
10
12
|
:shipping_package_id,
|
11
13
|
:status,
|
12
|
-
:tracking_number
|
14
|
+
:tracking_number,
|
15
|
+
:total
|
13
16
|
|
14
17
|
STATUS_PENDING = 'Pending'
|
15
18
|
STATUS_SHIPPED = 'Shipped'
|
@@ -99,7 +102,7 @@ module Caboose
|
|
99
102
|
self.line_items.each{ |li| weight = weight + li.variant.weight }
|
100
103
|
weight = weight * 0.035274 # Convert from grams to ounces
|
101
104
|
sp = self.shipping_package
|
102
|
-
return Package.new(weight, [sp.
|
105
|
+
return Package.new(weight, [sp.outside_length, sp.outside_width, sp.outside_height], :units => :imperial)
|
103
106
|
end
|
104
107
|
|
105
108
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Caboose
|
2
|
+
class OrderTransaction < ActiveRecord::Base
|
3
|
+
self.table_name = 'store_order_transactions'
|
4
|
+
self.primary_key = 'id'
|
5
|
+
|
6
|
+
belongs_to :order
|
7
|
+
attr_accessible :id,
|
8
|
+
:order_id,
|
9
|
+
:transaction_id,
|
10
|
+
:transaction_type,
|
11
|
+
:amount,
|
12
|
+
:auth_code,
|
13
|
+
:date_processed,
|
14
|
+
:response_code,
|
15
|
+
:success
|
16
|
+
|
17
|
+
TYPE_AUTHORIZE = 'auth'
|
18
|
+
TYPE_CAPTURE = 'capture'
|
19
|
+
TYPE_VOID = 'void'
|
20
|
+
TYPE_REFUND = 'refund'
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
data/app/models/caboose/page.rb
CHANGED
@@ -144,7 +144,7 @@ class Caboose::Page < ActiveRecord::Base
|
|
144
144
|
|
145
145
|
def self.update_authorized_for_action(page_id, action, roles)
|
146
146
|
Caboose::PagePermission.where(:page_id => page_id, :action => action).destroy_all
|
147
|
-
if
|
147
|
+
if roles
|
148
148
|
roles.each do |role|
|
149
149
|
role_id = role.is_a?(Integer) ? role : role.id
|
150
150
|
Caboose::PagePermission.create({
|
@@ -56,8 +56,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
56
56
|
],
|
57
57
|
Caboose::Order => [:shipping_method, :shipping_method_code],
|
58
58
|
#Caboose::PageCache => [:block],
|
59
|
-
Caboose::ShippingPackage => [:price, :carrier, :service_code, :service_name, :shipping_method_id],
|
59
|
+
Caboose::ShippingPackage => [:price, :carrier, :service_code, :service_name, :shipping_method_id, :length, :width, :height],
|
60
60
|
Caboose::Site => [:shipping_cost_function],
|
61
|
+
Caboose::StoreConfig => [:use_usps, :allowed_shipping_codes, :default_shipping_code],
|
61
62
|
Caboose::Variant => [:quantity],
|
62
63
|
Caboose::Vendor => [:vendor, :vendor_id]
|
63
64
|
}
|
@@ -281,6 +282,28 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
281
282
|
[ :description , :text ],
|
282
283
|
[ :file , :attachment ]
|
283
284
|
],
|
285
|
+
Caboose::OrderTransaction => [
|
286
|
+
[ :order_id , :integer ],
|
287
|
+
[ :date_processed , :datetime ],
|
288
|
+
[ :transaction_type , :string ],
|
289
|
+
[ :amount , :numeric , :default => 0 ],
|
290
|
+
[ :transaction_id , :string ],
|
291
|
+
[ :auth_code , :string ],
|
292
|
+
[ :response_code , :string ],
|
293
|
+
[ :success , :boolean ]
|
294
|
+
],
|
295
|
+
Caboose::OrderDiscount => [
|
296
|
+
[ :order_id , :integer ],
|
297
|
+
[ :discount_id , :integer ]
|
298
|
+
],
|
299
|
+
Caboose::OrderPackage => [
|
300
|
+
[ :order_id , :integer ],
|
301
|
+
[ :shipping_method_id , :integer ],
|
302
|
+
[ :shipping_package_id , :integer ],
|
303
|
+
[ :status , :string ],
|
304
|
+
[ :tracking_number , :string ],
|
305
|
+
[ :total , :decimal , { :default => 0.0 }]
|
306
|
+
],
|
284
307
|
Caboose::Order => [
|
285
308
|
[ :site_id , :integer ],
|
286
309
|
[ :email , :string ],
|
@@ -318,16 +341,6 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
318
341
|
[ :transaction_service , :string ],
|
319
342
|
[ :amount_discounted , :numeric ],
|
320
343
|
[ :decremented , :boolean ]
|
321
|
-
],
|
322
|
-
Caboose::OrderDiscount => [
|
323
|
-
[ :order_id , :integer ],
|
324
|
-
[ :discount_id , :integer ]
|
325
|
-
],
|
326
|
-
Caboose::OrderPackage => [
|
327
|
-
[ :order_id , :integer ],
|
328
|
-
[ :shipping_package_id , :integer ],
|
329
|
-
[ :status , :string ],
|
330
|
-
[ :tracking_number , :string ]
|
331
344
|
],
|
332
345
|
Caboose::Page => [
|
333
346
|
[ :site_id , :integer ],
|
@@ -485,11 +498,16 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
485
498
|
Caboose::ShippingPackage => [
|
486
499
|
[ :site_id , :integer ],
|
487
500
|
[ :name , :string ],
|
488
|
-
[ :
|
489
|
-
[ :
|
490
|
-
[ :
|
501
|
+
[ :inside_length , :decimal ],
|
502
|
+
[ :inside_width , :decimal ],
|
503
|
+
[ :inside_height , :decimal ],
|
504
|
+
[ :outside_length , :decimal ],
|
505
|
+
[ :outside_width , :decimal ],
|
506
|
+
[ :outside_height , :decimal ],
|
491
507
|
[ :volume , :decimal ],
|
492
|
-
[ :
|
508
|
+
[ :empty_weight , :decimal ],
|
509
|
+
[ :cylinder , :boolean , { :default => false }],
|
510
|
+
[ :priority , :integer , { :default => 1 }],
|
493
511
|
[ :flat_rate_price , :decimal ]
|
494
512
|
],
|
495
513
|
Caboose::ShippingPackageMethod => [
|
@@ -499,7 +517,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
499
517
|
Caboose::Site => [
|
500
518
|
[ :name , :string ],
|
501
519
|
[ :description , :text ],
|
502
|
-
[ :under_construction_html , :text ]
|
520
|
+
[ :under_construction_html , :text ],
|
521
|
+
[ :use_store , :boolean , { :default => false }]
|
503
522
|
],
|
504
523
|
Caboose::SiteMembership => [
|
505
524
|
[ :site_id , :integer ],
|
@@ -529,12 +548,18 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
529
548
|
[ :site_id , :integer ],
|
530
549
|
[ :pp_name , :string ],
|
531
550
|
[ :pp_username , :string ],
|
532
|
-
[ :pp_password , :string ],
|
533
|
-
[ :
|
551
|
+
[ :pp_password , :string ],
|
552
|
+
[ :ups_username , :string ],
|
553
|
+
[ :ups_password , :string ],
|
554
|
+
[ :ups_key , :string ],
|
555
|
+
[ :ups_origin_account , :string ],
|
556
|
+
[ :usps_username , :string ],
|
534
557
|
[ :usps_secret_key , :string ],
|
535
558
|
[ :usps_publishable_key , :string ],
|
536
|
-
[ :
|
537
|
-
[ :
|
559
|
+
[ :fedex_username , :string ],
|
560
|
+
[ :fedex_password , :string ],
|
561
|
+
[ :fedex_key , :string ],
|
562
|
+
[ :fedex_account , :string ],
|
538
563
|
[ :origin_country , :string ],
|
539
564
|
[ :origin_state , :string ],
|
540
565
|
[ :origin_city , :string ],
|
@@ -543,7 +568,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
543
568
|
[ :shipping_email , :string ],
|
544
569
|
[ :handling_percentage , :string ],
|
545
570
|
[ :calculate_packages , :boolean , { :default => true }],
|
546
|
-
[ :shipping_rates_function , :text ]
|
571
|
+
[ :shipping_rates_function , :text ],
|
572
|
+
[ :length_unit , :string , { :default => 'in' }],
|
573
|
+
[ :weight_unit , :string , { :default => 'oz' }]
|
547
574
|
],
|
548
575
|
Caboose::User => [
|
549
576
|
[ :site_id , :integer ],
|
@@ -601,7 +628,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
601
628
|
[ :site_id , :integer ],
|
602
629
|
[ :alternate_id , :string ],
|
603
630
|
[ :name , :string ],
|
604
|
-
[ :status , :string , { :default => 'Active' }
|
631
|
+
[ :status , :string , { :default => 'Active' }],
|
632
|
+
[ :featured , :boolean , { :default => false }],
|
605
633
|
[ :image , :attachment ]
|
606
634
|
]
|
607
635
|
}
|