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.
Files changed (63) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin_edit_order.js +724 -0
  4. data/app/assets/javascripts/caboose/cart2.js +4 -4
  5. data/app/assets/javascripts/caboose/model/index_table.js +122 -80
  6. data/app/assets/stylesheets/caboose/admin_main.css +8 -0
  7. data/app/controllers/caboose/application_controller.rb +1 -1
  8. data/app/controllers/caboose/block_type_sources_controller.rb +1 -1
  9. data/app/controllers/caboose/block_types_controller.rb +1 -1
  10. data/app/controllers/caboose/calendars_controller.rb +1 -1
  11. data/app/controllers/caboose/cart_controller.rb +8 -1
  12. data/app/controllers/caboose/checkout_controller.rb +17 -9
  13. data/app/controllers/caboose/line_items_controller.rb +135 -0
  14. data/app/controllers/caboose/order_packages_controller.rb +304 -0
  15. data/app/controllers/caboose/orders_controller.rb +31 -74
  16. data/app/controllers/caboose/pages_controller.rb +2 -1
  17. data/app/controllers/caboose/product_images_controller.rb +11 -0
  18. data/app/controllers/caboose/products_controller.rb +25 -8
  19. data/app/controllers/caboose/shipping_addresses_controller.rb +46 -0
  20. data/app/controllers/caboose/shipping_packages_controller.rb +125 -54
  21. data/app/controllers/caboose/sites_controller.rb +2 -79
  22. data/app/controllers/caboose/smtp_controller.rb +52 -0
  23. data/app/controllers/caboose/store_controller.rb +94 -0
  24. data/app/controllers/caboose/vendors_controller.rb +25 -4
  25. data/app/models/caboose/address.rb +1 -3
  26. data/app/models/caboose/caboose_plugin.rb +1 -1
  27. data/app/models/caboose/category.rb +18 -0
  28. data/app/models/caboose/core_plugin.rb +21 -19
  29. data/app/models/caboose/order.rb +12 -7
  30. data/app/models/caboose/order_package.rb +5 -2
  31. data/app/models/caboose/order_transaction.rb +25 -0
  32. data/app/models/caboose/page.rb +1 -1
  33. data/app/models/caboose/schema.rb +50 -22
  34. data/app/models/caboose/shipping_calculator.rb +26 -30
  35. data/app/models/caboose/shipping_package.rb +45 -5
  36. data/app/models/caboose/store_config.rb +18 -6
  37. data/app/models/caboose/tax_calculator.rb +6 -5
  38. data/app/views/caboose/blocks/admin_edit.html.erb +1 -1
  39. data/app/views/caboose/line_items/admin_new.html.erb +100 -0
  40. data/app/views/caboose/orders/admin_edit.html.erb +21 -247
  41. data/app/views/caboose/orders/admin_edit_old.html.erb +155 -0
  42. data/app/views/caboose/orders/admin_new.html.erb +8 -23
  43. data/app/views/caboose/products/#Untitled-1# +0 -0
  44. data/app/views/caboose/products/admin_edit_images.html.erb +20 -4
  45. data/app/views/caboose/products/admin_index.html.erb +9 -3
  46. data/app/views/caboose/products/admin_sort.html.erb +138 -142
  47. data/app/views/caboose/roles/index.html.erb +1 -1
  48. data/app/views/caboose/shipping_packages/admin_edit.html.erb +52 -137
  49. data/app/views/caboose/shipping_packages/admin_index.html.erb +56 -19
  50. data/app/views/caboose/sites/_admin_header.html.erb +3 -5
  51. data/app/views/caboose/sites/admin_edit.html.erb +5 -3
  52. data/app/views/caboose/smtp/admin_edit.html.erb +41 -0
  53. data/app/views/caboose/station/index.html.erb +1 -1
  54. data/app/views/caboose/store/admin_edit.html.erb +96 -0
  55. data/app/views/caboose/vendors/admin_edit.html.erb +7 -3
  56. data/app/views/layouts/caboose/_station.html.erb +1 -1
  57. data/config/routes.rb +67 -25
  58. data/lib/caboose/engine.rb +1 -1
  59. data/lib/caboose/version.rb +1 -1
  60. metadata +28 -5
  61. data/app/views/caboose/shipping_packages/admin_new.html.erb +0 -33
  62. data/app/views/caboose/sites/admin_edit_smtp_config.html.erb +0 -51
  63. data/app/views/caboose/sites/admin_edit_store_config.html.erb +0 -77
@@ -147,7 +147,8 @@ module Caboose
147
147
 
148
148
  # GET /admin/pages/:id/edit
149
149
  def admin_edit_general
150
- return unless user_is_allowed('pages', 'edit')
150
+ return if !user_is_allowed('pages', 'edit')
151
+ #return if !Page.is_allowed(logged_in_user, params[:id], 'edit')
151
152
  @page = Page.find(params[:id])
152
153
  render :layout => 'caboose/admin'
153
154
  end
@@ -33,6 +33,17 @@ module Caboose
33
33
  img = var.product_images.first
34
34
  render :json => img
35
35
  end
36
+
37
+ # PUT /admin/products/:product_id/images/sort-order
38
+ def admin_update_sort_order
39
+ return if !user_is_allowed('products', 'edit')
40
+
41
+ ids = params[:product_image_ids]
42
+ ids.each_with_index do |id, i|
43
+ ProductImage.find(id).update_attribute(:position, i)
44
+ end
45
+ render :json => { :success => true }
46
+ end
36
47
 
37
48
  end
38
49
  end
@@ -130,10 +130,19 @@ module Caboose
130
130
  params[:sort] = 'store_vendors.name' if params[:sort] == 'vendor'
131
131
 
132
132
  @gen = Caboose::PageBarGenerator.new(params, {
133
- 'site_id' => @site.id,
134
- 'vendor_name' => '',
135
- 'search_like' => '',
136
- 'price' => params[:filters] && params[:filters][:missing_prices] ? 0 : ''
133
+ 'site_id' => @site.id,
134
+ 'vendor_name' => '',
135
+ 'search_like' => '',
136
+ 'category_id' => '',
137
+ 'category_name' => '',
138
+ 'vendor_id' => '',
139
+ 'vendor_name' => '',
140
+ 'vendor_status' => '',
141
+ 'price_gte' => '',
142
+ 'price_lte' => '',
143
+ 'price' => '',
144
+ 'variant_status' => '',
145
+ 'price' => params[:filters] && params[:filters][:missing_prices] ? 0 : ''
137
146
  }, {
138
147
  'model' => 'Caboose::Product',
139
148
  'sort' => 'title',
@@ -146,9 +155,16 @@ module Caboose
146
155
  'search_like' => 'store_products.title_concat_vendor_name_like'
147
156
  },
148
157
 
149
- 'includes' => {
150
- 'vendor_name' => [ 'vendor' , 'name' ],
151
- 'price' => [ 'variants' , 'price' ]
158
+ 'includes' => {
159
+ 'category_id' => [ 'categories' , 'id' ],
160
+ 'category_name' => [ 'categories' , 'name' ],
161
+ 'vendor_id' => [ 'vendor' , 'id' ],
162
+ 'vendor_name' => [ 'vendor' , 'name' ],
163
+ 'vendor_status' => [ 'vendor' , 'status' ],
164
+ 'price_gte' => [ 'variants' , 'price' ],
165
+ 'price_lte' => [ 'variants' , 'price' ],
166
+ 'price' => [ 'variants' , 'price' ],
167
+ 'variant_status' => [ 'variants' , 'status' ]
152
168
  }
153
169
  })
154
170
 
@@ -163,6 +179,7 @@ module Caboose
163
179
 
164
180
  # Get the correct page of the results
165
181
  @products = @all_products.limit(@gen.limit).offset(@gen.offset)
182
+ @category_options = Category.options(@site.id)
166
183
 
167
184
  render :layout => 'caboose/admin'
168
185
  end
@@ -337,7 +354,7 @@ module Caboose
337
354
  resp.error = "Invalid date"
338
355
  save = false
339
356
  end
340
- end
357
+ end
341
358
  end
342
359
  end
343
360
  resp.success = save && product.save
@@ -0,0 +1,46 @@
1
+ module Caboose
2
+ class ShippingAddressesController < Caboose::ApplicationController
3
+
4
+ # GET /admin/orders/:order_id/shipping-address/json
5
+ def admin_json
6
+ return if !user_is_allowed('orders', 'edit')
7
+ order = Order.find(params[:order_id])
8
+ render :json => order.shipping_address
9
+ end
10
+
11
+ # PUT /admin/orders/:order_id/shipping-address
12
+ def admin_update
13
+ return if !user_is_allowed('orders', 'edit')
14
+
15
+ resp = Caboose::StdClass.new({'attributes' => {}})
16
+ order = Order.find(params[:order_id])
17
+ sa = order.shipping_address
18
+ Caboose.log(sa.first_name)
19
+ save = true
20
+ params.each do |name, value|
21
+ case name
22
+ when 'name' then sa.name = value
23
+ when 'first_name' then sa.first_name = value
24
+ when 'last_name' then sa.last_name = value
25
+ when 'street' then sa.street = value
26
+ when 'address1' then sa.address1 = value
27
+ when 'address2' then sa.address2 = value
28
+ when 'company' then sa.company = value
29
+ when 'city' then sa.city = value
30
+ when 'state' then sa.state = value
31
+ when 'province' then sa.province = value
32
+ when 'province_code' then sa.province_code = value
33
+ when 'zip' then sa.zip = value
34
+ when 'country' then sa.country = value
35
+ when 'country_code' then sa.country_code = value
36
+ when 'phone' then sa.phone = value
37
+ end
38
+ end
39
+ Caboose.log(sa.first_name)
40
+ resp.success = save && sa.save
41
+ Caboose.log(sa.first_name)
42
+ render :json => resp
43
+ end
44
+
45
+ end
46
+ end
@@ -8,12 +8,12 @@ module Caboose
8
8
  @page = Page.page_with_uri(request.host_with_port, '/admin')
9
9
  end
10
10
 
11
- # GET /admin/sites/:site_id/shipping-packages
11
+ # GET /admin/shipping-packages
12
12
  def admin_index
13
13
  return if !user_is_allowed('sites', 'view')
14
14
  end
15
15
 
16
- # GET /admin/sites/:site_id/shipping-packages/json
16
+ # GET /admin/shipping-packages/json
17
17
  def admin_json
18
18
  return if !user_is_allowed('sites', 'view')
19
19
 
@@ -21,62 +21,61 @@ module Caboose
21
21
  'site_id' => @site.id,
22
22
  },{
23
23
  'model' => 'Caboose::ShippingPackage',
24
- 'sort' => 'shipping_method_id',
24
+ 'sort' => 'name',
25
25
  'desc' => false,
26
- 'base_url' => "/admin/sites/#{@site.id}/shipping-packages",
26
+ 'base_url' => "/admin/shipping-packages",
27
27
  'use_url_params' => false
28
28
  })
29
29
  render :json => {
30
30
  :pages => pager,
31
- :models => pager.items
31
+ :models => pager.items.as_json(:include => :shipping_methods)
32
32
  }
33
33
  end
34
34
 
35
- # GET /admin/sites/:site_id/shipping-packages/new
35
+ # GET /admin/shipping-packages/new
36
36
  def admin_new
37
37
  return if !user_is_allowed('sites', 'add')
38
38
  @shipping_package = ShippingPackage.new
39
39
  end
40
40
 
41
- # GET /admin/sites/:site_id/shipping-packages/:id
41
+ # GET /admin/shipping-packages/:id
42
42
  def admin_edit
43
43
  return if !user_is_allowed('sites', 'edit')
44
44
  @shipping_package = ShippingPackage.find(params[:id])
45
45
  end
46
46
 
47
- # GET /admin/sites/:site_id/shipping-packages/:id/json
47
+ # GET /admin/shipping-packages/:id/json
48
48
  def admin_json_single
49
49
  return if !user_is_allowed('sites', 'edit')
50
50
  sp = ShippingPackage.find(params[:id])
51
- render :json => sp
52
- end
53
-
54
- # GET /admin/sites/:site_id/shipping-packages/:id/delete
55
- def admin_delete_form
56
- return if !user_is_allowed('sites', 'edit')
57
- @shipping_package = ShippingPackage.find(params[:id])
51
+ render :json => sp.as_json(:include => :shipping_methods)
58
52
  end
59
53
 
60
- # POST /admin/sites/:site_id/shipping-packages
54
+ # POST /admin/shipping-packages
61
55
  def admin_add
62
56
  return if !user_is_allowed('sites', 'add')
63
57
 
64
58
  resp = StdClass.new
65
-
66
- if params[:shipping_method_id].strip.length == 0 then resp.error = "Please select a shipping method."
67
- elsif params[:length].strip.length == 0 then resp.error = "Please enter a valid length."
68
- elsif params[:width ].strip.length == 0 then resp.error = "Please enter a valid width."
69
- elsif params[:height].strip.length == 0 then resp.error = "Please enter a valid height."
59
+
60
+ if params[:inside_length].strip.length == 0 then resp.error = "Please enter a valid inside length."
61
+ elsif params[:inside_width ].strip.length == 0 then resp.error = "Please enter a valid inside width."
62
+ elsif params[:inside_height].strip.length == 0 then resp.error = "Please enter a valid inside height."
63
+ elsif params[:outside_length].strip.length == 0 then resp.error = "Please enter a valid outside length."
64
+ elsif params[:outside_width ].strip.length == 0 then resp.error = "Please enter a valid outside width."
65
+ elsif params[:outside_height].strip.length == 0 then resp.error = "Please enter a valid outside height."
70
66
  else
71
67
 
72
68
  sp = ShippingPackage.new(
73
- :site_id => @site.id,
74
- :shipping_method_id => params[:shipping_method_id],
75
- :length => params[:length].to_f,
76
- :width => params[:width ].to_f,
77
- :height => params[:height].to_f
69
+ :site_id => @site.id,
70
+ :name => params[:name].strip,
71
+ :inside_length => params[:inside_length].to_f,
72
+ :inside_width => params[:inside_width ].to_f,
73
+ :inside_height => params[:inside_height].to_f,
74
+ :outside_length => params[:outside_length].to_f,
75
+ :outside_width => params[:outside_width ].to_f,
76
+ :outside_height => params[:outside_height].to_f
78
77
  )
79
- sp.volume = sp.length * sp.width * sp.height
78
+ sp.volume = sp.inside_length * sp.inside_width * sp.inside_height
80
79
  sp.save
81
80
  resp.redirect = "/admin/sites/#{@site.id}/shipping-packages/#{sp.id}"
82
81
 
@@ -85,31 +84,37 @@ module Caboose
85
84
  render :json => resp
86
85
  end
87
86
 
88
- # POST /admin/products/:product_id/variants/bulk
87
+ # POST /admin/shipping-packages/bulk
89
88
  def admin_bulk_add
90
89
  return if !user_is_allowed('sites', 'add')
91
90
 
92
91
  resp = Caboose::StdClass.new
93
92
 
94
93
  i = 0
95
- CSV.parse(params[:csv_data].strip).each do |row|
96
- if row[0].nil? || row[0].strip.length == 0 then resp.error = "Shipping method not defined on row #{i+1}."
97
- elsif row[3].nil? || row[1].strip.length == 0 then resp.error = "Length not defined on row #{i+1}."
98
- elsif row[4].nil? || row[2].strip.length == 0 then resp.error = "Width not defined on row #{i+1}."
99
- elsif row[5].nil? || row[3].strip.length == 0 then resp.error = "Height not defined on row #{i+1}."
94
+ CSV.parse(params[:csv_data].strip).each do |row|
95
+ if row[1].nil? || row[0].strip.length == 0 then resp.error = "Inside Length not defined on row #{i+1}."
96
+ elsif row[2].nil? || row[1].strip.length == 0 then resp.error = "Inside Width not defined on row #{i+1}."
97
+ elsif row[3].nil? || row[2].strip.length == 0 then resp.error = "Inside Height not defined on row #{i+1}."
98
+ elsif row[4].nil? || row[3].strip.length == 0 then resp.error = "Outside Length not defined on row #{i+1}."
99
+ elsif row[5].nil? || row[4].strip.length == 0 then resp.error = "Outside Width not defined on row #{i+1}."
100
+ elsif row[6].nil? || row[5].strip.length == 0 then resp.error = "Outside Height not defined on row #{i+1}."
100
101
  end
101
102
  i = i + 1
102
103
  end
103
104
 
104
105
  if resp.error.nil?
105
106
  CSV.parse(params[:csv_data]).each do |row|
106
- sp = Caboose::Variant.new(
107
- :site_id => @site.id,
108
- :shipping_method_id => row[0],
109
- :length => row[1].to_f,
110
- :width => row[2].to_f,
111
- :height => row[3].to_f
107
+ sp = Caboose::ShippingPackage.new(
108
+ :site_id => @site.id,
109
+ :name => row[0].strip,
110
+ :inside_length => row[1].to_f,
111
+ :inside_width => row[2].to_f,
112
+ :inside_height => row[3].to_f,
113
+ :outside_length => row[4].to_f,
114
+ :outside_width => row[5].to_f,
115
+ :outside_height => row[6].to_f
112
116
  )
117
+ sp.volume = sp.inside_length * sp.inside_width * sp.inside_height
113
118
  sp.save
114
119
  end
115
120
  resp.success = true
@@ -118,7 +123,7 @@ module Caboose
118
123
  render :json => resp
119
124
  end
120
125
 
121
- # PUT /admin/sites/:site_id/shipping-packages/:id
126
+ # PUT /admin/shipping-packages/:id
122
127
  def admin_update
123
128
  return if !user_is_allowed('sites', 'edit')
124
129
 
@@ -128,31 +133,70 @@ module Caboose
128
133
  save = true
129
134
  params.each do |name,value|
130
135
  case name
131
- when 'site_id' then sp.site_id = value
132
- when 'shipping_method_id' then sp.shipping_method_id = value
133
- when 'length' then sp.length = value.to_f
134
- when 'width' then sp.width = value.to_f
135
- when 'height' then sp.height = value.to_f
136
- end
136
+ when 'site_id' then sp.site_id = value
137
+ when 'name' then sp.name = value
138
+ when 'inside_length' then sp.inside_length = value.to_f
139
+ when 'inside_width' then sp.inside_width = value.to_f
140
+ when 'inside_height' then sp.inside_height = value.to_f
141
+ when 'outside_length' then sp.outside_length = value.to_f
142
+ when 'outside_width' then sp.outside_width = value.to_f
143
+ when 'outside_height' then sp.outside_height = value.to_f
144
+ when 'volume' then sp.height = value.to_f
145
+ when 'empty_weight' then sp.empty_weight = value.to_f
146
+ when 'cylinder' then sp.cylinder = value.to_i
147
+ when 'flat_rate_price' then sp.flat_rate_price = value.to_f
148
+ when 'priority' then sp.priority = value.to_i
149
+ when 'shipping_method_id' then sp.toggle_shipping_method(value[0], value[1])
150
+ end
137
151
  end
138
152
 
139
153
  resp.success = save && sp.save
140
154
  render :json => resp
141
- end
155
+ end
156
+
157
+ # PUT /admin/:shipping-packages/bulk
158
+ def admin_bulk_update
159
+ return unless user_is_allowed_to 'edit', 'sites'
160
+
161
+ resp = Caboose::StdClass.new
162
+ shipping_packages = params[:model_ids].collect{ |sp_id| ShippingPackage.find(sp_id) }
163
+
164
+ save = true
165
+ params.each do |k,v|
166
+ case k
167
+ when 'site_id' then shipping_packages.each{ |sp| sp.site_id = v }
168
+ when 'name' then shipping_packages.each{ |sp| sp.name = v }
169
+ when 'inside_length' then shipping_packages.each{ |sp| sp.inside_length = v.to_f }
170
+ when 'inside_width' then shipping_packages.each{ |sp| sp.inside_width = v.to_f }
171
+ when 'inside_height' then shipping_packages.each{ |sp| sp.inside_height = v.to_f }
172
+ when 'outside_length' then shipping_packages.each{ |sp| sp.outside_length = v.to_f }
173
+ when 'outside_width' then shipping_packages.each{ |sp| sp.outside_width = v.to_f }
174
+ when 'outside_height' then shipping_packages.each{ |sp| sp.outside_height = v.to_f }
175
+ when 'volume' then shipping_packages.each{ |sp| sp.height = v.to_f }
176
+ when 'empty_weight' then shipping_packages.each{ |sp| sp.empty_weight = v.to_f }
177
+ when 'cylinder' then shipping_packages.each{ |sp| sp.cylinder = v.to_i }
178
+ when 'flat_rate_price' then shipping_packages.each{ |sp| sp.flat_rate_price = v.to_f }
179
+ when 'priority' then shipping_packages.each{ |sp| sp.priority = v.to_i }
180
+ when 'shipping_method_id' then shipping_packages.each{ |sp| sp.toggle_shipping_method(v[0], v[1]) }
181
+ end
182
+ end
183
+ shipping_packages.each{ |sp| sp.save }
184
+
185
+ resp.success = true
186
+ render :json => resp
187
+ end
142
188
 
143
- # DELETE /admin/sites/:site_id/shipping-packages/:id
189
+ # DELETE /admin/shipping-packages/:id
144
190
  def admin_delete
145
191
  return if !user_is_allowed('sites', 'delete')
146
192
  sp = ShippingPackage.find(params[:id])
147
193
  sp.destroy
148
194
 
149
- resp = StdClass.new({
150
- 'redirect' => "/admin/sites/#{@site.id}/shipping-packages"
151
- })
195
+ resp = StdClass.new({ 'redirect' => "/admin/shipping-packages" })
152
196
  render :json => resp
153
197
  end
154
198
 
155
- # DELETE /admin/sites/:site_id/shipping-packages/:id/bulk
199
+ # DELETE /admin/shipping-packages/:id/bulk
156
200
  def admin_bulk_delete
157
201
  return if !user_is_allowed('sites', 'delete')
158
202
 
@@ -165,18 +209,45 @@ module Caboose
165
209
  render :json => resp
166
210
  end
167
211
 
168
- # GET /admin/sites/:site_id/shipping-packages/options
212
+ # GET /admin/shipping-packages/options
169
213
  def options
170
214
  return if !user_is_allowed('sites', 'view')
171
215
  options = ShippingPackage.where(:site_id => @site.id).reorder('service_name').all.collect { |sp| { 'value' => sp.id, 'text' => sp.service_name }}
172
216
  render :json => options
173
217
  end
174
218
 
175
- # GET /admin/sites/:site_id/shipping-packages/shipping-method-options
219
+ # GET /admin/shipping-methods/options
220
+ # GET /admin/shipping-packages/shipping-method-options
176
221
  def admin_shipping_method_options
177
222
  options = ShippingMethod.reorder(:carrier, :service_name).all.collect { |sm| { :value => sm.id, :text => sm.service_name }}
178
223
  render :json => options
179
224
  end
225
+
226
+ # GET /admin/shipping-methods/options
227
+ # GET /admin/shipping-packages/:id/shipping-method-options
228
+ def admin_shipping_method_options
229
+ options = nil
230
+ if params[:id]
231
+ sp = ShippingPackage.find(params[:id])
232
+ options = sp.shipping_methods.reorder(:carrier, :service_name).all.collect { |sm| { :value => sm.id, :text => sm.service_name }}
233
+ else
234
+ options = ShippingMethod.reorder(:carrier, :service_name).all.collect { |sm| { :value => sm.id, :text => sm.service_name }}
235
+ end
236
+ render :json => options
237
+ end
238
+
239
+ # GET /admin/shipping-packages/package-method-options
240
+ def admin_package_method_options
241
+ return if !user_is_allowed('sites', 'view')
242
+ options = []
243
+ ShippingPackage.where(:site_id => @site.id).reorder('name').all.each do |sp|
244
+ prefix = sp.name ? sp.name : "#{sp.outside_length}x#{sp.outside_width}x#{sp.outside_height}"
245
+ sp.shipping_methods.each do |sm|
246
+ options << { 'value' => "#{sp.id}_#{sm.id}", 'text' => "#{prefix} - #{sm.carrier} - #{sm.service_name}" }
247
+ end
248
+ end
249
+ render :json => options
250
+ end
180
251
 
181
252
  end
182
253
  end
@@ -36,20 +36,6 @@ module Caboose
36
36
  @site = Site.find(params[:id])
37
37
  end
38
38
 
39
- # GET /admin/sites/:id/store
40
- def admin_edit_store_config
41
- return if !user_is_allowed('sites', 'edit')
42
- @site = Site.find(params[:id])
43
- StoreConfig.create(:site_id => @site.id) if @site.store_config.nil?
44
- end
45
-
46
- # GET /admin/sites/:id/smtp
47
- def admin_edit_smtp_config
48
- return if !user_is_allowed('sites', 'edit')
49
- @site = Site.find(params[:id])
50
- SmtpConfig.create(:site_id => @site.id) if @site.smtp_config.nil?
51
- end
52
-
53
39
  # GET /admin/sites/:id/block-types
54
40
  def admin_edit_block_types
55
41
  return if !user_is_allowed('sites', 'edit')
@@ -95,6 +81,7 @@ module Caboose
95
81
  when 'name' then site.name = value
96
82
  when 'description' then site.description = value
97
83
  when 'under_construction_html' then site.under_construction_html = value
84
+ when 'use_store' then site.use_store = value
98
85
  end
99
86
  end
100
87
 
@@ -102,7 +89,7 @@ module Caboose
102
89
  render :json => resp
103
90
  end
104
91
 
105
- # DELETE /admin/sites/1
92
+ # DELETE /admin/sites/:id
106
93
  def admin_delete
107
94
  return if !user_is_allowed('sites', 'delete')
108
95
  site = Site.find(params[:id])
@@ -131,49 +118,6 @@ module Caboose
131
118
  render :json => true
132
119
  end
133
120
 
134
- # POST /admin/sites/:id/domains
135
- #def admin_add_domain
136
- # return if !user_is_allowed('sites', 'edit')
137
- #
138
- # resp = Caboose::StdClass.new
139
- # d = Domain.where(:domain => params[:domain]).first
140
- #
141
- # if d && d.site_id != params[:id]
142
- # resp.error = "That domain is already associated with another site."
143
- # elsif d && d.site_id == params[:id]
144
- # resp.refresh = true
145
- # elsif d.nil?
146
- # primary = Domain.where(:site_id => params[:id]).count == 0
147
- # d = Domain.create(:site_id => params[:id], :domain => params[:domain], :primary => primary)
148
- # resp.refresh = true
149
- # end
150
- # render :json => resp
151
- #end
152
-
153
- # PUT /admin/sites/:id/domains/:domain_id/set-primary
154
- #def admin_set_primary_domain
155
- # return if !user_is_allowed('sites', 'edit')
156
- #
157
- # domain_id = params[:domain_id].to_i
158
- # Domain.where(:site_id => params[:id]).all.each do |d|
159
- # d.primary = d.id == domain_id ? true : false
160
- # d.save
161
- # end
162
- # render :json => true
163
- #end
164
-
165
- # DELETE /admin/sites/:id/domains/:domain_id
166
- #def admin_remove_domain
167
- # return if !user_is_allowed('sites', 'edit')
168
- # Domain.find(params[:domain_id]).destroy
169
- # if Domain.where(:site_id => params[:id]).count == 1
170
- # d = Domain.where(:site_id => params[:id]).first
171
- # d.primary = true
172
- # d.save
173
- # end
174
- # render :json => { 'refresh' => true }
175
- #end
176
-
177
121
  # GET /admin/sites/options
178
122
  def options
179
123
  return if !user_is_allowed('sites', 'view')
@@ -181,26 +125,5 @@ module Caboose
181
125
  render :json => options
182
126
  end
183
127
 
184
- # GET /admin/sites/payment-processor-options
185
- def payment_processor_options
186
- return if !user_is_allowed('sites', 'view')
187
- options = [
188
- { 'value' => 'authorize.net' , 'text' => 'Authorize.net' },
189
- { 'value' => 'stripe' , 'text' => 'Stripe' }
190
- ]
191
- render :json => options
192
- end
193
-
194
- # GET /admin/sites/smtp-auth-options
195
- def smtp_auth_options
196
- return if !user_is_allowed('sites', 'view')
197
- options = [
198
- { 'value' => SmtpConfig::AUTH_PLAIN , 'text' => SmtpConfig::AUTH_PLAIN },
199
- { 'value' => SmtpConfig::AUTH_LOGIN , 'text' => SmtpConfig::AUTH_LOGIN },
200
- { 'value' => SmtpConfig::AUTH_MD5 , 'text' => SmtpConfig::AUTH_MD5 }
201
- ]
202
- render :json => options
203
- end
204
-
205
128
  end
206
129
  end