caboose-cms 0.8.25 → 0.8.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f96a208dfdb1074c18a5b5f0c845276dd631798
4
- data.tar.gz: 60d73ecbb0e26bc549c8131c1cde2a01334dba57
3
+ metadata.gz: 41bf1ce6d0e61f964d2f161da9b1bf4719786fe5
4
+ data.tar.gz: 6e4f08e55f99e6b8023803edbbf1e1f7bf247561
5
5
  SHA512:
6
- metadata.gz: bf1a6499f62a952971b09ebd6fe6c4eb64c29b165885bed861abb516e78af0a1dc56e5bbdd3d0a3fc7fe9305dd0b756e5eb9965f7c4e00deffc1920bd78e8272
7
- data.tar.gz: 949c6f709388a4190ce2583c0ef432e63f40f0621aa7e4acaef9a800c08a7417184b6aab86e696336b9679cfe01a44644de5bc9534bedcee09b960bf2b88def8
6
+ metadata.gz: 55d17b778bef6a0d74bc48f68945c9156b8e452d0c80ae13d3a8495180f2dca5e2c4577bc55775291640d48c647bb7b0b2bc7a4cdf8fb06ac6f2017f897413b5
7
+ data.tar.gz: 05db00cfc1cf84ac39845441eec91d590399b0ca45e76ca8d8338fbea9997652fb1f77f738fa9dac95c3fc665aa75f5e17b2874f30f2a8c24586007fd450494c
@@ -10,8 +10,8 @@ module Caboose
10
10
 
11
11
  # @route GET /admin/products/stubs
12
12
  def admin_stubs
13
- title = params[:title].strip.downcase.split(' ')
14
- render :json => [] and return if title.length == 0
13
+ title = params[:title] ? params[:title].strip.downcase.split(' ') : nil
14
+ render :json => [] and return if title.nil? || title.length == 0
15
15
 
16
16
  where = ["site_id = ?"]
17
17
  vars = [@site.id]
@@ -462,6 +462,7 @@ module Caboose
462
462
  resp = Caboose::StdClass.new
463
463
  name = params[:name]
464
464
  pd = @site.product_default
465
+ vd = @site.variant_default
465
466
 
466
467
  if name.length == 0
467
468
  resp.error = "The title cannot be empty."
@@ -482,6 +483,39 @@ module Caboose
482
483
  p.gift_wrap_price = pd.gift_wrap_price
483
484
 
484
485
  p.save
486
+
487
+ v = Variant.new
488
+ v.product_id = p.id
489
+ v.option1 = p.default1 if p.option1
490
+ v.option2 = p.default2 if p.option2
491
+ v.option3 = p.default3 if p.option3
492
+
493
+ v.cost = vd.cost
494
+ v.price = vd.price
495
+ v.available = vd.available
496
+ v.quantity_in_stock = vd.quantity_in_stock
497
+ v.ignore_quantity = vd.ignore_quantity
498
+ v.allow_backorder = vd.allow_backorder
499
+ v.weight = vd.weight
500
+ v.length = vd.length
501
+ v.width = vd.width
502
+ v.height = vd.height
503
+ v.volume = vd.volume
504
+ v.cylinder = vd.cylinder
505
+ v.requires_shipping = vd.requires_shipping
506
+ v.taxable = vd.taxable
507
+ v.shipping_unit_value = vd.shipping_unit_value
508
+ v.flat_rate_shipping = vd.flat_rate_shipping
509
+ v.flat_rate_shipping_package_id = vd.flat_rate_shipping_package_id
510
+ v.flat_rate_shipping_method_id = vd.flat_rate_shipping_method_id
511
+ v.flat_rate_shipping_single = vd.flat_rate_shipping_single
512
+ v.flat_rate_shipping_combined = vd.flat_rate_shipping_combined
513
+ v.status = vd.status
514
+ v.downloadable = vd.downloadable
515
+ v.is_bundle = vd.is_bundle
516
+
517
+ v.save
518
+
485
519
  resp.redirect = "/admin/products/#{p.id}/general"
486
520
  end
487
521
  render :json => resp
@@ -36,12 +36,12 @@ module Caboose
36
36
 
37
37
  if @product.variants.nil? || @product.variants.count == 0
38
38
  v = Variant.new
39
+ v.product_id = @product.id
39
40
  v.option1 = @product.default1 if @product.option1
40
41
  v.option2 = @product.default2 if @product.option2
41
42
  v.option3 = @product.default3 if @product.option3
42
43
  v.status = 'Active'
43
- @product.variants = [v]
44
- @product.save
44
+ v.save
45
45
  end
46
46
  @variant = params[:variant_id] ? Variant.find(params[:variant_id]) : @product.variants[0]
47
47
  @highlight_variant_id = params[:highlight] ? params[:highlight].to_i : nil
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.25'
2
+ VERSION = '0.8.26'
3
3
  end
@@ -308,11 +308,39 @@ namespace :caboose do
308
308
  caboose_correct_sequences
309
309
  end
310
310
 
311
- desc "Resets the admin password to 'caboose'"
312
- task :reset_admin_pass => :environment do
313
- admin_user = Caboose::User.where(username: 'admin').first
311
+ desc "Resets the admin password to 'caboose'"
312
+ task :reset_admin_pass, [:site_name] => :environment do |t, args|
313
+ site = Caboose::Site.where(:name => args.first).first
314
+ if site.nil?
315
+ puts "Error: can't find a site with that name."
316
+ return
317
+ end
318
+ admin_user = Caboose::User.where(:username => 'admin', :site_id => site.id).first
319
+ if admin_user.nil?
320
+ puts "Error: can't find admin user for site #{site.name}."
321
+ return
322
+ end
314
323
  admin_user.password = Digest::SHA1.hexdigest(Caboose::salt + 'caboose')
315
324
  admin_user.save
325
+ puts "Password reset successfully for the admin user for site #{site.name}."
326
+ end
327
+
328
+ desc "Verify store products have a default variant"
329
+ task :verify_variants_exist => :environment do
330
+ query = ["select id from store_products where id not in (select distinct product_id from store_variants) order by site_id, status"]
331
+ rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, query))
332
+ return if rows.nil? || rows.count == 0
333
+
334
+ rows.each do |row|
335
+ p = Caboose::Product.find(row[0])
336
+ v = Caboose::Variant.new
337
+ v.product_id = p.id
338
+ v.option1 = p.default1 if p.option1
339
+ v.option2 = p.default2 if p.option2
340
+ v.option3 = p.default3 if p.option3
341
+ v.status = 'Active'
342
+ v.save
343
+ end
316
344
  end
317
345
 
318
346
  desc "Clears sessions older than the length specified in the caboose config from the sessions table"
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.8.25
4
+ version: 0.8.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-19 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg