caboose-cms 0.6.12 → 0.6.13

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmZmZjJjMjE2ZTgyZjc3ZjEwYjVkODMxNzA2ODY2NjBmY2M1NmU5ZA==
4
+ M2U1YjdkM2YxYWNmMWVlNzBiYzc1MDE5ZmNiNWNkMGI3OWU2ZjhkNg==
5
5
  data.tar.gz: !binary |-
6
- YmUxZjQ5ZTc3YmJlZWRiZGE2MjY2OTFhY2I4Y2IxYzJhNzNiMjVlMw==
6
+ NmEzN2UyOTVlNDY4OWQ0ZWJkMzBiZTg3ZmU1NWFjNDI3NTE1MDQ5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTU4NTM4YTY2MDVkOWU1MTMzYzIwYWY1YzNmMDZmZDc2YzVhODdmMmM0Njgx
10
- ZTAyZDg0Yzg4YmUxMmQ4MTVlZDI1YzQxNzM0NmRjMTQ2ODE0YzE3ZGIyMjJi
11
- NjUyMzBhZjZkYTNhMTNiZTI4NDY1NzBjMDQ2MzkzMzVlZjUwMmY=
9
+ N2JjNmJmMDA3MjE2OTUwZDFjYjhkMThhNzAzZWEzOWY4ZTU4NDk0NDdjMmE3
10
+ NGIwOGQ3ZDJhY2UyYzIyMTZiMWE4MTVkN2M5MzIxMmZmOWU0MTU2ZGUzNGVi
11
+ M2VhZWFhMTY0ZmM0NzE0ZDRkZDI4YTNmZTMwMzNjNGU5YmJjYWU=
12
12
  data.tar.gz: !binary |-
13
- OTEwNjAzN2YyMDgwNGI4YTkyZDk2M2RjYmVlZmQyOGUwYmExOTQ2ODk3MmRl
14
- OGIwNjMxZTBiYzJjZDQzYzFmNTEyNTE3YjQzYzY4MDVlNmU4Y2RjYWU4YTE3
15
- MTgxNDBhODQyNjQ0N2M5ZTM5ZDVkMWYwZGVmMjBlNTE0MGUxZWY=
13
+ ZGY0ZjUxNzg0MmNmNTE4MzA5MDhjNzdiNTVjNDhjMDJmZWMyOTBkNjRjOWY5
14
+ NGVhYTNmYjEzMWIxNDkxZDNlZDY0MmFhODE3Y2RiYzViNTNhZThjMGY5NGNh
15
+ ZjVmYTRhNjYzOGFmMmQzOWQwOGZkZDRkNzFhOTZiMzFhZTlkOTE=
@@ -93,6 +93,13 @@ module Caboose
93
93
  m = Media.where(:id => id).first
94
94
  next if m.nil?
95
95
  m.update_attribute(:media_category_id, media_category_id)
96
+ p = Product.where(:media_category_id => media_category_id).last
97
+ if p
98
+ pi = ProductImage.where(:media_id => id).exists? ? ProductImage.where(:media_id => id).first : ProductImage.create(:media_id => id, :product_id => p.id)
99
+ pi.product_id = p.id
100
+ pi.save
101
+ ProductImageVariant.where(:product_image_id => pi.id).destroy_all
102
+ end
96
103
  end
97
104
 
98
105
  render :json => { :success => true }
@@ -93,7 +93,8 @@ module Caboose
93
93
  # DELETE /admin/media/:id
94
94
  def admin_delete
95
95
  return unless user_is_allowed('media', 'delete')
96
- Media.find(params[:id]).destroy
96
+ Media.find(params[:id]).destroy
97
+ ProductImage.where(:media_id => params[:id]).destroy_all
97
98
  render :json => { :success => true }
98
99
  end
99
100
 
@@ -104,6 +105,7 @@ module Caboose
104
105
  if ids
105
106
  ids.each do |id|
106
107
  Media.where(:id => id).destroy_all
108
+ ProductImage.where(:media_id => id).destroy_all
107
109
  end
108
110
  end
109
111
  render :json => { :success => true }
@@ -116,7 +118,13 @@ module Caboose
116
118
  original_name = params[:name]
117
119
  name = Caboose::Media.upload_name(original_name)
118
120
  m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name).first
119
- Media.create(:media_category_id => media_category_id, :original_name => original_name, :name => name, :processed => false) if m.nil?
121
+ if m.nil?
122
+ m = Media.create(:media_category_id => media_category_id, :original_name => original_name, :name => name, :processed => false)
123
+ end
124
+ p = Product.where(:media_category_id => media_category_id).last
125
+ if p
126
+ pi = ProductImage.create(:product_id => p.id, :media_id => m.id)
127
+ end
120
128
  render :json => { :success => true }
121
129
  end
122
130
 
@@ -284,7 +284,29 @@ module Caboose
284
284
  # GET /admin/products/:id/images
285
285
  def admin_edit_images
286
286
  return if !user_is_allowed('products', 'edit')
287
- @product = Product.find(params[:id])
287
+ @product = Product.find(params[:id])
288
+ config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
289
+ access_key = config['access_key_id']
290
+ secret_key = config['secret_access_key']
291
+ bucket = config['bucket']
292
+ policy = {
293
+ "expiration" => 1.hour.from_now.utc.xmlschema,
294
+ "conditions" => [
295
+ { "bucket" => "#{bucket}-uploads" },
296
+ { "acl" => "public-read" },
297
+ [ "starts-with", "$key", '' ],
298
+ [ 'starts-with', '$name', '' ],
299
+ [ 'starts-with', '$Filename', '' ],
300
+ ]
301
+ }
302
+ @policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
303
+ @signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, @policy)).gsub("\n","")
304
+ @s3_upload_url = "https://#{bucket}-uploads.s3.amazonaws.com/"
305
+ @aws_access_key_id = access_key
306
+
307
+ @top_media_category = @product.media_category.parent
308
+ @media_category = @product.media_category
309
+
288
310
  render :layout => 'caboose/admin'
289
311
  end
290
312
 
@@ -341,7 +363,11 @@ module Caboose
341
363
  when 'site_id' then product.site_id = value
342
364
  when 'vendor_id' then product.vendor_id = value
343
365
  when 'alternate_id' then product.alternate_id = value
344
- when 'title' then product.title = value
366
+ when 'title'
367
+ product.title = value
368
+ c = MediaCategory.where(:id => product.media_category_id).last
369
+ c.name = value
370
+ c.save
345
371
  when 'caption' then product.caption = value
346
372
  when 'featured' then product.featured = value
347
373
  when 'description' then product.description = value
@@ -409,6 +435,10 @@ module Caboose
409
435
  resp.error = "The title cannot be empty."
410
436
  else
411
437
  p = Product.new(:site_id => @site.id, :title => name)
438
+ mc = MediaCategory.where(:site_id => @site.id).where("parent_id IS NULL").exists? ? MediaCategory.where(:site_id => @site.id).where("parent_id IS NULL").last : MediaCategory.create(:name => "Media", :site_id => @site.id)
439
+ pc = MediaCategory.where(:name => "Products", :site_id => @site.id).exists? ? MediaCategory.where(:name => "Products", :site_id => @site.id).last : MediaCategory.create(:name => "Products", :site_id => @site.id, :parent_id => mc.id)
440
+ c = MediaCategory.create(:site_id => @site.id, :name => name, :parent_id => pc.id)
441
+ p.media_category_id = c.id
412
442
  p.save
413
443
  resp.redirect = "/admin/products/#{p.id}/general"
414
444
  end
@@ -4,6 +4,7 @@ module Caboose
4
4
  self.primary_key = 'id'
5
5
 
6
6
  belongs_to :site
7
+ belongs_to :media_category
7
8
  belongs_to :stackable_group, :class_name => 'Caboose::StackableGroup'
8
9
  belongs_to :vendor, :class_name => 'Caboose::Vendor'
9
10
  has_many :customizations, :class_name => 'Caboose::Product', :through => :customization_memberships
@@ -45,7 +46,8 @@ module Caboose
45
46
  :stackable_group_id ,
46
47
  :on_sale ,
47
48
  :allow_gift_wrap ,
48
- :gift_wrap_price
49
+ :gift_wrap_price ,
50
+ :media_category_id
49
51
 
50
52
  STATUS_ACTIVE = 'Active'
51
53
  STATUS_INACTIVE = 'Inactive'
@@ -3,6 +3,7 @@ module Caboose
3
3
  self.table_name = 'store_product_images'
4
4
 
5
5
  belongs_to :product
6
+ belongs_to :media
6
7
  has_many :product_image_variants
7
8
  has_many :variants, :through => :product_image_variants
8
9
 
@@ -17,7 +18,8 @@ module Caboose
17
18
  :image_updated_at,
18
19
  :square_offset_x,
19
20
  :square_offset_y,
20
- :square_scale_factor
21
+ :square_scale_factor,
22
+ :media_id
21
23
 
22
24
  has_attached_file :image,
23
25
  :path => ':caboose_prefixproducts/:product_id_:id_:style.:extension',
@@ -44,7 +46,8 @@ module Caboose
44
46
  end
45
47
 
46
48
  def url(size) # 'tiny', 'thumb', 'medium', 'large', 'huge'
47
- self.image.url(size)
49
+ return self.media.image.url(size) if !self.media_id.blank?
50
+ return self.image.url(size)
48
51
  end
49
52
 
50
53
  def urls
@@ -521,7 +521,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
521
521
  [ :stackable_group_id , :integer ],
522
522
  [ :on_sale , :boolean , { :default => false }],
523
523
  [ :allow_gift_wrap , :boolean , { :default => false }],
524
- [ :gift_wrap_price , :decimal , { :precision => 8, :scale => 2 }]
524
+ [ :gift_wrap_price , :decimal , { :precision => 8, :scale => 2 }],
525
+ [ :media_category_id , :integer ]
525
526
  ],
526
527
  Caboose::ProductImage => [
527
528
  [ :product_id , :integer ],
@@ -534,7 +535,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
534
535
  [ :image_updated_at , :datetime ],
535
536
  [ :square_offset_x , :integer ],
536
537
  [ :square_offset_y , :integer ],
537
- [ :square_scale_factor , :numeric ]
538
+ [ :square_scale_factor , :numeric ],
539
+ [ :media_id , :integer ]
538
540
  ],
539
541
  Caboose::ProductImageVariant => [
540
542
  [ :product_image_id , :integer ],
@@ -3,7 +3,7 @@ p = @product
3
3
  %>
4
4
  <%= render :partial => 'caboose/products/admin_header' %>
5
5
 
6
- <form action='/admin/products/<%= p.id %>/images' method='post' enctype='multipart/form-data' id='new_image_form' target='new_image_iframe'>
6
+ <!-- <form action='/admin/products/<%= p.id %>/images' method='post' enctype='multipart/form-data' id='new_image_form' target='new_image_iframe'>
7
7
  <input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>" />
8
8
  <p><input type='file' name='new_image' id='new_image' />
9
9
  <input type='submit' value='Add Image' onclick='add_image();' /></p>
@@ -11,12 +11,75 @@ p = @product
11
11
  <div id='new_image_message'></div>
12
12
  <iframe id='new_image_iframe' name='new_image_iframe' style='display: none;'></iframe>
13
13
  <div id='message'></div>
14
+ -->
15
+
16
+ <!-- <p>Upload new product images at the <a href="/admin/media">media browser</a>.</p> -->
17
+
18
+
19
+
20
+
21
+
22
+
23
+ <h2>Product Images</h2>
24
+
25
+ <div id='left_content' style="width:150px;">
26
+ <!-- <div id='categories'></div> -->
27
+ <div id='controls'></div>
28
+ </div>
29
+ <div id='right_content' style="margin-left:170px;">
30
+ <div id='uploader'></div>
31
+ <div id='media'></div>
32
+ </div>
33
+
34
+ <% content_for :caboose_css do %>
35
+ <%= stylesheet_link_tag 'caboose/admin_media_index' %>
36
+ <%= stylesheet_link_tag 'plupload/jquery.ui.plupload/css/jquery.ui.plupload.css' %>
37
+ <% end %>
38
+
39
+ <% content_for :caboose_js do %>
40
+ <%= javascript_include_tag 'caboose/model/all' %>
41
+ <%= javascript_include_tag 'caboose/admin_media_index.js' %>
42
+ <%= javascript_include_tag 'caboose/jquery-ui.drag-multiple.min.js' %>
43
+
44
+ <!-- production -->
45
+ <%= javascript_include_tag 'plupload/plupload.full.min.js' %>
46
+ <%= javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js' %>
47
+
48
+ <!-- debug
49
+ <script type="text/javascript" src="/assets/plupload/moxie.js"></script>
50
+ <script type="text/javascript" src="/assets/plupload/plupload.dev.js"></script>
51
+ <script type="text/javascript" src="/assets/plupload/jquery.ui.plupload/jquery.ui.plupload.js"></script>
52
+ -->
53
+
54
+ <script type="text/javascript">
55
+
56
+ var controller = false;
57
+ $(document).ready(function() {
58
+ controller = new MediaController({
59
+ top_cat_id: <%= raw Caboose.json(@media_category ? @top_media_category.id : false) %>,
60
+ cat_id: <%= raw Caboose.json(@media_category ? @media_category.id : false) %>,
61
+ s3_upload_url: '<%= raw @s3_upload_url %>',
62
+ aws_access_key_id: '<%= raw @aws_access_key_id %>',
63
+ policy: '<%= raw @policy %>',
64
+ signature: '<%= raw @signature %>',
65
+ refresh_unprocessed_images: false
66
+ });
67
+ });
68
+
69
+ </script>
70
+ <% end %>
71
+
72
+
73
+
74
+ <hr style="margin:40px 0 20px 0;"/>
75
+
14
76
 
15
77
  <div id='images'>
78
+ <h4>Assign Images to Variants</h4>
16
79
  <% if p.product_images.count > 0 %>
17
80
  <ul id='images_list' class='clearfix'>
18
81
  <% p.product_images.reorder(:position).each do |img| %>
19
- <% url = img.image.url(:tiny) %>
82
+ <% url = img.url(:tiny) %>
20
83
  <li id='img_<%= img.id %>'><div id='img_<%= img.id %>_container'><a href="javascript:select_image(<%= img.id %>);"><img src='<%= url %>' width='75' /></a></div></li>
21
84
  <% end %>
22
85
  </ul>
@@ -38,6 +101,9 @@ p = @product
38
101
  #images div.selected img { border: #ff3333 4px solid; }
39
102
  #images_list { list-style: none; margin: 0; padding: 0; }
40
103
  #images_list li { list-style: none; margin: 0 10px 10px 0; padding: 0; float: left; }
104
+ .delete_dropper {
105
+ margin-top: 0;
106
+ }
41
107
  </style>
42
108
  <% end %>
43
109
  <% content_for :caboose_js do %>
@@ -115,7 +181,7 @@ function select_image(image_id, confirm)
115
181
 
116
182
  $('#variants').empty().append('<br/>');
117
183
  $('#variants').append($('<div/>').attr('id','delete_message'));
118
- $('#variants').append($('<input/>').attr('type','button').val('Delete Image').click(function() { delete_image(image_id); }));
184
+ // $('#variants').append($('<input/>').attr('type','button').val('Delete Image').click(function() { delete_image(image_id); }));
119
185
  $('#variants').append(tbl);
120
186
  }
121
187
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.6.12'
2
+ VERSION = '0.6.13'
3
3
  end
@@ -1,6 +1,54 @@
1
1
  require "caboose/version"
2
2
 
3
3
  namespace :caboose do
4
+
5
+ desc "Create media categories for existing products on all sites"
6
+ task :create_product_media_categories => :environment do
7
+ sites = Caboose::Site.where(:use_store => true).all.each do |s|
8
+ puts "Processing categories for " + s.description
9
+ # Create the parent level Media category if it doesn't exist
10
+ media_category = Caboose::MediaCategory.where(:name => "Media", :site_id => s.id).where("parent_id IS NULL").exists? ? Caboose::MediaCategory.where(:name => "Media", :site_id => s.id).where("parent_id IS NULL").last : Caboose::MediaCategory.new
11
+ media_category.name = "Media"
12
+ media_category.site_id = s.id
13
+ media_category.save
14
+ # Create the Products category if it doesn't exist
15
+ product_category = Caboose::MediaCategory.where(:name => "Products", :site_id => s.id).exists? ? Caboose::MediaCategory.where(:name => "Products", :site_id => s.id).last : Caboose::MediaCategory.new
16
+ product_category.parent_id = media_category.id
17
+ product_category.name = "Products"
18
+ product_category.site_id = s.id
19
+ product_category.save
20
+ # Create new category for each product
21
+ Caboose::Product.where(:site_id => s.id).all.each do |p|
22
+ puts "Creating media category for " + p.title
23
+ p_category = Caboose::MediaCategory.where(:name => p.title, :site_id => s.id).exists? ? Caboose::MediaCategory.where(:name => p.title, :site_id => s.id).last : Caboose::MediaCategory.new
24
+ p_category.name = p.title
25
+ p_category.parent_id = product_category.id
26
+ p_category.site_id = s.id
27
+ p_category.save
28
+ p.media_category_id = p_category.id
29
+ p.save
30
+ end
31
+ end
32
+ end
33
+
34
+ desc "Migrate product images to media"
35
+ task :migate_product_images_to_media => :environment do
36
+ Caboose::ProductImage.where("image_file_name is not null AND media_id IS NULL").order("id DESC").all.each do |product_image|
37
+ next if product_image.product.nil?
38
+ puts "Saving media for Product Image " + product_image.id.to_s
39
+ m = nil
40
+ m = Caboose::Media.where(:id => product_image.media_id).first
41
+ m = Caboose::Media.create(:media_category_id => product_image.product.media_category_id) if m.nil?
42
+ product_image.media_id = m.id
43
+ product_image.save
44
+ m.original_name = product_image.image_file_name
45
+ m.name = Caboose::Media.upload_name(m.original_name)
46
+ m.image = URI.parse(product_image.image.url(:original))
47
+ m.processed = true
48
+ m.save
49
+ end
50
+ end
51
+
4
52
 
5
53
  desc "Create a new lite site"
6
54
  task :create_site => :environment do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.12
4
+ version: 0.6.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -660,7 +660,6 @@ files:
660
660
  - app/mailers/caboose/caboose_mailer.rb
661
661
  - app/mailers/caboose/login_mailer.rb
662
662
  - app/mailers/caboose/orders_mailer.rb
663
- - app/models/caboose/#Untitled-1#
664
663
  - app/models/caboose/ab_option.rb
665
664
  - app/models/caboose/ab_testing.rb
666
665
  - app/models/caboose/ab_value.rb
@@ -1,56 +0,0 @@
1
- ================================================================================
2
- Order packages
3
- ================================================================================
4
-
5
- # Create a single order package for the order
6
- sp = ShippingPackage.where(:site_id => order.site_id).first
7
- op = OrderPackage.create(:order_id => order.id, :shipping_package_id => sp.id)
8
-
9
- # Assign the line items to the order package
10
- order.line_items.each do |li|
11
- li.order_package_id = op.id
12
- li.save
13
- end
14
-
15
- ================================================================================
16
- Shipping
17
- ================================================================================
18
-
19
- sc = store_config
20
- sa = order.shipping_address
21
- origin = ActiveShipping::Location.new(:country => sc.origin_country, :state => sc.origin_state, :city => sc.origin_city, :zip => sc.origin_zip)
22
- destination = ActiveShipping::Location.new(:country => sc.origin_country, :state => sa.state, :city => sa.city, :postal_code => sa.zip)
23
- carriers = {}
24
- carriers['UPS'] = ActiveShipping::UPS.new(:login => sc.ups_username, :password => sc.ups_password, :key => sc.ups_key, :origin_account => sc.ups_origin_account)
25
- carriers['USPS'] = ActiveShipping::USPS.new( :login => sc.usps_username) if order.total < 150
26
-
27
- all_rates = []
28
- order.order_packages.all.each do |op|
29
-
30
- flat_rate = true
31
- op.line_items do |li|
32
- flat_rate = false if !li.variant.flat_rate_shipping
33
- end
34
- if flat_rate
35
- v = op.line_items.first.variant
36
- all_rates << { :order_package => op, :rates => [{ :shipping_method => v.flat_rate_shipping_method, :total_price => (v.flat_rate_shipping_single/100) }] }
37
- else
38
- sp = op.shipping_package
39
- package = op.activemerchant_package
40
- rates = []
41
- carriers.each do |name, carrier|
42
- resp = carrier.find_rates(origin, destination, package)
43
- resp.rates.sort_by(&:price).each do |rate|
44
- sm = ShippingMethod.where( :carrier => name, :service_code => rate.service_code).first
45
- sm = ShippingMethod.create(:carrier => name, :service_code => rate.service_code, :service_name => rate.service_name) if sm.nil?
46
- next if !sp.uses_shipping_method(sm)
47
- price = rate.total_price
48
- price = rate.package_rates[0].rate if price.nil? && rate.package_rates && rate.package_rates.count > 0
49
- rates << { :shipping_method => sm, :total_price => (price.to_d/100) }
50
- end
51
- end
52
- all_rates << { :order_package => op, :rates => rates }
53
- end
54
-
55
- end
56
- return all_rates