caboose-cms 0.7.42 → 0.7.43

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.
@@ -123,10 +123,12 @@ module Caboose
123
123
  when 'alternate_id' then v.alternate_id = value
124
124
  when 'sku' then v.sku = value
125
125
  when 'barcode' then v.barcode = value
126
+ when 'cost' then v.cost = value
126
127
  when 'price' then v.price = value
127
128
  when 'quantity_in_stock' then v.quantity_in_stock = value
128
129
  when 'ignore_quantity' then v.ignore_quantity = value
129
130
  when 'allow_backorder' then v.allow_backorder = value
131
+ when 'clearance' then v.clearance = value
130
132
  when 'status' then v.status = value
131
133
  when 'weight' then v.weight = value
132
134
  when 'length' then v.length = value
@@ -261,6 +263,30 @@ module Caboose
261
263
  render :layout => 'caboose/admin'
262
264
  end
263
265
 
266
+ # GET /admin/products/:product_id/variants/option1-media
267
+ def admin_edit_option1_media
268
+ return if !user_is_allowed('products', 'edit')
269
+ @product = Product.find(params[:product_id])
270
+ @variants = Variant.where(:product_id => @product.id, :option1 => params[:option_value]).reorder(:option1_sort_order).all
271
+ render :layout => 'caboose/modal'
272
+ end
273
+
274
+ # GET /admin/products/:product_id/variants/option2-media
275
+ def admin_edit_option2_media
276
+ return if !user_is_allowed('products', 'edit')
277
+ @product = Product.find(params[:product_id])
278
+ @variants = Variant.where(:product_id => @product.id, :option2 => params[:option_value]).reorder(:option2_sort_order).all
279
+ render :layout => 'caboose/modal'
280
+ end
281
+
282
+ # GET /admin/products/:product_id/variants/option3-media
283
+ def admin_edit_option3_media
284
+ return if !user_is_allowed('products', 'edit')
285
+ @product = Product.find(params[:product_id])
286
+ @variants = Variant.where(:product_id => @product.id, :option3 => params[:option_value]).reorder(:option3_sort_order).all
287
+ render :layout => 'caboose/modal'
288
+ end
289
+
264
290
  # PUT /admin/products/:product_id/variants/option1-sort-order
265
291
  def admin_update_option1_sort_order
266
292
  product_id = params[:product_id]
@@ -425,6 +451,9 @@ module Caboose
425
451
  when 'option1' then variants.each { |v| v.option1 = value }
426
452
  when 'option2' then variants.each { |v| v.option2 = value }
427
453
  when 'option3' then variants.each { |v| v.option3 = value }
454
+ when 'option1_media_id' then variants.each { |v| v.option1_media_id = value }
455
+ when 'option2_media_id' then variants.each { |v| v.option2_media_id = value }
456
+ when 'option3_media_id' then variants.each { |v| v.option3_media_id = value }
428
457
  when 'requires_shipping' then variants.each { |v| v.requires_shipping = value }
429
458
  when 'taxable' then variants.each { |v| v.taxable = value }
430
459
  when 'downloadable' then variants.each { |v| v.downloadable = value }
@@ -27,8 +27,8 @@ module Caboose
27
27
  fail_count = Caboose::LoginLog.fail_count(user)
28
28
  if (fail_count+1) >= user.site.login_fail_lock_count
29
29
  user.locked = true
30
- user.save
31
- LoginMailer.locked_account(user).deliver
30
+ user.save
31
+ LoginMailer.configure_for_site(user.site.id).locked_account(user).deliver
32
32
  resp.error = "Too many failed login attempts. Your account has been locked and the site administrator has been notified."
33
33
  ll.success = false
34
34
  else
@@ -1,11 +1,16 @@
1
1
  module Caboose
2
2
  class CommentRoutes
3
3
 
4
- def CommentRoutes.parse_controllers
4
+ def CommentRoutes.parse_controllers
5
+ return CommentRoutes.controller_routes
6
+ end
7
+
8
+ def CommentRoutes.controller_routes(controller = nil)
5
9
 
6
10
  classes = {'zzz_all_domains' => []}
7
11
  Rails.application.config.paths['app/controllers'].each do |controller_path|
8
- files = Dir.glob(Rails.root.join(controller_path, '*.rb'))
12
+ #files = Dir.glob(Rails.root.join(controller_path, '*.rb'))
13
+ files = controller ? Dir.glob(Rails.root.join(controller_path, "#{controller}_controller.rb")) : Dir.glob(Rails.root.join(controller_path, '*.rb'))
9
14
  for file in files
10
15
  f = Rails.root.join('app', 'controllers', file)
11
16
  f2 = File.open(f, "r")
@@ -67,18 +72,100 @@ module Caboose
67
72
  actions.sort_by{ |arr| arr[2] }.each do |arr|
68
73
  action = arr[0]
69
74
  uris = arr[1]
70
- uris.each do |uri|
71
- #puts "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
72
- routes << "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
75
+ uris.each do |uri|
76
+ # puts "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
77
+ routes << "#{uri.ljust(length, ' ')} => \"#{class_name}\##{action}\""
73
78
  end
74
79
  end
75
- puts ""
80
+ #puts ""
81
+ routes << ""
76
82
  end
77
83
  routes << "end" if domain != 'zzz_all_domains'
78
84
  end
79
- puts routes
85
+ #puts routes
80
86
  return routes.join("\n")
81
87
  end
88
+
89
+ def CommentRoutes.split_route(line)
90
+ return nil if line.nil?
91
+ line = line.strip
92
+
93
+ #return ['get' , line.gsub(/^get (.*?)=>(.*?)$/ , '\1').strip.gsub('"', '').gsub("'", ''), line.gsub(/^get (.*?)=>(.*?)$/ , '\2').strip.gsub('"', '').gsub("'", '')] if line =~ /^get (.*?)=>(.*?)$/
94
+ #return ['post' , line.gsub(/^post (.*?)=>(.*?)$/ , '\1').strip.gsub('"', '').gsub("'", ''), line.gsub(/^post (.*?)=>(.*?)$/ , '\2').strip.gsub('"', '').gsub("'", '')] if line =~ /^post (.*?)=>(.*?)$/
95
+ #return ['put' , line.gsub(/^put (.*?)=>(.*?)$/ , '\1').strip.gsub('"', '').gsub("'", ''), line.gsub(/^put (.*?)=>(.*?)$/ , '\2').strip.gsub('"', '').gsub("'", '')] if line =~ /^put (.*?)=>(.*?)$/
96
+ #return ['delete' , line.gsub(/^delete (.*?)=>(.*?)$/ , '\1').strip.gsub('"', '').gsub("'", ''), line.gsub(/^delete (.*?)=>(.*?)$/ , '\2').strip.gsub('"', '').gsub("'", '')] if line =~ /^delete (.*?)=>(.*?)$/
97
+
98
+ if line =~ /^get (.*?)=>(.*?)$/ || line =~ /^post (.*?)=>(.*?)$/ || line =~ /^put (.*?)=>(.*?)$/ || line =~ /^delete (.*?)=>(.*?)$/
99
+ arr = [
100
+ line.gsub(/^(\w*?) (.*?)=>(.*?)$/ , '\1').strip.gsub('"', '').gsub("'", ''),
101
+ line.gsub(/^(\w*?) (.*?)=>(.*?)$/ , '\2').strip.gsub('"', '').gsub("'", ''),
102
+ line.gsub(/^(\w*?) (.*?)=>(.*?)$/ , '\3').strip.gsub('"', '').gsub("'", '')
103
+ ]
104
+ arr[1] = "/#{arr[1]}" if !arr[1].starts_with?('/')
105
+ return arr
106
+ end
107
+ return nil
108
+ end
109
+
110
+ def CommentRoutes.in_routes_array(route, routes_array)
111
+ return false if route.nil? || route.count < 3
112
+ routes_array.each do |route2|
113
+ next if route2.nil? || route2.count < 3
114
+ return true if route[0] == route2[0] && route[1] == route2[1] && route[2] == route2[2]
115
+ end
116
+ return false
117
+ end
118
+
119
+ def CommentRoutes.compare_routes
120
+
121
+ routes_in_routes_file = []
122
+ file = File.open(Rails.root.join('config', 'routes.rb'), "r")
123
+ file.each_line do |line|
124
+ line = line.strip
125
+ routes_in_routes_file << self.split_route(line)
126
+ end
127
+
128
+ routes_in_controllers = []
129
+ self.controller_routes.split("\n").each do |route|
130
+ route = route.strip
131
+ next if route.length == 0
132
+ routes_in_controllers << self.split_route(route)
133
+ end
134
+
135
+ all_routes = []
136
+
137
+ # See what routes are in the controller routes but not in routes file
138
+ routes_not_in_routes_file = []
139
+ routes_in_controllers.each do |route|
140
+ next if route.nil? || route.count != 3
141
+ all_routes << [route[0], route[1], route[2], 'Y', self.in_routes_array(route, routes_in_routes_file) ? 'Y' : '']
142
+ end
143
+
144
+ # See what routes are in the routes file but not in the controllers
145
+ routes_not_in_controllers = []
146
+ routes_in_routes_file.each do |route|
147
+ next if route.nil? || route.count != 3
148
+ if !self.in_routes_array(route, all_routes)
149
+ all_routes << [route[0], route[1], route[2], '', 'Y']
150
+ end
151
+ end
152
+
153
+ lengths = [0, 0, 0]
154
+ all_routes.each do |route|
155
+ lengths[0] = route[0].length if route[0].length > lengths[0]
156
+ lengths[1] = route[1].length if route[1].length > lengths[1]
157
+ lengths[2] = route[2].length if route[2].length > lengths[2]
158
+ end
159
+
160
+ puts "#{"Verb".ljust(lengths[0], ' ')} #{"URI".ljust(lengths[1], ' ')} #{"Action".ljust(lengths[2], ' ')} #{"In Controller".ljust(14, ' ')} #{"In Routes File".ljust(14, ' ')}"
161
+ puts "#{"".ljust(lengths[0], '-')} #{"".ljust(lengths[1], '-')} #{"".ljust(lengths[2], '-')} #{"".ljust(14, '-')} #{"".ljust(14, '-')}"
162
+ all_routes.each do |route|
163
+ next if route[3] == 'Y' && route[4] == 'Y'
164
+ puts "#{route[0].ljust(lengths[0], ' ')} #{route[1].ljust(lengths[1], ' ')} #{route[2].ljust(lengths[2], ' ')} #{route[3].ljust(14, ' ')} #{route[4].ljust(14, ' ')}"
165
+ end
166
+ puts "\n"
167
+
168
+ end
82
169
 
83
170
  end
84
171
  end
@@ -32,7 +32,10 @@ module Caboose
32
32
  :category_id ,
33
33
  :option1 ,
34
34
  :option2 ,
35
- :option3 ,
35
+ :option3 ,
36
+ :option1_media ,
37
+ :option2_media ,
38
+ :option3_media ,
36
39
  :default1 ,
37
40
  :default2 ,
38
41
  :default3 ,
@@ -159,14 +162,32 @@ module Caboose
159
162
  self.variants.where(:status => 'Active').reorder(:option1_sort_order).pluck(:option1).uniq.reject { |x| x.nil? || x.empty? }
160
163
  end
161
164
 
165
+ def option1_values_with_media
166
+ h = {}
167
+ self.variants.where("status = ? and option1 is not null", 'Active').reorder(:option1_sort_order).each{ |v| h[v.option1] = v.option1_media }
168
+ return h
169
+ end
170
+
162
171
  def option2_values
163
172
  self.variants.where(:status => 'Active').reorder(:option2_sort_order).pluck(:option2).uniq.reject { |x| x.nil? || x.empty? }
164
173
  end
165
174
 
175
+ def option2_values_with_media
176
+ h = {}
177
+ self.variants.where("status = ? and option2 is not null", 'Active').reorder(:option2_sort_order).each{ |v| h[v.option2] = v.option2_media }
178
+ return h
179
+ end
180
+
166
181
  def option3_values
167
182
  self.variants.where(:status => 'Active').reorder(:option3_sort_order).pluck(:option3).uniq.reject { |x| x.nil? || x.empty? }
168
183
  end
169
184
 
185
+ def option3_values_with_media
186
+ h = {}
187
+ self.variants.where("status = ? and option3 is not null", 'Active').reorder(:option3_sort_order).each{ |v| h[v.option3] = v.option3_media }
188
+ return h
189
+ end
190
+
170
191
  def toggle_category(cat_id, value)
171
192
  if value.to_i > 0 # Add to category
172
193
  if cat_id == 'all'
@@ -562,6 +562,9 @@ class Caboose::Schema < Caboose::Utilities::Schema
562
562
  [ :option1 , :string ],
563
563
  [ :option2 , :string ],
564
564
  [ :option3 , :string ],
565
+ [ :option1_media , :boolean , { :default => false }],
566
+ [ :option2_media , :boolean , { :default => false }],
567
+ [ :option3_media , :boolean , { :default => false }],
565
568
  [ :category_id , :integer ],
566
569
  [ :status , :string ],
567
570
  [ :default1 , :string ],
@@ -799,11 +802,13 @@ class Caboose::Schema < Caboose::Utilities::Schema
799
802
  [ :alternate_id , :string ],
800
803
  [ :sku , :string ],
801
804
  [ :barcode , :string ],
802
- [ :price , :decimal , { :precision => 8, :scale => 2 }],
805
+ [ :cost , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
806
+ [ :price , :decimal , { :precision => 8, :scale => 2, :default => 0.00 }],
803
807
  [ :sale_price , :decimal , { :precision => 8, :scale => 2 }],
804
808
  [ :date_sale_starts , :datetime ],
805
809
  [ :date_sale_ends , :datetime ],
806
810
  [ :date_sale_end , :datetime ],
811
+ [ :clearance , :boolean , { :default => false }],
807
812
  [ :available , :boolean , { :default => true }],
808
813
  [ :quantity_in_stock , :integer , { :default => 0 }],
809
814
  [ :ignore_quantity , :boolean , { :default => false }],
@@ -816,7 +821,10 @@ class Caboose::Schema < Caboose::Utilities::Schema
816
821
  [ :cylinder , :boolean , { :default => false }],
817
822
  [ :option1 , :string ],
818
823
  [ :option2 , :string ],
819
- [ :option3 , :string ],
824
+ [ :option3 , :string ],
825
+ [ :option1_media_id , :integer ],
826
+ [ :option2_media_id , :integer ],
827
+ [ :option3_media_id , :integer ],
820
828
  [ :requires_shipping , :boolean , { :default => true }],
821
829
  [ :taxable , :boolean , { :default => true }],
822
830
  [ :shipping_unit_value , :numeric ],
@@ -13,15 +13,20 @@ module Caboose
13
13
  has_many :product_images, :through => :product_image_variants
14
14
  belongs_to :flat_rate_shipping_method, :class_name => 'Caboose::ShippingMethod'
15
15
  belongs_to :flat_rate_shipping_package, :class_name => 'Caboose::ShippingPackage'
16
+ belongs_to :option1_media, :class_name => 'Caboose::Media'
17
+ belongs_to :option2_media, :class_name => 'Caboose::Media'
18
+ belongs_to :option3_media, :class_name => 'Caboose::Media'
16
19
 
17
20
  attr_accessible :id,
18
21
  :alternate_id,
19
22
  :product_id,
20
23
  :barcode, # Returns the barcode value of the variant.
24
+ :cost, # Cost of goods (don't show to customer)
21
25
  :price, # Variant’s price.
22
26
  :sale_price,
23
27
  :date_sale_starts,
24
28
  :date_sale_end,
29
+ :clearance,
25
30
  :ignore_quantity,
26
31
  :quantity,
27
32
  :quantity_in_stock,
@@ -33,7 +38,13 @@ module Caboose
33
38
  :height, # Height of variant in inches
34
39
  :option1, # Returns the value of option1 for given variant
35
40
  :option2, # If a product has a second option defined, then returns the value of this variant's option2.
36
- :option3, # If a product has a third option defined, then returns the value of this variant's option3.
41
+ :option3, # If a product has a third option defined, then returns the value of this variant's option3.
42
+ :option1_color,
43
+ :option2_color,
44
+ :option3_color,
45
+ :option1_media_id,
46
+ :option2_media_id,
47
+ :option3_media_id,
37
48
  :requires_shipping, # Returns true if the variant is shippable or false if it is a service or a digital good.
38
49
  :taxable, # Returns true if the variant is taxable or false if it is not.
39
50
  :sku,
@@ -1,8 +1,10 @@
1
- <% if @user %>
1
+ <% if @user && @user.site %>
2
2
  <%
3
- url = "#{Caboose::website_domain}/modal/login/reset-password/#{@user.password_reset_id}"
3
+ site = @user.site
4
+ pd = site.primary_domain
5
+ url = "#{pd.domain}/modal/login/reset-password/#{@user.password_reset_id}"
4
6
  %>
5
- <p>To reset your <%= Caboose::website_name %> website password, click the link below:</p>
7
+ <p>To reset your <%= site.name %> website password, click the link below:</p>
6
8
  <p><a href='<%= url %>'><%= url %></p>
7
9
  <% end %>
8
10
 
@@ -18,9 +18,9 @@ may_delete3 = p.variants.collect{|v| v.option3 }.uniq.count == 1
18
18
  </p>
19
19
 
20
20
  <table>
21
- <tr><td><div id='product_<%= p.id %>_option1'></div></td><td><div id='product_<%= p.id %>_default1'></div></td></tr>
22
- <tr><td><div id='product_<%= p.id %>_option2'></div></td><td><div id='product_<%= p.id %>_default2'></div></td></tr>
23
- <tr><td><div id='product_<%= p.id %>_option3'></div></td><td><div id='product_<%= p.id %>_default3'></div></td></tr>
21
+ <tr><td><div id='product_<%= p.id %>_option1'></div></td><td><div id='product_<%= p.id %>_default1'></div></td><td><div id='product_<%= p.id %>_option1_media'></div></td></tr>
22
+ <tr><td><div id='product_<%= p.id %>_option2'></div></td><td><div id='product_<%= p.id %>_default2'></div></td><td><div id='product_<%= p.id %>_option2_media'></div></td></tr>
23
+ <tr><td><div id='product_<%= p.id %>_option3'></div></td><td><div id='product_<%= p.id %>_default3'></div></td><td><div id='product_<%= p.id %>_option3_media'></div></td></tr>
24
24
  </table>
25
25
 
26
26
  <h2>Modifications</h2>
@@ -41,18 +41,24 @@ may_delete3 = p.variants.collect{|v| v.option3 }.uniq.count == 1
41
41
 
42
42
  var mods_controller = false;
43
43
  $(document).ready(function() {
44
+ console.log(<%= raw p.option1_media %>);
45
+ console.log(<%= raw p.option2_media %>);
46
+ console.log(<%= raw p.option3_media %>);
44
47
  m = new ModelBinder({
45
48
  name: 'Product',
46
49
  id: <%= p.id %>,
47
50
  update_url: '/admin/products/<%= p.id %>',
48
51
  authenticity_token: '<%= form_authenticity_token %>',
49
52
  attributes: [
50
- { name: 'option1' , nice_name: 'Option 1' , type: 'text', value: <%= raw Caboose.json(p.option1) %>, width: 250, fixed_placeholder: true },
51
- { name: 'option2' , nice_name: 'Option 2' , type: 'text', value: <%= raw Caboose.json(p.option2) %>, width: 250, fixed_placeholder: true },
52
- { name: 'option3' , nice_name: 'Option 3' , type: 'text', value: <%= raw Caboose.json(p.option3) %>, width: 250, fixed_placeholder: true },
53
- { name: 'default1' , nice_name: 'Default value' , type: 'text', value: <%= raw Caboose.json(p.default1) %>, width: 285, fixed_placeholder: true },
54
- { name: 'default2' , nice_name: 'Default value' , type: 'text', value: <%= raw Caboose.json(p.default2) %>, width: 285, fixed_placeholder: true },
55
- { name: 'default3' , nice_name: 'Default value' , type: 'text', value: <%= raw Caboose.json(p.default3) %>, width: 285, fixed_placeholder: true }
53
+ { name: 'option1' , nice_name: 'Option 1' , type: 'text' , value: <%= raw Caboose.json(p.option1) %>, width: 250, fixed_placeholder: true },
54
+ { name: 'option2' , nice_name: 'Option 2' , type: 'text' , value: <%= raw Caboose.json(p.option2) %>, width: 250, fixed_placeholder: true },
55
+ { name: 'option3' , nice_name: 'Option 3' , type: 'text' , value: <%= raw Caboose.json(p.option3) %>, width: 250, fixed_placeholder: true },
56
+ { name: 'option1_media' , nice_name: 'Uses Image' , type: 'checkbox' , value: <%= raw Caboose.json(p.option1_media) %>, width: 150, fixed_placeholder: true, align: 'right' },
57
+ { name: 'option2_media' , nice_name: 'Uses Image' , type: 'checkbox' , value: <%= raw Caboose.json(p.option2_media) %>, width: 150, fixed_placeholder: true, align: 'right' },
58
+ { name: 'option3_media' , nice_name: 'Uses Image' , type: 'checkbox' , value: <%= raw Caboose.json(p.option3_media) %>, width: 150, fixed_placeholder: true, align: 'right' },
59
+ { name: 'default1' , nice_name: 'Default value' , type: 'text' , value: <%= raw Caboose.json(p.default1) %>, width: 285, fixed_placeholder: true },
60
+ { name: 'default2' , nice_name: 'Default value' , type: 'text' , value: <%= raw Caboose.json(p.default2) %>, width: 285, fixed_placeholder: true },
61
+ { name: 'default3' , nice_name: 'Default value' , type: 'text' , value: <%= raw Caboose.json(p.default3) %>, width: 285, fixed_placeholder: true }
56
62
  ]
57
63
  });
58
64
 
@@ -20,7 +20,8 @@ v = @variant
20
20
  <h2>Inventory</h2>
21
21
  <div id='variant_<%= v.id %>_alternate_id' ></div>
22
22
  <div id='variant_<%= v.id %>_sku' ></div>
23
- <div id='variant_<%= v.id %>_barcode' ></div>
23
+ <div id='variant_<%= v.id %>_barcode' ></div>
24
+ <div id='variant_<%= v.id %>_cost' ></div>
24
25
  <div id='variant_<%= v.id %>_price' ></div>
25
26
  <div id='variant_<%= v.id %>_quantity_in_stock' ></div>
26
27
  <div id='variant_<%= v.id %>_ignore_quantity' ></div>
@@ -37,7 +38,8 @@ v = @variant
37
38
  <div id='variant_<%= v.id %>_date_sale_starts' ></div>
38
39
  <div id='variant_<%= v.id %>_time_sale_starts' ></div>
39
40
  <div id='variant_<%= v.id %>_date_sale_ends' ></div>
40
- <div id='variant_<%= v.id %>_time_sale_ends' ></div>
41
+ <div id='variant_<%= v.id %>_time_sale_ends' ></div>
42
+ <div id='variant_<%= v.id %>_clearance' ></div>
41
43
  </td>
42
44
  <td valign='top' colspan='4'4>
43
45
  <h2>Flat Rate Shipping</h2>
@@ -75,11 +77,13 @@ $(document).ready(function() {
75
77
  <% if p.option3 %>{ name: 'option3' , nice_name: <%= raw Caboose.json(p.option3) %> , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.option3 ) %> },<% end %>
76
78
  { name: 'alternate_id' , nice_name: 'Alternate ID' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.alternate_id ) %> },
77
79
  { name: 'sku' , nice_name: 'SKU' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.sku ) %> },
78
- { name: 'barcode' , nice_name: 'Barcode' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.barcode ) %> },
80
+ { name: 'barcode' , nice_name: 'Barcode' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.barcode ) %> },
81
+ { name: 'cost' , nice_name: 'Cost of Goods' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(sprintf("%.2f", v.cost) ) %> },
79
82
  { name: 'price' , nice_name: 'Price' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(sprintf("%.2f", v.price) ) %> },
80
83
  { name: 'sale_price' , nice_name: 'Sale price' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.sale_price ) %> },
81
84
  { name: 'date_sale_starts' , nice_name: 'Sale starts' , type: 'datetime' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.date_sale_starts ? v.date_sale_starts.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
82
- { name: 'date_sale_ends' , nice_name: 'Sale ends' , type: 'datetime' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.date_sale_ends ? v.date_sale_ends.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
85
+ { name: 'date_sale_ends' , nice_name: 'Sale ends' , type: 'datetime' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.date_sale_ends ? v.date_sale_ends.in_time_zone(@logged_in_user.timezone).strftime('%m/%d/%Y %I:%M %P') : '') %> },
86
+ { name: 'clearance' , nice_name: 'On Clearance' , type: 'checkbox' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.clearance ) %> },
83
87
  { name: 'quantity_in_stock' , nice_name: 'Quantity' , type: 'text' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.quantity_in_stock ) %> },
84
88
  { name: 'ignore_quantity' , nice_name: 'Ignore Quantity' , type: 'checkbox' , align: 'right' , width: 250, value: <%= raw Caboose.json(v.ignore_quantity ) %> },
85
89
  { name: 'weight' , nice_name: 'Weight (<%= sc.weight_unit %>)' , type: 'text' , align: 'right' , width: 175, value: <%= raw Caboose.json(v.weight ) %> },
@@ -0,0 +1,94 @@
1
+ <%
2
+ config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
3
+ access_key = config['access_key_id']
4
+ secret_key = config['secret_access_key']
5
+ bucket = config['bucket']
6
+ policy = {
7
+ "expiration" => 1.hour.from_now.utc.xmlschema,
8
+ "conditions" => [
9
+ { "bucket" => "#{bucket}-uploads" },
10
+ { "acl" => "public-read" },
11
+ [ "starts-with", "$key", '' ],
12
+ #[ "starts-with", "$Content-Type", 'image/' ],
13
+ [ 'starts-with', '$name', '' ],
14
+ [ 'starts-with', '$Filename', '' ],
15
+ ]
16
+ }
17
+ @policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
18
+ @signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, @policy)).gsub("\n","")
19
+ @s3_upload_url = "https://#{bucket}-uploads.s3.amazonaws.com/"
20
+ @aws_access_key_id = access_key
21
+ @top_media_category = Caboose::MediaCategory.top_category(@site.id)
22
+
23
+ %>
24
+ <div id='left_content'>
25
+ <div id='categories'></div>
26
+ </div>
27
+ <div id='right_content'>
28
+ <div id='controls'></div>
29
+ <div id='uploader'></div>
30
+ <div id='media'></div>
31
+ </div>
32
+
33
+ <p style='clear: both;'>&nbsp;</p>
34
+ <p>
35
+ <input type='button' value='Close' onclick="parent.location.reload(true); modal.close();" />
36
+ <input type='button' value='Manage Media' onclick="parent.window.location='/admin/media';" />
37
+ </p>
38
+
39
+ <% content_for :caboose_css do %>
40
+ <%= stylesheet_link_tag 'caboose/admin_block_edit_image' %>
41
+ <%= stylesheet_link_tag 'plupload/jquery.ui.plupload/css/jquery.ui.plupload.css' %>
42
+ <% end %>
43
+
44
+ <% content_for :caboose_js do %>
45
+ <%= javascript_include_tag "caboose/model/all" %>
46
+ <%= javascript_include_tag "caboose/media_browser" %>
47
+ <%= javascript_include_tag 'caboose/jquery-ui.drag-multiple.min.js' %>
48
+
49
+ <%= javascript_include_tag 'plupload/plupload.full.min.js' %>
50
+ <%= javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js' %>
51
+ <%
52
+ #javascript_include_tag 'plupload/moxie.js'
53
+ #javascript_include_tag 'plupload/plupload.dev.js'
54
+ #javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js'
55
+ %>
56
+
57
+ <script type='text/javascript'>
58
+
59
+ var modal = false;
60
+ $(window).load(function() {
61
+ modal = new CabooseModal(900);
62
+ });
63
+
64
+ var controller = false;
65
+ $(document).ready(function() {
66
+ b = new MediaBrowser({
67
+ media_id: <% if @media %><%= @media.id %><% else %>false<% end %>,
68
+ authenticity_token: '<%= form_authenticity_token %>',
69
+ top_cat_id: <%= raw Caboose.json(@top_media_category.id) %>,
70
+ cat_id: <% if @media %><%= @media.media_category_id %><% else %><%= @top_media_category.id %><% end %>,
71
+ s3_upload_url: '<%= raw @s3_upload_url %>',
72
+ aws_access_key_id: '<%= raw @aws_access_key_id %>',
73
+ policy: '<%= raw @policy %>',
74
+ signature: '<%= raw @signature %>',
75
+ refresh_unprocessed_images: false,
76
+ select_media: function(browser, media_id) {
77
+ $.ajax({
78
+ url: '/admin/products/<%= @product.id %>/variants/bulk',
79
+ type: 'put',
80
+ data: {
81
+ model_ids: <%= raw Caboose.json(@variants.collect{ |v| v.id }) %>,
82
+ option1_media_id: media_id
83
+ },
84
+ success: function(resp) {
85
+ parent.location.reload(true);
86
+ modal.close();
87
+ }
88
+ });
89
+ },
90
+ });
91
+ });
92
+
93
+ </script>
94
+ <% end %>